`
lvwenwen
  • 浏览: 930976 次
  • 性别: Icon_minigender_1
  • 来自: 魔都
社区版块
存档分类
最新评论

webservice wsdl文件详解

 
阅读更多

 

 WSDL:  Web Services Description Language  网页服务描述语言

 

详解WSDL文档元素:

文件是以XML格式定义的,内容分成了5大元素:

1、<types>:webservice使用的数据类型,它是独立以机器和语言的类型定义,这些数据类型被<message>标签所使用。

2、<message>:webservice使用的消息,它定义了webservice函数的参数。在webservice中输入参数和输出参数需要分开定义,使用不同的message标签体。message定义的输入输出参数,被<portType>标签使用。

3、<portType>:webservice执行操作。该标签引用<message>标签定义的函数来描述函数的签名(操作名、输入参数、输出参数)

4、<binding>:webservice通信协议。在portType中定义的每一项操作,都在此绑定中实现。

5、<service>:该标签定义每一绑定的端口地址。

 

WSDL文档可以分为两部分。顶部分由抽象定义组成,而底部分则由具体描述组成。抽象部分以独立于平台和语言的方式定义SOAP消息,它们并不包含任何随机器或语言而变的元素。这就定义了一系列服务,截然不同的应用都可以实现。具体部分,如数据的序列化则归入底部分,因为它包含具体的定义。在上述的文档元素中,<types>、<message>、<portType>属于抽象定义层,<binding>、<service>属于具体定义层。所有的抽象可以是单独存在于别的文件中,也可以从主文档中导入。

 

 

WSDL文档一个实例:

 

Xml代码  收藏代码
  1.  <?xml version="1.0" encoding="UTF-8" ?>  
  2. lt;wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"  
  3. xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://servicelifecycle.sample"  
  4. xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"  
  5. xmlns:ax21="http://bean.servicelifecycle.sample/xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"  
  6. xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"  
  7. xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://servicelifecycle.sample">  
  8. <wsdl:documentation>Library</wsdl:documentation>  
  9. <wsdl:types>  
  10.     <xs:schema xmlns:ax22="http://bean.servicelifecycle.sample/xsd"  
  11.         attributeFormDefault="qualified" elementFormDefault="qualified"  
  12.         targetNamespace="http://servicelifecycle.sample">  
  13.         <xs:import namespace="http://bean.servicelifecycle.sample/xsd" />  
  14.         <xs:element name="returnBook">  
  15.             <xs:complexType>  
  16.                 <xs:sequence>  
  17.                     <xs:element minOccurs="0" name="isbn" nillable="true"  
  18.                         type="xs:string" />  
  19.                 </xs:sequence>  
  20.             </xs:complexType>  
  21.         </xs:element>  
  22.         <xs:complexType name="Exception">  
  23.             <xs:sequence>  
  24.                 <xs:element minOccurs="0" name="Exception" nillable="true"  
  25.                     type="xs:anyType" />  
  26.             </xs:sequence>  
  27.         </xs:complexType>  
  28.         <xs:element name="register">  
  29.             <xs:complexType>  
  30.                 <xs:sequence>  
  31.                     <xs:element minOccurs="0" name="userName" nillable="true"  
  32.                         type="xs:string" />  
  33.                     <xs:element minOccurs="0" name="passWord" nillable="true"  
  34.                         type="xs:string" />  
  35.                 </xs:sequence>  
  36.             </xs:complexType>  
  37.         </xs:element>  
  38.         <xs:element name="registerResponse">  
  39.             <xs:complexType>  
  40.                 <xs:sequence>  
  41.                     <xs:element minOccurs="0" name="return" type="xs:boolean" />  
  42.                 </xs:sequence>  
  43.             </xs:complexType>  
  44.         </xs:element>  
  45.         <xs:element name="login">  
  46.             <xs:complexType>  
  47.                 <xs:sequence>  
  48.                     <xs:element minOccurs="0" name="userName" nillable="true"  
  49.                         type="xs:string" />  
  50.                     <xs:element minOccurs="0" name="passWord" nillable="true"  
  51.                         type="xs:string" />  
  52.                 </xs:sequence>  
  53.             </xs:complexType>  
  54.         </xs:element>  
  55.         <xs:element name="loginResponse">  
  56.             <xs:complexType>  
  57.                 <xs:sequence>  
  58.                     <xs:element minOccurs="0" name="return" type="xs:boolean" />  
  59.                 </xs:sequence>  
  60.             </xs:complexType>  
  61.         </xs:element>  
  62.         <xs:element name="listLendBookResponse">  
  63.             <xs:complexType>  
  64.                 <xs:sequence>  
  65.                     <xs:element maxOccurs="unbounded" minOccurs="0" name="return"  
  66.                         nillable="true" type="ax22:Book" />  
  67.                 </xs:sequence>  
  68.             </xs:complexType>  
  69.         </xs:element>  
  70.         <xs:element name="listAvailableBookResponse">  
  71.             <xs:complexType>  
  72.                 <xs:sequence>  
  73.                     <xs:element maxOccurs="unbounded" minOccurs="0" name="return"  
  74.                         nillable="true" type="ax22:Book" />  
  75.                 </xs:sequence>  
  76.             </xs:complexType>  
  77.         </xs:element>  
  78.         <xs:element name="listAllBookResponse">  
  79.             <xs:complexType>  
  80.                 <xs:sequence>  
  81.                     <xs:element maxOccurs="unbounded" minOccurs="0" name="return"  
  82.                         nillable="true" type="ax22:Book" />  
  83.                 </xs:sequence>  
  84.             </xs:complexType>  
  85.         </xs:element>  
  86.         <xs:element name="lendBook">  
  87.             <xs:complexType>  
  88.                 <xs:sequence>  
  89.                     <xs:element minOccurs="0" name="isbn" nillable="true"  
  90.                         type="xs:string" />  
  91.                     <xs:element minOccurs="0" name="userName" nillable="true"  
  92.                         type="xs:string" />  
  93.                 </xs:sequence>  
  94.             </xs:complexType>  
  95.         </xs:element>  
  96.         <xs:element name="lendBookResponse">  
  97.             <xs:complexType>  
  98.                 <xs:sequence>  
  99.                     <xs:element minOccurs="0" name="return" nillable="true"  
  100.                         type="ax22:Book" />  
  101.                 </xs:sequence>  
  102.             </xs:complexType>  
  103.         </xs:element>  
  104.     </xs:schema>  
  105.     <xs:schema attributeFormDefault="qualified"  
  106.         elementFormDefault="qualified" targetNamespace="http://bean.servicelifecycle.sample/xsd">  
  107.         <xs:complexType name="Book">  
  108.             <xs:sequence>  
  109.                 <xs:element minOccurs="0" name="author" nillable="true"  
  110.                     type="xs:string" />  
  111.                 <xs:element minOccurs="0" name="isbn" nillable="true"  
  112.                     type="xs:string" />  
  113.                 <xs:element minOccurs="0" name="title" nillable="true"  
  114.                     type="xs:string" />  
  115.             </xs:sequence>  
  116.         </xs:complexType>  
  117.     </xs:schema>  
  118. </wsdl:types>  
  119. <wsdl:message name="loginRequest">  
  120.     <wsdl:part name="parameters" element="ns:login" />  
  121. </wsdl:message>  
  122. <wsdl:message name="loginResponse">  
  123.     <wsdl:part name="parameters" element="ns:loginResponse" />  
  124. </wsdl:message>  
  125. <wsdl:message name="lendBookRequest">  
  126.     <wsdl:part name="parameters" element="ns:lendBook" />  
  127. </wsdl:message>  
  128. <wsdl:message name="lendBookResponse">  
  129.     <wsdl:part name="parameters" element="ns:lendBookResponse" />  
  130. </wsdl:message>  
  131. <wsdl:message name="listAllBookRequest" />  
  132. <wsdl:message name="listAllBookResponse">  
  133.     <wsdl:part name="parameters" element="ns:listAllBookResponse" />  
  134. </wsdl:message>  
  135. <wsdl:message name="listLendBookRequest" />  
  136. <wsdl:message name="listLendBookResponse">  
  137.     <wsdl:part name="parameters" element="ns:listLendBookResponse" />  
  138. </wsdl:message>  
  139. <wsdl:message name="returnBookRequest">  
  140.     <wsdl:part name="parameters" element="ns:returnBook" />  
  141. </wsdl:message>  
  142. <wsdl:message name="registerRequest">  
  143.     <wsdl:part name="parameters" element="ns:register" />  
  144. </wsdl:message>  
  145. <wsdl:message name="registerResponse">  
  146.     <wsdl:part name="parameters" element="ns:registerResponse" />  
  147. </wsdl:message>  
  148. <wsdl:message name="listAvailableBookRequest" />  
  149. <wsdl:message name="listAvailableBookResponse">  
  150.     <wsdl:part name="parameters" element="ns:listAvailableBookResponse" />  
  151. </wsdl:message>  
  152. <wsdl:portType name="LibraryPortType">  
  153.     <wsdl:operation name="login">  
  154.         <wsdl:input message="ns:loginRequest" wsaw:Action="urn:login" />  
  155.         <wsdl:output message="ns:loginResponse" wsaw:Action="urn:loginResponse" />  
  156.     </wsdl:operation>  
  157.     <wsdl:operation name="lendBook">  
  158.         <wsdl:input message="ns:lendBookRequest" wsaw:Action="urn:lendBook" />  
  159.         <wsdl:output message="ns:lendBookResponse" wsaw:Action="urn:lendBookResponse" />  
  160.     </wsdl:operation>  
  161.     <wsdl:operation name="listAllBook">  
  162.         <wsdl:input message="ns:listAllBookRequest" wsaw:Action="urn:listAllBook" />  
  163.         <wsdl:output message="ns:listAllBookResponse"  
  164.             wsaw:Action="urn:listAllBookResponse" />  
  165.     </wsdl:operation>  
  166.     <wsdl:operation name="listLendBook">  
  167.         <wsdl:input message="ns:listLendBookRequest" wsaw:Action="urn:listLendBook" />  
  168.         <wsdl:output message="ns:listLendBookResponse"  
  169.             wsaw:Action="urn:listLendBookResponse" />  
  170.     </wsdl:operation>  
  171.     <wsdl:operation name="returnBook">  
  172.         <wsdl:input message="ns:returnBookRequest" wsaw:Action="urn:returnBook" />  
  173.     </wsdl:operation>  
  174.     <wsdl:operation name="register">  
  175.         <wsdl:input message="ns:registerRequest" wsaw:Action="urn:register" />  
  176.         <wsdl:output message="ns:registerResponse" wsaw:Action="urn:registerResponse" />  
  177.     </wsdl:operation>  
  178.     <wsdl:operation name="listAvailableBook">  
  179.         <wsdl:input message="ns:listAvailableBookRequest"  
  180.             wsaw:Action="urn:listAvailableBook" />  
  181.         <wsdl:output message="ns:listAvailableBookResponse"  
  182.             wsaw:Action="urn:listAvailableBookResponse" />  
  183.     </wsdl:operation>  
  184. </wsdl:portType>  
  185. <wsdl:binding name="LibrarySoap11Binding" type="ns:LibraryPortType">  
  186.     <soap:binding transport="http://schemas.xmlsoap.org/soap/http"  
  187.         style="document" />  
  188.     <wsdl:operation name="login">  
  189.         <soap:operation soapAction="urn:login" style="document" />  
  190.         <wsdl:input>  
  191.             <soap:body use="literal" />  
  192.         </wsdl:input>  
  193.         <wsdl:output>  
  194.             <soap:body use="literal" />  
  195.         </wsdl:output>  
  196.     </wsdl:operation>  
  197.     <wsdl:operation name="lendBook">  
  198.         <soap:operation soapAction="urn:lendBook" style="document" />  
  199.         <wsdl:input>  
  200.             <soap:body use="literal" />  
  201.         </wsdl:input>  
  202.         <wsdl:output>  
  203.             <soap:body use="literal" />  
  204.         </wsdl:output>  
  205.     </wsdl:operation>  
  206.     <wsdl:operation name="register">  
  207.         <soap:operation soapAction="urn:register" style="document" />  
  208.         <wsdl:input>  
  209.             <soap:body use="literal" />  
  210.         </wsdl:input>  
  211.         <wsdl:output>  
  212.             <soap:body use="literal" />  
  213.         </wsdl:output>  
  214.     </wsdl:operation>  
  215.     <wsdl:operation name="listAllBook">  
  216.         <soap:operation soapAction="urn:listAllBook" style="document" />  
  217.         <wsdl:input>  
  218.             <soap:body use="literal" />  
  219.         </wsdl:input>  
  220.         <wsdl:output>  
  221.             <soap:body use="literal" />  
  222.         </wsdl:output>  
  223.     </wsdl:operation>  
  224.     <wsdl:operation name="returnBook">  
  225.         <soap:operation soapAction="urn:returnBook" style="document" />  
  226.         <wsdl:input>  
  227.             <soap:body use="literal" />  
  228.         </wsdl:input>  
  229.     </wsdl:operation>  
  230.     <wsdl:operation name="listLendBook">  
  231.         <soap:operation soapAction="urn:listLendBook" style="document" />  
  232.         <wsdl:input>  
  233.             <soap:body use="literal" />  
  234.         </wsdl:input>  
  235.         <wsdl:output>  
  236.             <soap:body use="literal" />  
  237.         </wsdl:output>  
  238.     </wsdl:operation>  
  239.     <wsdl:operation name="listAvailableBook">  
  240.         <soap:operation soapAction="urn:listAvailableBook"  
  241.             style="document" />  
  242.         <wsdl:input>  
  243.             <soap:body use="literal" />  
  244.         </wsdl:input>  
  245.         <wsdl:output>  
  246.             <soap:body use="literal" />  
  247.         </wsdl:output>  
  248.     </wsdl:operation>  
  249. </wsdl:binding>  
  250. <wsdl:binding name="LibrarySoap12Binding" type="ns:LibraryPortType">  
  251.     <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"  
  252.         style="document" />  
  253.     <wsdl:operation name="login">  
  254.         <soap12:operation soapAction="urn:login" style="document" />  
  255.         <wsdl:input>  
  256.             <soap12:body use="literal" />  
  257.         </wsdl:input>  
  258.         <wsdl:output>  
  259.             <soap12:body use="literal" />  
  260.         </wsdl:output>  
  261.     </wsdl:operation>  
  262.     <wsdl:operation name="lendBook">  
  263.         <soap12:operation soapAction="urn:lendBook" style="document" />  
  264.         <wsdl:input>  
  265.             <soap12:body use="literal" />  
  266.         </wsdl:input>  
  267.         <wsdl:output>  
  268.             <soap12:body use="literal" />  
  269.         </wsdl:output>  
  270.     </wsdl:operation>  
  271.     <wsdl:operation name="register">  
  272.         <soap12:operation soapAction="urn:register" style="document" />  
  273.         <wsdl:input>  
  274.             <soap12:body use="literal" />  
  275.         </wsdl:input>  
  276.         <wsdl:output>  
  277.             <soap12:body use="literal" />  
  278.         </wsdl:output>  
  279.     </wsdl:operation>  
  280.     <wsdl:operation name="listAllBook">  
  281.         <soap12:operation soapAction="urn:listAllBook"  
  282.             style="document" />  
  283.         <wsdl:input>  
  284.             <soap12:body use="literal" />  
  285.         </wsdl:input>  
  286.         <wsdl:output>  
  287.             <soap12:body use="literal" />  
  288.         </wsdl:output>  
  289.     </wsdl:operation>  
  290.     <wsdl:operation name="returnBook">  
  291.         <soap12:operation soapAction="urn:returnBook" style="document" />  
  292.         <wsdl:input>  
  293.             <soap12:body use="literal" />  
  294.         </wsdl:input>  
  295.     </wsdl:operation>  
  296.     <wsdl:operation name="listLendBook">  
  297.         <soap12:operation soapAction="urn:listLendBook"  
  298.             style="document" />  
  299.         <wsdl:input>  
  300.             <soap12:body use="literal" />  
  301.         </wsdl:input>  
  302.         <wsdl:output>  
  303.             <soap12:body use="literal" />  
  304.         </wsdl:output>  
  305.     </wsdl:operation>  
  306.     <wsdl:operation name="listAvailableBook">  
  307.         <soap12:operation soapAction="urn:listAvailableBook"  
  308.             style="document" />  
  309.         <wsdl:input>  
  310.             <soap12:body use="literal" />  
  311.         </wsdl:input>  
  312.         <wsdl:output>  
  313.             <soap12:body use="literal" />  
  314.         </wsdl:output>  
  315.     </wsdl:operation>  
  316. </wsdl:binding>  
  317. <wsdl:binding name="LibraryHttpBinding" type="ns:LibraryPortType">  
  318.     <http:binding verb="POST" />  
  319.     <wsdl:operation name="login">  
  320.         <http:operation location="Library/login" />  
  321.         <wsdl:input>  
  322.             <mime:content type="text/xml" part="login" />  
  323.         </wsdl:input>  
  324.         <wsdl:output>  
  325.             <mime:content type="text/xml" part="login" />  
  326.         </wsdl:output>  
  327.     </wsdl:operation>  
  328.     <wsdl:operation name="lendBook">  
  329.         <http:operation location="Library/lendBook" />  
  330.         <wsdl:input>  
  331.             <mime:content type="text/xml" part="lendBook" />  
  332.         </wsdl:input>  
  333.         <wsdl:output>  
  334.             <mime:content type="text/xml" part="lendBook" />  
  335.         </wsdl:output>  
  336.     </wsdl:operation>  
  337.     <wsdl:operation name="register">  
  338.         <http:operation location="Library/register" />  
  339.         <wsdl:input>  
  340.             <mime:content type="text/xml" part="register" />  
  341.         </wsdl:input>  
  342.         <wsdl:output>  
  343.             <mime:content type="text/xml" part="register" />  
  344.         </wsdl:output>  
  345.     </wsdl:operation>  
  346.     <wsdl:operation name="listAllBook">  
  347.         <http:operation location="Library/listAllBook" />  
  348.         <wsdl:input>  
  349.             <mime:content type="text/xml" part="listAllBook" />  
  350.         </wsdl:input>  
  351.         <wsdl:output>  
  352.             <mime:content type="text/xml" part="listAllBook" />  
  353.         </wsdl:output>  
  354.     </wsdl:operation>  
  355.     <wsdl:operation name="returnBook">  
  356.         <http:operation location="Library/returnBook" />  
  357.         <wsdl:input>  
  358.             <mime:content type="text/xml" part="returnBook" />  
  359.         </wsdl:input>  
  360.     </wsdl:operation>  
  361.     <wsdl:operation name="listLendBook">  
  362.         <http:operation location="Library/listLendBook" />  
  363.         <wsdl:input>  
  364.             <mime:content type="text/xml" part="listLendBook" />  
  365.         </wsdl:input>  
  366.         <wsdl:output>  
  367.             <mime:content type="text/xml" part="listLendBook" />  
  368.         </wsdl:output>  
  369.     </wsdl:operation>  
  370.     <wsdl:operation name="listAvailableBook">  
  371.         <http:operation location="Library/listAvailableBook" />  
  372.         <wsdl:input>  
  373.             <mime:content type="text/xml" part="listAvailableBook" />  
  374.         </wsdl:input>  
  375.         <wsdl:output>  
  376.             <mime:content type="text/xml" part="listAvailableBook" />  
  377.         </wsdl:output>  
  378.     </wsdl:operation>  
  379. </wsdl:binding>  
  380. <wsdl:service name="Library">  
  381.     <wsdl:port name="LibraryHttpSoap11Endpoint" binding="ns:LibrarySoap11Binding">  
  382.         <soap:address  
  383.             location="http://localhost:8088/axis2/services/Library.LibraryHttpSoap11Endpoint/" />  
  384.     </wsdl:port>  
  385.     <wsdl:port name="LibraryHttpSoap12Endpoint" binding="ns:LibrarySoap12Binding">  
  386.         <soap12:address  
  387.             location="http://localhost:8088/axis2/services/Library.LibraryHttpSoap12Endpoint/" />  
  388.     </wsdl:port>  
  389.     <wsdl:port name="LibraryHttpEndpoint" binding="ns:LibraryHttpBinding">  
  390.         <http:address  
  391.             location="http://localhost:8088/axis2/services/Library.LibraryHttpEndpoint/" />  
  392.     </wsdl:port>  
  393. </wsdl:service>  
  394. lt;/wsdl:definitions>  

 

 

理解这个WSDL文件结构可能要根据写的webservice程序结构来理解:


 

 

下面标红的地方都是元素之间引用的关系。

 

1.WSDL文档的根元素:

 

<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"

xmlns:ns1="http://org.apache.axis2/xsd"

xmlns:ns="http://servicelifecycle.sample"

xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"

xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"

xmlns:ax21="http://bean.servicelifecycle.sample/xsd"

xmlns:xs="http://www.w3.org/2001/XMLSchema"

xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"

xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"

xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"

targetNamespace="http://servicelifecycle.sample">

 

 

 

<definitions>定义了文档中用到的各个xml元素的namespace缩写,也界定了本文档自己的 targetNamespace="http://servicelifecycle.sample",这意味着其它的XML要引用当前XML中的元素时,要声明这个namespace。注意xmlns:ns="http://www.jsoso.com/wstest"这个声明,它标示了使用ns这个前缀指向自身的命名空间。

 

2.WSDL文档数据类型定义元素:<types>:

 

 

<wsdl:types>

<xs:schema xmlns:ax22="http://bean.servicelifecycle.sample/xsd"

attributeFormDefault="qualified" elementFormDefault="qualified"

targetNamespace="http://servicelifecycle.sample">

<xs:import namespace="http://bean.servicelifecycle.sample/xsd" />

<xs:element name="returnBook">

<xs:complexType>

<xs:sequence>

<xs:element minOccurs="0" name="isbn" nillable="true"

type="xs:string" />

</xs:sequence>

</xs:complexType>

</xs:element>

<xs:element name="login"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="userName" nillable="true" type="xs:string" /> <xs:element minOccurs="0" name="passWord" nillable="true" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="loginResponse"> <xs:complexType> <xs:sequence> <xs:element minOccurs="0" name="return" type="xs:boolean" /> </xs:sequence> </xs:complexType> </xs:element>

 

这里定义webservice的一个元素名称returnBook,就是service的一个函数名称(见图),定义了混合类型数据类型,类型是string类型,名称叫isbn

 

3.WSDL文档消息体定义元素:< message >:

 

 

<wsdl:message name="loginRequest">

<wsdl:part name="parameters" element="ns:login" />

</wsdl:message>

<wsdl:message name="loginResponse">

<wsdl:part name="parameters" element="ns:loginResponse" />

</wsdl:message>

 

 

这里定义定义了消息请求,这里定义使用的消息是loginRequest和loginResponse,它分别引用了types中的login和loginResponse元素。在types中的login和loginResponse元素定义好了参数类型。有没有Response消息,主要是看你的函数是否有返回值,如果是void,想returnBook这函数就没有returnBookResponse。

 

4.WSDL文档操作定义元素:< portType >

 

 

<wsdl:portType name="LibraryPortType">

<wsdl:operation name="login">

<wsdl:input message="ns:loginRequest" wsaw:Action="urn:login" />

<wsdl:output message="ns:loginResponse" wsaw:Action="urn:loginResponse" />

</wsdl:operation>

 

定义了操作名称login,输入使用的消息是loginRequest,Action是urn:login,输出ns:loginResponse,Action是:urn:loginResponse

 

 

5、WSDL文档操作绑定协议<binding>:

 

<wsdl:binding name="LibrarySoap11Binding" type="ns:LibraryPortType"> <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" /> <wsdl:operation name="login"> <soap:operation soapAction="urn:login" style="document" /> <wsdl:input> <soap:body use="literal" /> </wsdl:input> <wsdl:output> <soap:body use="literal" /> </wsdl:output> </wsdl:operation>

 

首先<binding>标签使用<soap:binding>的transport和style属性定义了Web Service的通讯协议HTTP和SOAP的请求风格RPC。其次<operation>子标签将portType中定义的 operation同SOAP的请求绑定,定义了操作名称soapAction,输出输入参数和异常的编码方式及命名空间。 

如果客户端要调用这方法就要声明是这soapAction名称urn:login。

 

6、WSDL文档绑定服务端口地址<service>:

 

<wsdl:service name="Library"> <wsdl:port name="LibraryHttpSoap11Endpoint" binding="ns:LibrarySoap11Binding"> <soap:address location="http://localhost:8088/axis2/services/Library.LibraryHttpSoap11Endpoint/" /> </wsdl:port> <wsdl:port name="LibraryHttpSoap12Endpoint" binding="ns:LibrarySoap12Binding"> <soap12:address location="http://localhost:8088/axis2/services/Library.LibraryHttpSoap12Endpoint/" /> </wsdl:port> <wsdl:port name="LibraryHttpEndpoint" binding="ns:LibraryHttpBinding"> <http:address location="http://localhost:8088/axis2/services/Library.LibraryHttpEndpoint/" /> </wsdl:port> </wsdl:service>

 

这里描述webservice的服务名称是Libraryservice是一套<port>元素。在一一对应形式下,每个<port>元素都和一个location关联。如果同一个<binding>有多个<port>元素与之关联,可以使用额外的URL地址作为替换。 


一个WSDL文档中可以有多个<service>元素,而且多个<service>元素十分有用,其中之一就是可以根据目标URL来组织端口。在一个 WSDL文档中,<service>的name属性用来区分不同的service。在同一个service中,不同端口,使用端口的"name"属性区分。 

转自:http://zengjz88.iteye.com/blog/1668725

http://tenn.iteye.com/blog/148384

http://askcuix.iteye.com/blog/212051

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics