首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

wsdl 1.1轨范,wsdl 2.0规范,两者区别

2012-07-05 
wsdl 1.1规范,wsdl 2.0规范,两者区别wsdl 1.1 :wsdl 分为抽象定义部分和具体定义部分根为descriptiondefi

wsdl 1.1规范,wsdl 2.0规范,两者区别
wsdl 1.1 :
wsdl 分为抽象定义部分和具体定义部分
根为description

   <definitions>        <types> ... </types>        <message> ... </message>        <portType> ... </portType>        <binding> ... </binding>        <service> ... </serivce>     </definitions>  


其中,抽象定义部分为:
types:相当于定义数据的具体结构,包含complex type 和simple type(就是xsd当中对数据的定义)

message: 相当于每个方法的输入输出参数的定义(一个方法输入,输出各一个),message里面包含了0到多个<part>,part 相当于是具体的每个参数的定义,其中part的类型就是定义在<types>里面的。比如传入参数有两个,就相当于有一个message对应request,两个part分别对应于两个参数。

portType:一组operation的集合,porttype下面定义了operation(相当于一个个的具体方法)
operation里面又定义了input 和output,input, output分别和message一一对应

摘录:
WSDL消息交换模式(MEP)
  Messaging Exchange Patterns(MEP)
  Web服务中使用了四种消息交换模式,即请求/响应、单向、通知以及恳求/响应模式。大多数基于WSDL的web服务使用请求/响应和单向两种模式。
   WSDL通过operation元素的input/output来定义使用那种模式,如果有input+output+可选的fault参数,那就使用请求/响应模式;如果只使用input,那就使用单向模式。
   在通知模式中:Web服务将消息发送给客户,但不等待回复;一般客户通过注册来接收通知;在恳求/响应模式中类似通知模式,唯一的区别要期待客户对Web服务的响应。

下面是具体定义部分
bingding:将一个抽象的portType映射到一组具体的协议(SOAP或者HTTP)、消息传递样式(RPC或者document)以及编码样式(literal或者SOAP encoding)。

service:包含一到多个port,每个port是将一个binding和一个 具体地址关联

参考一个
<wsdl:definitions         targetNamespace="http://webservice.security.tempmodule.temp.com.cn"     xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding"     xmlns:tns="http://webservice.security.tempmodule.temp.com.cn"     xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"     xmlns:xsd="http://www.w3.org/2001/XMLSchema"     xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/"     xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/"     xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/"     xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"    >    <wsdl:types><xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://webservice.security.tempmodule.temp.com.cn"><xsd:element name="queryFunctionListByUser"><xsd:complexType><xsd:sequence><xsd:element maxOccurs="1" minOccurs="1" name="in0" nillable="true" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element><xsd:element name="queryFunctionListByUserResponse"><xsd:complexType><xsd:sequence><xsd:element maxOccurs="1" minOccurs="1" name="out" nillable="true" type="xsd:string"/></xsd:sequence></xsd:complexType></xsd:element></xsd:schema>    </wsdl:types>    <wsdl:message name="queryFunctionListByUserRequest">        <wsdl:part name="parameters" element="tns:queryFunctionListByUser"/>    </wsdl:message>    <wsdl:message name="queryFunctionListByUserResponse">        <wsdl:part name="parameters" element="tns:queryFunctionListByUserResponse"/>    </wsdl:message>    <wsdl:portType name="UserFunctionWebservicePortType">        <wsdl:operation name="queryFunctionListByUser">            <wsdl:input name="queryFunctionListByUserRequest" message="tns:queryFunctionListByUserRequest"/>            <wsdl:output name="queryFunctionListByUserResponse" message="tns:queryFunctionListByUserResponse"/>        </wsdl:operation>    </wsdl:portType>    <wsdl:binding name="UserFunctionWebserviceHttpBinding" type="tns:UserFunctionWebservicePortType">        <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>        <wsdl:operation name="queryFunctionListByUser">            <wsdlsoap:operation soapAction=""/>            <wsdl:input name="queryFunctionListByUserRequest">                <wsdlsoap:body use="literal"/>            </wsdl:input>            <wsdl:output name="queryFunctionListByUserResponse">                <wsdlsoap:body use="literal"/>            </wsdl:output>        </wsdl:operation>    </wsdl:binding>    <wsdl:service name="UserFunctionWebservice">        <wsdl:port name="UserFunctionWebserviceHttpPort" binding="tns:UserFunctionWebserviceHttpBinding">            <wsdlsoap:address location="http://127.0.0.1:7021/tempproject/webservice/UserFunctionWebservice"/>        </wsdl:port>    </wsdl:service></wsdl:definitions>


wsdl2.0 和1.1的主要区别:
    * 根元素为<description>,替代了1.1中的<definitions>
    * 去掉了<message>元素,在定义操作时直接引用XML Schema定义的元素。
    * 使用元素<interface>代替<portType>
    * 引入了接口的继承,可以像面向对象一样,通过继承现有的接口来定义新的接口
    * 使用元素<endpoint>代替了<port>元素
    * 每个<service>只能实现一个接口,但可以包含不同的实现,即可以包含多个<endpoint>元素,分别对应不同的地址和实现。


参考资料
http://blog.csdn.net/xys_777/article/details/6796966
http://xiongzhenhui.iteye.com/blog/998932
http://calvinliu.iteye.com/blog/1001192

热点排行