华为 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

你可能感兴趣的:(apache,tomcat,xml,SOAP,华为)