SP业务开发实例_说明

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

1、工具下载1.1JDKJDK1.5下载页面:下载链接::3/jdk-1_5_0_13-windows-i586-p.exe双击jdk-1_5_0_13-windows-i586-p.exe安装JDK1.5。1.2Eclipse(开发环境)Eclipse下载页面:下载链接:=/eclipse/downloads/drops/R-3.3.1-200709211145/eclipse-SDK-3.3.1-win32.zip&url==385解压缩eclipse-SDK-3.3.1-win32.zip即可(不需安装)。1.3Tomcat(Web服务器)Tomcat6.0下载页面:下载链接:解压缩apache-tomcat-6.0.14.zip即可(不需安装)。1.4AXIS2(SOAP引擎)AXIS2下载页面:下载链接:解压缩axis2-1.3-bin.zip,lib目录下的jar包是WebService业务开发需要的库文件。axis2-1.3-war.zip下载链接:、Tomcat+AXIS2配置1.解压缩apache-tomcat-6.0.14.zip,axis2-1.3-bin.zip,axis2-1.3-war.zip。2.配置AXIS2环境变量:右击“我的电脑”-属性-高级-选择“环境变量”将axis2-1.3下的bin目录增加到Path系统环境变量中(其中D:\axis2-1.3\bin需要根据实际情况设置):3.解压缩axis2-1.3-war.zip后,将axis2.war复制到Tomcat目录\webapps下。4.双击Tomcat目录\bin\startup.bat启动Tomcat服务器,启动过程会自动将axis2.war解压缩,在Tomcat目录\webapps下生成axis2目录。3、客户端业务开发实例本节以向用户发送彩信的业务为例讲解客户端业务开发的实例,其他业务能力的业务开发实例请参见各业务实例代码文件夹中的_readme.txt。彩信发送业务:SP作为客户端调用ParlayXGW开放的SendMessage接口发送彩信。3.1由WSDL文件生成客户端代码使用到的WSDL文件包括:cuc_common_faults_2_0.wsdl,cuc_common_types_2_1.xsd,cuc_mm_send_interface_2_2.wsdl,cuc_mm_send_service_2_2.wsdl,cuc_mm_types_2_2.xsd在命令行下执行:WSDL2Java.bat-uricuc_mm_send_service_2_2.wsdl生成的代码在src目录下:[src]|-[cn\com\chinaunicom\]3.2在Eclipse中创建工程,将WSDL生成的代码中src文件夹下的cn目录复制到工程中3.3在工程中加入AXIS2的lib库选中工程cuc_mms,右击-选择Properties-在工程属性对话框左边选择“JavaBuildPath”,然后选择右边的“Libraries”属性页-点击“AddExternalJARs...”按钮,选择axis2-1.3目录\lib目录下所有的jar文件,加入到工程的Libraries中-OK3.4编写客户端代码,开发彩信发送业务3.4.1设置SOAPHeader新建类HeaderSetter,在HeaderSetter.java中编写代码:(完整代码见“cuc_mms\HeaderSetter.java”)publicclassHeaderSetter{protectedstaticfinalStringnameSpace==spId;protectedstaticfinalStringSOAPHEADER_spPassword=spPassword;//...(略)publicstaticvoidsetAOMTSoapHeader(ServiceClientserviceClient){//SOAPHeader字段赋值StringspId=41999;StringspPassword=41999;//...(略)try{//获取AXIOM的对象工厂OMFactoryfac=OMAbstractFactory.getOMFactory();SOAPFactorysfac=OMAbstractFactory.getSOAP11Factory();//创建名字空间NameSpaceOMNamespaceomNs=fac.createOMNamespace(nameSpace,tns);//创建RequestSOAPHeaderSOAPHeaderBlockblock_RequestSOAPHeader=sfac.createSOAPHeaderBlock(SOAPHEADER_RequestSOAPHeader,omNs);//设置spIdSOAPHeaderBlockblock_spId=sfac.createSOAPHeaderBlock(SOAPHEADER_spId,omNs);block_spId.addChild(sfac.createOMText(spId));//...(略)//将字段spId,spPassword,timeStamp,serviceId,...//作为RequestSOAPHeader的子节点block_RequestSOAPHeader.addChild(block_spId);block_RequestSOAPHeader.addChild(block_spPassword);block_RequestSOAPHeader.addChild(block_timeStamp);block_RequestSOAPHeader.addChild(block_serviceId);block_RequestSOAPHeader.addChild(block_SPNumber);block_RequestSOAPHeader.addChild(block_sessionId);block_RequestSOAPHeader.addChild(block_sessionEnd);block_RequestSOAPHeader.addChild(block_linkId);block_RequestSOAPHeader.addChild(block_OA);block_RequestSOAPHeader.addChild(block_FA);block_RequestSOAPHeader.addChild(block_groupMessaging);serviceClient.addHeader(block_RequestSOAPHeader);}catch(Exceptione){e.printStackTrace();}}//...(略)}3.4.2修改存根类SendMessageServiceStub的sendMessage方法,设置SOAP附件[cn\com\chinaunicom\]第168行://【增加org.apache.axiom.attachments.Attachmentsattachments参数用于发送附件】publiccn.com.chinaunicom.(cn.com.chinaunicom.)第203行:/**增加以下代码用于设置SOAP附件*//*****begin-设置SOAP附件的代码*****/if(attachments!=null){_operationClient.getOptions().setProperty(org.apache.axis2.Constants.Configuration.ENABLE_SWA,org.apache.axis2.Constants.VALUE_TRUE);_messageContext.setAttachmentMap(attachments);}/*****end-设置附件的代码*****/3.4.3调用SendMessage接口发送彩信新建类TestSendMms,在TestSendMms.java中编写代码:(完整代码见“cuc_mms\TestSendMms.java”)publicclassTestSendMms{publicstaticvoidmain(String[]args){try{/**MMS接口规范中定义的sendMessage接口参数:**DestinationAddressxsd:anyURI[0..unbounded]*SenderAddressxsd:anyURI*Subjectxsd:String*PriorityMessagePriority*ChargingCommon

1 / 14
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功