WSDL 理解

1 <?xml version="1.0" encoding="utf-8"?>
 2 <wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" 
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" 
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" 
    xmlns:tns="http://www.qianzhilan.com/webservice/atopg.wsdl" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:s="http://www.w3.org/2001/XMLSchema" 
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" 
    targetNamespace="http://www.qianzhilan.com/webservice/atopg.wsdl" 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
 3   <wsdl:types>
 4     <s:schema elementFormDefault="qualified" targetNamespace="http://www.qianzhilan.com/webservice/atopg.wsdl">
 5       <s:element name="add">
 6         <s:complexType>
 7           <s:sequence>
 8             <s:element minOccurs="1" maxOccurs="1" name="a" type="s:double" />    
 9             <s:element minOccurs="1" maxOccurs="1" name="b" type="s:double" />
10           </s:sequence>
11         </s:complexType>
12       </s:element>
13       <s:element name="addResponse">
14         <s:complexType>                             <!--复杂类型 --> 
15           <s:sequence>                              <!--元素出现的序列 --> 
16             <s:element minOccurs="1" maxOccurs="1" name="addResult" type="s:double" />   <!--type类型为s代表的命名空间下的double类型--> 
17           </s:sequence>
18         </s:complexType>
19       </s:element>
20     </s:schema>
21   </wsdl:types>
22   <wsdl:message name="addSoapIn">
23     <wsdl:part name="parameters" element="tns:add" />    <!--使用5-12行的add类型作为输入参数 --> 
24   </wsdl:message>
25   <wsdl:message name="addSoapOut">
26     <wsdl:part name="parameters" element="tns:addResponse" />   <!--使用13-19行的add类型作为输出参数 --> 
27   </wsdl:message>
28   <wsdl:portType name="myServiceSoap">
29     <wsdl:operation name="add">
30       <wsdl:input message="tns:addSoapIn" />        <!--使用22-24行的消息addSoapIn --> 
31       <wsdl:output message="tns:addSoapOut" />      <!--使用25-27行的消息addSoapOut --> 
32     </wsdl:operation>
33   </wsdl:portType>
34   <wsdl:binding name="myServiceSoap" type="tns:myServiceSoap">            <!--使用28-33的portType,portType:可以理解为一个函数库 --> 
35     <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />     <!--使用soap1.1服务命名空间下的传输协议http --> 
36     <wsdl:operation name="add">                                            <!--operation相当于函数库下的具体函数 --> 
37       <soap:operation soapAction="http://www.qianzhilan.com/webservice/atopg.wsdl/add" style="document" /> <!--指定soapAction为tns下的add(29-32)--> 
38       <wsdl:input>
39         <soap:body use="literal" />
40       </wsdl:input>
41       <wsdl:output>
42         <soap:body use="literal" />
43       </wsdl:output>
44     </wsdl:operation>
45   </wsdl:binding>
46   <wsdl:binding name="myServiceSoap12" type="tns:myServiceSoap">
47     <soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
48     <wsdl:operation name="add">
49       <soap12:operation soapAction="http://www.qianzhilan.com/webservice/atopg.wsdl/add" style="document" />
50       <wsdl:input>
51         <soap12:body use="literal" />
52       </wsdl:input>
53       <wsdl:output>
54         <soap12:body use="literal" />
55       </wsdl:output>
56     </wsdl:operation>
57   </wsdl:binding>
58   <wsdl:service name="myService">              <!--使用soap1.1服务的名字 -->  
59     <wsdl:port name="myServiceSoap" binding="tns:myServiceSoap">   <!--使用34-45的soap1.1服务绑定,接着转到34行--> 
60       <soap:address location="http://10.20.35.200:8006/AccessToPG.asmx" />
61     </wsdl:port>
62     <wsdl:port name="myServiceSoap12" binding="tns:myServiceSoap12">  <!--使用46-57的soap1.2服务绑定行--> 
63       <soap12:address location="http://10.20.35.200:8006/AccessToPG.asmx" />
64     </wsdl:port>
65   </wsdl:service>
66 </wsdl:definitions>
View Code

 

以上是一个用ASP .NET制作的一个Web Service的 wsdl文件。wsdl是对服务一个描述,那么下面就介绍下我个人对于它是如何描述wsdl进行一个说明。

一般情况下,对一个WSDL文件的理解是从上往下看的,为了便于理解,我从下往上进行解读,首先在58-65行之间是关于service的描述,

 

posted @ 2014-12-15 15:17  Xiaodigua  阅读(278)  评论(0编辑  收藏  举报