webservice--wsdl说明书
WSDL文档的结构实例解析
<?xml version="1.0" encoding="UTF-8"?> <definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://www.jsoso.com/wstest" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://www.jsoso.com/wstest" name="Example">
<definitions>定义了文档中用到的各个xml元素的namespace缩写,也界定了本文档自己的targetNamespace="http://www.jsoso.com/wstest",这意味着其它的XML要引用当前XML中的元素时,要声明这个namespace。注意xmlns:tns="http://www.jsoso.com/wstest"这个声明,它标示了使用tns这个前缀指向自身的命名空间 <types> <xsd:schema> <xsd:import namespace="http://www.jsoso.com/wstest" schemaLocation="http://localhost:8080/hello?xsd=1"></xsd:import> </xsd:schema> </types>
<types>数据类型定义,为了最大程度的平台中立性,WSDL 使用 XML Schema 语法来定义数据类型, schemaLocation="http://localhost:8080/hello?xsd=1"是我们自定义的Java对象类型,点击这个链接,可以看到接口的具体内容,和对象的具体内容 <message name="toSayHello"> <part name="userName" type="xsd:string"></part> </message>
<message>定义了函数的参数,每个<part>子元素都和某个参数相符,
<portType name="Example"> <operation name="toSayHello" parameterOrder="userName"> </operation> </portType>
<portType>描述一个 web service、可被执行的操作,以及相关的消息,name属性对应Java中的一个服务类的类名
<operation>描述一个web service的服务方法,name属性表示服务方法名,parameterOrder属性表示方法的参数顺序,使用空格符分割多个参数, <binding name="ExamplePortBinding" type="tns:Example"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"></soap:binding> <operation name="toSayHello"> <soap:operation soapAction="sayHello"></soap:operation> <input> <soap:body use="literal" namespace="http://www.jsoso.com/wstest"></soap:body> </input> <output> <soap:body use="literal" namespace="http://www.jsoso.com/wstest"></soap:body> </output> </operation> </binding>
<binding>描述协议、序列化和编码的地方,
<soap:binding>的transport和style属性定义了Web Service的通讯协议HTTP和SOAP的请求风格RPC。
<operation>子标签将portType中定义的operation同SOAP的请求绑定,定义了操作名称soapAction,输出输入参数和异常的编码方式及命名空间。
<service name="Example"> <port name="ExamplePort" binding="tns:ExamplePortBinding"> <soap:address location="http://localhost:8080/hello"></soap:address> </port> </service>
</service> 即服务视图,name属性用来区分不同的service
</definitions>
如何阅读wsdl与客户端程序对应?
1.先找到service标签,在找到binding属性
2.找到binding标签,在找到type属性
3.找到portType标签,可以看到发布的服务方法
祝:
大家生活愉快,工作顺利