【申明:此代码已经经过测试可以正确使用;但内容解释为个人见解,如有不准确之处,请指教。
阅读前请先仔细阅读“【】”中的说明文字,以免与您的需求不符而浪费时间。】
【前提:对方给了一个wsdl文件,用axis根据此wsdl文件,写一个访问其webservice接口的方法。其中还知道
了对方报文实体(RequestBody)和回复实体(ResponseBody:也就是wsdl的返回对象实体)
流程:我方通过webservice接口(http://14.2.33.94:9103/BSBOPM/services/OPMgetMDSData)向对方发
送报文 ---> 对方收到后,再给我方一个回复。】
【开发环境:MyEclipse6.5; web项目】
【语言: java、axis1】
【接口属性:参数类型:对象(RequestBody);返回类型:对象(ResponseBody)】
步骤:
1.首先引用相关jar包:
axis-ant.jar、axis.jar、commons-discovery-0.2.jar、wsdl4j-1.5.1.jar、httpclient-4.2.1.jar、httpcore-4.2.2.jar。(httpclient-4.2.1.jar、httpcore-4.2.2.jar 这个不确定是否用过,之所以引用了这两个包,是在另一个功能中使用HttpPost进行webservice回复功能。建议:可先不需要引这两个包)。
2.查看wsdl文件:
注:此是已经发布成功的wsdl文件,而非其源码(.wsdd)文件。
<?xml verson="1.0">
<wsdl:definitions targetNamespace="http://service.axis.com/da/"
xmlns:apachesoap="http://xml.apache.org/xml-soap"
xmlns:impl="http://service.axis.com/da/"
xmlns:intf="http://ervice.axis.com/da/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
.....>
<wsdl:types>
<schema targetNamespace="http://service.axis.com/da/"
xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
<complexType name="MessageBody">
<sequence>
<element name="jobStatus" nillable="true" type="xsd:string" />
<element name="jobTicket" nillable="true" type="xsd:string" />
<element name="sendTime" nillable="true" type="xsd:string" />
<element name="systemDate" nillable="true" type="xsd:string" />
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="MessageHandlerRequest">
<wsdl:part name="requestBody" type="impl:MessageBody">
</wsdl:message>
<wsdl:message name="MessageHandlerRespnse">
<wsdl:part