如何根据wsdl文件调用web service?

whulph 2004-10-28 10:48:01
如果服务部署用Axis部署的话,在客户端可以用axis的api调用服务。但是很多时候要调用其它人提供的web service,关于该web service的信息就只有wsdl,这时是否可以直接构造soap消息来调用该web service呢?
比如下面的wsdl,它的输入参数类型是tns1:Order,不是简单类型,我如何调用这个web service呢?(我并不知道该wsdl文件中的tns1:Order类型是对应自定义的bean,因此无法用axis的api来进行类型映射beanMapping Registry)
<?xml version="1.0" encoding="UTF-8" ?>
- <wsdl:definitions targetNamespace="http://localhost:8080/axis/services/OrderProcessor" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://localhost:8080/axis/services/OrderProcessor" xmlns:intf="http://localhost:8080/axis/services/OrderProcessor" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="urn:BeanService" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <wsdl:types>
- <schema targetNamespace="http://localhost:8080/axis/services/OrderProcessor" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="ArrayOf_xsd_string">
- <complexContent>
- <restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]" />
</restriction>
</complexContent>
</complexType>
- <complexType name="ArrayOf_xsd_int">
- <complexContent>
- <restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:int[]" />
</restriction>
</complexContent>
</complexType>
</schema>
- <schema targetNamespace="urn:BeanService" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/" />
- <complexType name="Order">
- <sequence>
<element name="customerName" nillable="true" type="xsd:string" />
<element name="itemCodes" nillable="true" type="impl:ArrayOf_xsd_string" />
<element name="quantities" nillable="true" type="impl:ArrayOf_xsd_int" />
<element name="shippingAddress" nillable="true" type="xsd:string" />
</sequence>
</complexType>
</schema>
</wsdl:types>
- <wsdl:message name="processOrderRequest">
<wsdl:part name="order" type="tns1:Order" />
</wsdl:message>
- <wsdl:message name="processOrderResponse">
<wsdl:part name="processOrderReturn" type="xsd:string" />
</wsdl:message>
- <wsdl:portType name="BeanService">
- <wsdl:operation name="processOrder" parameterOrder="order">
<wsdl:input message="impl:processOrderRequest" name="processOrderRequest" />
<wsdl:output message="impl:processOrderResponse" name="processOrderResponse" />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name="OrderProcessorSoapBinding" type="impl:BeanService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />
- <wsdl:operation name="processOrder">
<wsdlsoap:operation soapAction="" />
- <wsdl:input name="processOrderRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://example5.userguide.samples" use="encoded" />
</wsdl:input>
- <wsdl:output name="processOrderResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://localhost:8080/axis/services/OrderProcessor" use="encoded" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name="BeanServiceService">
- <wsdl:port binding="impl:OrderProcessorSoapBinding" name="OrderProcessor">
<wsdlsoap:address location="http://localhost:8080/axis/services/OrderProcessor" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
...全文
333 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
redez 2004-10-31
  • 打赏
  • 举报
回复
学习
dosig 2004-10-30
  • 打赏
  • 举报
回复
用wsdl文件生产对应的java文件,然后就可以调用了

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧