1.WSDL執行個體

執行個體解釋
<?xml version='1.0' encoding='UTF-8'?>
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="http://ws.day01_ws.atguigu.com/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
name="HelloWSImplService"
targetNamespace="http://ws.day01_ws.atguigu.com/">
<!--
types
schema : 定義了一些标簽結構
-->
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://ws.day01_ws.atguigu.com/" elementFormDefault="unqualified"
targetNamespace="http://ws.day01_ws.atguigu.com/" version="1.0">
<!--
//用于請求
<sayHello>
<arg0>string</arg0>
</sayHello>
<q0:sayHello>
<arg0>BB</arg0>
</q0:sayHello>
//用于響應
<sayHelloResponse>
<return>string</return>
</sayHelloResponse>
<ns2:sayHelloResponse">
<return>Hello BB</return>
</ns2:sayHelloResponse>
-->
<xs:element name="sayHello" type="tns:sayHello" />
<xs:element name="sayHelloResponse" type="tns:sayHelloResponse" />
<xs:complexType name="sayHello">
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:complexType name="sayHelloResponse">
<xs:sequence>
<xs:element minOccurs="0" name="return" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
<!--
message: 用來定義消息的結構 soap消息
part : 指定引用types中定義的标簽片斷
-->
<wsdl:message name="sayHelloResponse">
<wsdl:part element="tns:sayHelloResponse" name="parameters">
</wsdl:part>
</wsdl:message>
<wsdl:message name="sayHello">
<wsdl:part element="tns:sayHello" name="parameters">
</wsdl:part>
</wsdl:message>
<!--
portType: 用來定義伺服器端的SEI
operation : 用來指定SEI中的處理請求的方法
input : 指定用戶端應用傳過來的資料, 會引用上面的定義的<message>
output : 指定伺服器端傳回給用戶端的資料, 會引用上面的定義的<message>
-->
<wsdl:portType name="HelloWS">
<wsdl:operation name="sayHello">
<wsdl:input message="tns:sayHello" name="sayHello">
</wsdl:input>
<wsdl:output message="tns:sayHelloResponse" name="sayHelloResponse">
</wsdl:output>
</wsdl:operation>
</wsdl:portType>
<!--
binding : 用于定義SEI的實作類
type屬性: 引用上面的<portType>
<soap:binding style="document"> : 綁定的資料是一個document(xml)
operation : 用來定義實作的方法
<soap:operation style="document" /> 傳輸的是document(xml)
input: 指定用戶端應用傳過來的資料
<soap:body use="literal" /> : 文本資料
output : 指定伺服器端傳回給用戶端的資料
<soap:body use="literal" /> : 文本資料
-->
<wsdl:binding name="HelloWSImplServiceSoapBinding" type="tns:HelloWS">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="sayHello">
<soap:operation soapAction="" style="document" />
<wsdl:input name="sayHello">
<soap:body use="literal" />
</wsdl:input>
<wsdl:output name="sayHelloResponse">
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<!--
service : 一個webservice的容器
name屬性: 它用一指定用戶端容器類
port : 用來指定一個伺服器端處理請求的入口(就SEI的實作)
binding屬性: 引用上面定義的<binding>
address : 目前webservice的請求位址
-->
<wsdl:service name="HelloWSImplService">
<wsdl:port binding="tns:HelloWSImplServiceSoapBinding" name="HelloWSImplPort">
<soap:address location="http://192.168.10.165:8888/day01_ws/hellows" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
2.WSDL文檔結構
<definitions> <types> <schema>定義限制條件 <element> </types> <message>消息(請求消息和響應消息) <part> </message> <portType> <operation> <input> <output> </portType> <binding> <operation> <input> <output> </binding> <service> <port> <address> </service> </definitions> |
3.消息格式
4元素
WSDL 元素基于XML文法描述了與服務進行互動的基本元素:
(1)Type(消息類型):資料類型定義的容器,它使用某種類型系統(如 XSD)。
(2)Message(消息):通信資料的抽象類型化定義,它由一個或者多個 part 組成。用來定義消息的結構
(3)Part:消息參數,用來指定tyes中定義的片段
(4)Operation(操作):對服務所支援的操作進行抽象描述
WSDL定義了四種操作:
1.單向(one-way):端點接受資訊;
2.請求-響應(request-response):端點接受消息,然後發送相關消息;
3.要求-響應(solicit-response):端點發送消息,然後接受相關消息;
4.通知(notification[2] ):端點發送消息。
(5)Port Type(端口類型):特定端口類型的具體協定和資料格式規範。
(6)Binding:特定端口類型的具體協定和資料格式規範。
(7)Port:定義為綁定和網絡位址組合的單個端點。
(8)Service:相關端口的集合,包括其關聯的接口、操作、消息等。