您的位置:首页 > 运维架构 > Tomcat

移动MISC 1.6平台Provison同步接口开发(Tomcat 5.5 + AXIS 1.2)

2005-07-08 13:51 519 查看
----------------------------------------------------------------/** * 版权: 雪夜清风 [ Jeansan] 所有 ; * * MSN: qingfeng0826@hotmail.com * QQ : 331999816 * * */---------------------------------------------------------------- 说明 :系统采用AXIS 1.2+Tomcat 5.5,如果无axis知识,建议可以到IBM开发者上搜索相关 AXIS 文档浏览 ————————————————————————————————————— 1、 配置好AXIS 1.22、 将wsdl 文件 copy 到 /TOMCAT_HOME/webapps/axis/WEB-INF 下,Wsdl 文件由于MISC提供的不能生成 header ;经过修改以后的新的WSDL文件为:
[align=center]
<definitions xmlns:ws="http://www.monternet.com/dsmp/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.ort/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:dsmp="http://www.monternet.com/dsmp/schemas/" targetNamespace="http://www.monternet.com/dsmp/wsdl/">
<types>
<schema targetNamespace="http://www.monternet.com/dsmp/schemas/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="qualified">
<complexType name="address_info_schema">
<sequence>
<element name="DeviceType" type="xsd:integer"/>
<element name="DeviceID" type="xsd:string"/>
</sequence>
</complexType>
<complexType name="user_id_schema">
<sequence>
<element name="UserIDType" type="xsd:integer"/>
<element name="MSISDN" type="xsd:string"/>
<element name="PseudoCode" type="xsd:base64Binary"/>
</sequence>
</complexType>
<complexType name="service_id_schema">
<sequence>
<element name="ServiceIDType" type="integer"/>
<element name="SPID" type="string"/>
<element name="SPServiceID" type="string"/>
<element name="AccessNo" type="string"/>
<element name="FeatureStr" type="base64Binary"/>
</sequence>
</complexType>
<!-- request & response -->
<element name="TransactionID" type="xsd:string"/>
<element name="SyncOrderRelationReq" type="dsmp:SyncOrderRelationReqType"/>
<complexType name="SyncOrderRelationReqType">
<sequence>
<element name="MsgType" type="xsd:string"/>
<element name="Version" type="xsd:string"/>
<element name="Send_Address" type="dsmp:address_info_schema"/>
<element name="Dest_Address" type="dsmp:address_info_schema"/>
<element name="FeeUser_ID" type="dsmp:user_id_schema"/>
<element name="DestUser_ID" type="dsmp:user_id_schema"/>
<element name="LinkID" type="xsd:string" minOccurs="0"/>
<element name="ActionID" type="xsd:integer"/>
<element name="ActionReasonID" type="xsd:integer"/>
<element name="SPID" type="xsd:string" minOccurs="0"/>
<element name="SPServiceID" type="xsd:string"/>
<element name="AccessMode" type="xsd:integer" minOccurs="0"/>
<element name="FeatureStr" type="xsd:base64Binary" minOccurs="0"/>
</sequence>
</complexType>
<element name="SyncOrderRelationResp" type="dsmp:SyncOrderRelationRespType"/>
<complexType name="SyncOrderRelationRespType">
<sequence>
<element name="MsgType" type="xsd:string"/>
<element name="Version" type="xsd:string"/>
<element name="hRet" type="xsd:integer"/>
</sequence>
</complexType>
<element name="SubscribeServiceReq" type="dsmp:SubscribeServiceReqType"/>
<complexType name="SubscribeServiceReqType">
<sequence>
<element name="Version" type="string"/>
<element name="MsgType" type="string"/>
<element name="Send_Address" type="dsmp:address_info_schema"/>
<element name="Dest_Address" type="dsmp:address_info_schema"/>
<element name="FeeUser_ID" type="dsmp:user_id_schema"/>
<element name="DestUser_ID" type="dsmp:user_id_schema"/>
<element name="Service_ID" type="dsmp:service_id_schema"/>
<element name="FeatureStr" type="base64Binary" minOccurs="0"/>
</sequence>
</complexType>
<element name="SubscribeServiceResp" type="dsmp:SubscribeServiceRespType"/>
<complexType name="SubscribeServiceRespType">
<sequence>
<element name="Version" type="string"/>
<element name="MsgType" type="string"/>
<element name="hRet" type="integer"/>
<element name="LinkID" type="string" minOccurs="0"/>
</sequence>
</complexType>
<element name="UnSubscribeServiceReq" type="dsmp:UnSubscribeServiceReqType"/>
<complexType name="UnSubscribeServiceReqType">
<sequence>
<element name="Version" type="string"/>
<element name="MsgType" type="string"/>
<element name="Send_Address" type="dsmp:address_info_schema"/>
<element name="Dest_Address" type="dsmp:address_info_schema"/>
<element name="FeeUser_ID" type="dsmp:user_id_schema"/>
<element name="DestUser_ID" type="dsmp:user_id_schema"/>
<element name="Service_ID" type="dsmp:service_id_schema"/>
</sequence>
</complexType>
<element name="UnSubscribeServiceResp" type="dsmp:UnSubscribeServiceRespType"/>
<complexType name="UnSubscribeServiceRespType">
<sequence>
<element name="Version" type="string"/>
<element name="MsgType" type="string"/>
<element name="hRet" type="integer"/>
</sequence>
</complexType>
</schema>
</types>
<message name="ma.SyncOrderRelationReq">
<part name="SyncOrderRelationInput" element="dsmp:SyncOrderRelationReq"/>
<part name="TransactionIDInput" element="dsmp:TransactionID"/>
</message>
<message name="ma.SyncOrderRelationResp">
<part name="SyncOrderRelationOutput" element="dsmp:SyncOrderRelationResp"/>
<part name="TransactionIDOut" element="dsmp:TransactionID"/>
</message>
<message name="ma.SubscribeServiceReq">
<part name="SubscribeServiceInput" element="dsmp:SubscribeServiceReq"/>
<part name="TransactionIDInput" element="dsmp:TransactionID"/>
</message>
<message name="ma.SubscribeServiceResp">
<part name="SubscribeServiceOutput" element="dsmp:SubscribeServiceResp"/>
<part name="TransactionIDOut" element="dsmp:TransactionID"/>
</message>
<message name="ma.UnSubscribeServiceReq">
<part name="UnSubscribeServiceInput" element="dsmp:UnSubscribeServiceReq"/>
<part name="TransactionIDInput" element="dsmp:TransactionID"/>
</message>
<message name="ma.UnSubscribeServiceResp">
<part name="UnSubscribeServiceOutput" element="dsmp:UnSubscribeServiceResp"/>
<part name="TransactionIDOut" element="dsmp:TransactionID"/>
</message>
<portType name="maPort">
<operation name="SyncOrderRelation">
<input message="ws:ma.SyncOrderRelationReq"/>
<output message="ws:ma.SyncOrderRelationResp"/>
</operation>
<operation name="SubscribeService">
<input message="ws:ma.SubscribeServiceReq"/>
<output message="ws:ma.SubscribeServiceResp"/>
</operation>
<operation name="UnSubscribeService">
<input message="ws:ma.UnSubscribeServiceReq"/>
<output message="ws:ma.UnSubscribeServiceResp"/>
</operation>
</portType>
<binding name="maPortBinding" type="ws:maPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="SubscribeService">
<soap:operation soapAction="sim.SubscribeService" style="document"/>
<input>
<soap:body use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://10.1.2.122/misc/dsmp.xsd"/>
<soap:header message="ws:ma.SubscribeServiceReq" part="TransactionIDInput" use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding" namespace="http://10.1.2.122/misc/dsmp.xsd"/>
</input>
<output>
<soap:body use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://10.1.2.122/misc/dsmp.xsd"/>
<soap:header message="ws:ma.SubscribeServiceResp" part="TransactionIDOut" use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding" namespace="http://10.1.2.122/misc/dsmp.xsd"/>
</output>
</operation>
<operation name="SyncOrderRelation">
<soap:operation soapAction="sim.SyncOrderRelation" style="document"/>
<input>
<soap:body use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://10.1.2.122/misc/dsmp.xsd"/>
<soap:header message="ws:ma.SyncOrderRelationReq" part="TransactionIDInput" use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding" namespace="http://10.1.2.122/misc/dsmp.xsd"/>
</input>
<output>
<soap:body use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://10.1.2.122/misc/dsmp.xsd"/>
<soap:header message="ws:ma.SyncOrderRelationResp" part="TransactionIDOut" use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding" namespace="http://10.1.2.122/misc/dsmp.xsd"/>
</output>
</operation>
<operation name="UnSubscribeService">
<soap:operation soapAction="sim.UnSubscribeService" style="document"/>
<input>
<soap:body use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://10.1.2.122/misc/dsmp.xsd"/>
<soap:header message="ws:ma.UnSubscribeServiceReq" part="TransactionIDInput" use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding" namespace="http://10.1.2.122/misc/dsmp.xsd"/>
</input>
<output>
<soap:body use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://10.1.2.122/misc/dsmp.xsd"/>
<soap:header message="ws:ma.UnSubscribeServiceResp" part="TransactionIDOut" use="literal" encodingStyle="http://schemas.xmlsoap.org/soap/encoding" namespace="http://10.1.2.122/misc/dsmp.xsd"/>
</output>
</operation>
</binding>
<service name="dsmp">
<port name="maPort" binding="ws:maPortBinding">
<soap:address location="http://localhost:8080/axis/services/maPort"/>
</port>
</service>
</definitions>
[/align]
3、 生成客户端,服务端代码:
使用命令:Java -Djava.ext.dirs=lib org.apache.axis.wsdl.WSDL2Java --server-side --skeletonDeploy true dsmp.wsdl4、 deploy.wsdd 用来发布service
MaPortBindingImpl.java 服务短编程使用
MaPortBindingStub.java 客户端编程使用5、 建立服务:使用命令 :java org.apache.axis.utils.Admin client|server deploy.wsdd
建立服务端和客户端的服务。如果建立服务不成功,可以直接将com/monternet/www/dsmp/wsdl下的deploy.wsdd中的<service>...</service>之间的文字直接拷贝到server-config.wsdd文件中。查看服务,如果没有发布成功是因为没有生成相关的class文件,可以先编译MaPortBindingSkeleton.java文件,然后查看是否发布
6、 编写测试代码:
package com.misc.client;import java.math.BigInteger;import java.net.URL;import javax.xml.rpc.holders.StringHolder;import com.monternet.www.dsmp.schemas.Address_info_schema;import com.monternet.www.dsmp.schemas.SyncOrderRelationReqType;import com.monternet.www.dsmp.schemas.SyncOrderRelationRespType;import com.monternet.www.dsmp.schemas.User_id_schema;import com.monternet.www.dsmp.schemas.holders.SyncOrderRelationRespTypeHolder;import com.monternet.www.dsmp.wsdl.MaPortBindingStub;//import com.monternet.www.dsmp.*;
/* * 移动MISC系统升级,SP客户端测试环境 */public class miscClient {

private static BigInteger msg; public static void main(String[] args) { MaPortBindingStub binding = null; SyncOrderRelationRespType resp = null; SyncOrderRelationReqType req=new SyncOrderRelationReqType(); SyncOrderRelationRespTypeHolder syncOrderRelationOutput = new SyncOrderRelationRespTypeHolder(); StringHolder transactionIDOut = new StringHolder(); /** * * TransactionID 由返回的provision包里面的对应字段来决定,然后放到响应包里面的对应字段 * TransactionID不是sp生成的 * */ // 根据 - 数据业务管理平台接口规范-1.5.1 定义。可以参考schemas 下的类文件 BigInteger devicetypeSend_Address = BigInteger.valueOf(201); BigInteger devicetypeDest_Address = BigInteger.valueOf(0); BigInteger UserIDTypeFeeUser_ID = BigInteger.valueOf(1); BigInteger ActionID = BigInteger.valueOf(1); BigInteger ActionReasonID = BigInteger.valueOf(1); BigInteger AccessMode = BigInteger.valueOf(3);

byte[] pseudoCode = new byte[]{}; // 对于一些固定的值来决定 Address_info_schema Send_Address = new Address_info_schema(); Send_Address.setDeviceID("misc"); Send_Address.setDeviceType(devicetypeSend_Address);
Address_info_schema Dest_Address = new Address_info_schema(); Dest_Address.setDeviceID("1212"); Dest_Address.setDeviceType(devicetypeDest_Address);
User_id_schema FeeUser_ID = new User_id_schema(); FeeUser_ID.setMSISDN("13583153328"); FeeUser_ID.setUserIDType(UserIDTypeFeeUser_ID);
FeeUser_ID.setPseudoCode(pseudoCode); User_id_schema DestUser_ID = new User_id_schema(); DestUser_ID.setMSISDN("13583153328"); DestUser_ID.setUserIDType(UserIDTypeFeeUser_ID);
DestUser_ID.setPseudoCode(pseudoCode); /** * 给请求赋值 */ req.setMsgType("SubscribeServiceReq"); req.setVersion("1.5.0"); req.setSend_Address(Send_Address); req.setDest_Address(Dest_Address); req.setFeeUser_ID(FeeUser_ID); req.setDestUser_ID(DestUser_ID); req.setLinkID(""); // 可选 req.setActionID(ActionID); req.setActionReasonID(ActionReasonID); req.setSPID("082601"); req.setSPServiceID("dz"); req.setAccessMode(AccessMode); try { URL endpoint = new URL("http://localhost:8080/axis/services/maPort"); //详细见说明1 和说明 2 说明3 binding = (MaPortBindingStub) new com.monternet.www.dsmp.wsdl.DsmpLocator().getmaPort(endpoint); binding.setTimeout(60000);

binding.syncOrderRelation(req,"00240301806870",syncOrderRelationOutput,transactionIDOut);
resp = syncOrderRelationOutput.value;
String tranID = transactionIDOut.value;

System.out.println(tranID);
System.out.println(resp.getMsgType());
System.out.println(resp.getVersion());
System.out.println(resp.getHRet());
if((resp.getHRet()).equals("0")){
System.out.println("Transact Success!");
} } catch (Exception e) { e.printStackTrace(); }

} }
说明1、 该URL是在真实环境中提交给 MISC平台的地址;
说明2、 该URL指向本地的服务地址,一定要保证 访问该URL时候提示为:

maPort

Hi there, this is an AXIS service!

Perhaps there will be a form for invoking the service here...
说明3 、本出URL的地址中端口为 808 是因为在 TCPMonitor中设置 监听端口转发为 808。 如果不开启TCPMonitor 则直接设置为8080
7、 编写服务短返回代码
[align=center]
// 添加返回

SyncOrderRelationRespType ret = new SyncOrderRelationRespType();

BigInteger hret = BigInteger.valueOf(0);

ret.setMsgType("SubscribeServiceResp");

ret.setHRet(hret);

ret.setVersion("1.5.0"); //return null;
[/align]
8、 问题解决:
n 包含 xmls=““ 问题把wsdl文件里的 elementFormDefault="unqualified" 和attributeFormDefault="unqualified"都改成qualified就不会出现xmlns=""的问题了,不需要改axis源代码

9、客户端程序:(修改MaPortBindingImpl.java文件)
把wsdl文件里的 elementFormDefault="unqualified" 和attributeFormDefault="unqualified"都改成qualified就不会出现xmlns=""的问题了,不需要改axis源代码

9、客户端程序:(修改MaPortBindingImpl.java文件)

/**
* MaPortBindingImpl.java
* 只实现正向定购同步功能,其他可以参考
*/
package com.monternet.www.dsmp.wsdl;import com.monternet.www.dsmp.schemas.*;import java.math.BigInteger;import javax.xml.rpc.holders.StringHolder;
public class MaPortBindingImpl implements com.monternet.www.dsmp.wsdl.MaPort{
public void subscribeService(com.monternet.www.dsmp.schemas.SubscribeServiceReqType subscribeServiceInput, java.lang.String transactionIDInput, com.monternet.www.dsmp.schemas.holders.SubscribeServiceRespTypeHolder subscribeServiceOutput, javax.xml.rpc.holders.StringHolder transactionIDOut) throws java.rmi.RemoteException {
subscribeServiceOutput.value = new com.monternet.www.dsmp.schemas.SubscribeServiceRespType();
transactionIDOut.value = new java.lang.String();
} public void syncOrderRelation(com.monternet.www.dsmp.schemas.SyncOrderRelationReqType syncOrderRelationInput, java.lang.String transactionIDInput, com.monternet.www.dsmp.schemas.holders.SyncOrderRelationRespTypeHolder syncOrderRelationOutput, javax.xml.rpc.holders.StringHolder transactionIDOut) throws java.rmi.RemoteException {
//syncOrderRelationOutput.value = new com.monternet.www.dsmp.schemas.SyncOrderRelationRespType();
// transactionIDOut.value = new java.lang.String();
SyncOrderRelationReqType request;
request = syncOrderRelationInput;
String ver = syncOrderRelationInput.getVersion();
String msgType = "SyncOrderRelationResp"; //syncOrderRelationInput.getMsgType(); SyncOrderRelationRespType resp = new SyncOrderRelationRespType();
resp.setVersion(ver);
resp.setMsgType(msgType); /**
* 是否成功的标志
*
* 所有的业务处理都在这里
* String getHRet(SyncOrderRelationReqType req)
*/ String checkhret = getResult(request);
java.math.BigInteger hret = new java.math.BigInteger(checkhret);
resp.setHRet(hret); syncOrderRelationOutput.value = resp; //new com.monternet.www.dsmp.schemas.SyncOrderRelationRespType();
//该消息编号
transactionIDOut.value = transactionIDInput; //new java.lang.String();
}

public String getResult(com.monternet.www.dsmp.schemas.SyncOrderRelationReqType syncInput){ com.monternet.www.dsmp.schemas.SyncOrderRelationReqType req;
String spid,isdn,spserviceid,ver; req = syncInput;
ver = req.getVersion();
spid = req.getSPID();
isdn = req.getDestUser_ID().getMSISDN();
spserviceid = req.getSPServiceID();

if(!(ver.equals("") || spid.equals("") || isdn.equals("") || spserviceid.equals(""))){
return "0";
}
else
{ return "1";
} } public void unSubscribeService(com.monternet.www.dsmp.schemas.UnSubscribeServiceReqType unSubscribeServiceInput, java.lang.String transactionIDInput, com.monternet.www.dsmp.schemas.holders.UnSubscribeServiceRespTypeHolder unSubscribeServiceOutput, javax.xml.rpc.holders.StringHolder transactionIDOut) throws java.rmi.RemoteException {
unSubscribeServiceOutput.value = new com.monternet.www.dsmp.schemas.UnSubscribeServiceRespType();
transactionIDOut.value = new java.lang.String();
}}
/**
* MaPortBindingImpl.java
* 只实现正向定购同步功能,其他可以参考
*/
package com.monternet.www.dsmp.wsdl;import com.monternet.www.dsmp.schemas.*;import java.math.BigInteger;import javax.xml.rpc.holders.StringHolder;
public class MaPortBindingImpl implements com.monternet.www.dsmp.wsdl.MaPort{
public void subscribeService(com.monternet.www.dsmp.schemas.SubscribeServiceReqType subscribeServiceInput, java.lang.String transactionIDInput, com.monternet.www.dsmp.schemas.holders.SubscribeServiceRespTypeHolder subscribeServiceOutput, javax.xml.rpc.holders.StringHolder transactionIDOut) throws java.rmi.RemoteException {
subscribeServiceOutput.value = new com.monternet.www.dsmp.schemas.SubscribeServiceRespType();
transactionIDOut.value = new java.lang.String();
} public void syncOrderRelation(com.monternet.www.dsmp.schemas.SyncOrderRelationReqType syncOrderRelationInput, java.lang.String transactionIDInput, com.monternet.www.dsmp.schemas.holders.SyncOrderRelationRespTypeHolder syncOrderRelationOutput, javax.xml.rpc.holders.StringHolder transactionIDOut) throws java.rmi.RemoteException {
//syncOrderRelationOutput.value = new com.monternet.www.dsmp.schemas.SyncOrderRelationRespType();
// transactionIDOut.value = new java.lang.String();
SyncOrderRelationReqType request;
request = syncOrderRelationInput;
String ver = syncOrderRelationInput.getVersion();
String msgType = "SyncOrderRelationResp"; //syncOrderRelationInput.getMsgType(); SyncOrderRelationRespType resp = new SyncOrderRelationRespType();
resp.setVersion(ver);
resp.setMsgType(msgType); /**
* 是否成功的标志
*
* 所有的业务处理都在这里
* String getHRet(SyncOrderRelationReqType req)
*/ String checkhret = getResult(request);
java.math.BigInteger hret = new java.math.BigInteger(checkhret);
resp.setHRet(hret); syncOrderRelationOutput.value = resp; //new com.monternet.www.dsmp.schemas.SyncOrderRelationRespType();
//该消息编号
transactionIDOut.value = transactionIDInput; //new java.lang.String();
}

public String getResult(com.monternet.www.dsmp.schemas.SyncOrderRelationReqType syncInput){ com.monternet.www.dsmp.schemas.SyncOrderRelationReqType req;
String spid,isdn,spserviceid,ver; req = syncInput;
ver = req.getVersion();
spid = req.getSPID();
isdn = req.getDestUser_ID().getMSISDN();
spserviceid = req.getSPServiceID();

if(!(ver.equals("") || spid.equals("") || isdn.equals("") || spserviceid.equals(""))){
return "0";
}
else
{ return "1";
} } public void unSubscribeService(com.monternet.www.dsmp.schemas.UnSubscribeServiceReqType unSubscribeServiceInput, java.lang.String transactionIDInput, com.monternet.www.dsmp.schemas.holders.UnSubscribeServiceRespTypeHolder unSubscribeServiceOutput, javax.xml.rpc.holders.StringHolder transactionIDOut) throws java.rmi.RemoteException {
unSubscribeServiceOutput.value = new com.monternet.www.dsmp.schemas.UnSubscribeServiceRespType();
transactionIDOut.value = new java.lang.String();
}}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: