华为 ParlayX 接口同步订购关系的soap服务端

与联通vasp平台通信的sp需要的,同步订购关系soap服务端

 package com.ml.service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;

import com.ml.mms.service.UsersService;
import com.ml.mms.tools.LogOper;


public class SyncOrderService {

 private static UsersService service=new UsersService();
 private static LogOper logger=new LogOper();
 private static String telno="";
 private static String serviceType="";
 private static String sPPServiceID="";
 private static String updateType="";
 private static String updateTime="";
 
 public OMElement SyncOrderRelation(OMElement in) throws Exception {
  in.build();
  in.detach();
  Iterator<OMElement> childs = in.getChildElements();
  while (childs.hasNext()) {
   OMElement child = childs.next();
   String name = child.getLocalName();
   if (name.equals("User_ID")) {// 用户信息
    Iterator<OMElement> childElements = child.getChildElements();
    while (childElements.hasNext()) {
     OMElement element = childElements.next();
     if (element.getLocalName().equals("MSISDN")) {
      telno = element.getText();
      telno=telno.substring(2);
     }
    }
   } else if (name.equals("ServiceType")) {
    serviceType = child.getText();
   } else if (name.equals("SPPServiceID")) {
    sPPServiceID = child.getText().trim();
   } else if (name.equals("UpdateType")) {
    updateType = child.getText();
   } else if (name.equals("UpdateTime")) {
    updateTime = child.getText();
   }
  }
  
  // 调用 定制取消 接口 处理数据
//控制台显示
String time=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS").format(new Date());
System.out.println(time+"serviceType:"+serviceType);
System.out.println(time+"sPPServiceID:"+sPPServiceID);
System.out.println(time+"updateTime:"+updateTime);
System.out.println(time+"updateType:"+updateType);
System.out.println(time+"telno:"+telno);
System.out.println(time+"info:"+service);

  boolean done=false;
  if(updateType.equals("1")&&serviceType.equals("3")){//订购,3:彩信业务
   try {
    int categoryID=service.getCategoryID(sPPServiceID);
System.out.println("......订购...... /n categoryID:"+categoryID);

//DB操作
    service.insertUser(Long.valueOf(telno.trim()).longValue(), updateTime, categoryID);

    done=true;

   } catch (NumberFormatException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
   }
  }else if(updateType.equals("2")&&serviceType.equals("3")){ //取消
    try {
System.out.println("......取消......");
     int categoryID = service.getCategoryID(sPPServiceID);
System.out.println("categoryID"+categoryID);

//DB操作
     int userID=service.getUserid(categoryID, Long.parseLong(telno));
     service.deleteUser(userID, Long.parseLong(telno), "admin");

     done=true;
    } catch (Exception e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }

  }
  //将处理结果返给soap发送者
  OMFactory factory = OMAbstractFactory.getOMFactory();
  OMNamespace omNS = factory.createOMNamespace("http://www.unicom.com.cn/dsmp/message/",
    "wsdlns");
  
  //数字空间
  OMNamespace xsiNS= factory.createOMNamespace("http://www.w3.org/2001/XMLSchema-instance", "xsi");
    
  OMElement method = factory.createOMElement("SyncOrderRelationResponse", omNS);
  
  OMElement value = factory.createOMElement("hRet",null);
  
      value.addAttribute(factory.createOMAttribute("type", xsiNS, "xsd:int"));
  //处理的结果(0:成,1:败)
  if(done){
   value.addChild(factory.createOMText(value, "0"));
  }else{
   value.addChild(factory.createOMText(value, "1"));
  }
  method.addChild(value);
  return method;
 }
}

接着:需要生成aar文件,步骤:将工程导出jar文件,用winrar打开jar,将services.xml放入META-INF目录下,将jar改名aar(直接jar也行),services.xml内容:

//services.xml

<service name="MainlinkMMSService">
    <description>
        Mainlink axiom
    </description>
    <parameter name="ServiceClass">com.ml.service.SyncOrderService</parameter>
    <operation name="SyncOrderRelation">
        <messageReceiver class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
    </operation>

</service>

//最后,把此aar文件放到axis2/WEB-INF/services下,起到tomcat

OK

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

gamebox1

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值