WSDL文档结构

WSDL(Web Service Description Language)是一种用于描述Web Service的XML。其文档结构如下:
 
Definition
根元素
 
Types
数据类型定义,提供了用于描述交换消息的数据类型定义,它使用某种类型系统(一般使用XML Schema中的类型,即XSD)
 
Message
消息数据结构的抽象类型化定义,消息包括多个逻辑部分,每一部分与某种类型系统中的一个定义相关。消息使用Types所定义的类型来定义整个消息的数据结构。
 
Operation
对服务中所支持的操作的抽象描述。一般来说,单个Operation描述了一个访问入口的请求/响应消息对。
 
 
PortType
某个访问入口点类型所支持的操作的抽象集合,这些操作可以由一个或多个服务访问点来支持,每个操作指向一个输入消息和多个输出消息。
 
Binding
特定的端口类型的具体协议和数据格式规范的邦定,它是由端口类型定义的操作和消息制定具体的协议和数据格式规范的结合。
 
Port
协议/数据格式绑定与具体Web访问地址组合的单个服务访问点,它指出了用于绑定的地址,因此定义了单个通信终端。
 
Service
相关服务访问点的集合,它集成了一组相关的端口。
 
其中:
Types,Message,Operation,PortType描述了调用Web Service的抽象定义;
Binding,Port,Service是服务的具体定义
 
来个简单的例子
<?xml version="1.0">
<definition name="StockQuote"
targetNamespace="http://xxx/stockquote.wsdl"
XMLns:wsdl="http://xxx/soap">
 
<types>
<Schema targetNamespace="http://xxxx/stockquote.xsd">
<element name="PriceReuest">
<complexType>
<all>
<element name="tickerSymbol" type="string"/>
</all>
<complexType>
</element>
<element name="PriceResult">
<complexType>
<all>
<element name="price" type="float"/>
</all>
<complexType>
</element>
</Schema>
</types>
 
<message name="GetLastPriceInput">
<part name="body" element="xsdl:PriceRequest">
</message>
<message name="GetLastPriceOutput">
<part name="body" element="xsdl:PriceResult">
</message>
 
<portType name="StockQuotePortType">
<operation name="GetLastPrice">
<input message="tns:GetLastPriceInput"/>
<output message="tns:GetLastPriceOutput"/>
</operation>
</portType>
 
<!--以上是服务的抽象定义部分,以下为具体定义部分-->
 
<binding name="StockQuoteSoapBinding"
type="tns:StockQuotePortType">
<soap:binding style="document"
tansport="http://Schema.XMLsoap.org/http">
<operation name="GetLastPrice">
<soap:operation soapAction="http://x/GetLastPrice">
<input>
<soap:body use="literal"
namespace="http://x/stockqute.xsd"
encodingStype="http://x/encoding"/>
</input>
<output>
<soap:body use="literal"
namespace="http://x/stockqute.xsd"
encodingStype="http://x/encoding"/>
</output>
</soap:operation>
</operation>
</soap:binding>
</binding>
 
<service name="StockQuoteService">
<documentation></documentation>
<port name="StockQuotePort" binding="tns:StockQuoteBinding">
<soap:address location="http://x/stockqute"/>
</port>
</service>
 
</definition>
原文地址:https://www.cnblogs.com/lvfeilong/p/fd.html