日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【转】WebServices:WSDL的结构分析

發布時間:2023/12/10 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【转】WebServices:WSDL的结构分析 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

????? WSDL(Web Services Description Language,Web服務描述語言)是為描述Web Services發布的XML格式。W3C組織沒有批準1.1版的WSDL,但是2.0版本已經在製訂中,2.0版將被作為推薦標準(recommendation)(一種官方標準),并將被W3C組織批準為正式標準。WSDL描述Web服務的公共接口。這是一個基于XML的關于如何與Web服務通訊和使用的服務描述;也就是描述與目錄中列出的Web服務進行交互時需要綁定的協議和信息格式。通常采用抽象語言描述該服務支持的操作和信息,使用的時候再將實際的網絡協議和信息格式綁定給該服務。

????? WSDL 文檔僅僅是一個簡單的 XML 文檔。它包含一系列描述某個 web service 的定義。

????? WebMthod的定義:

1: [WebService(Namespace = "http://tempuri.org/")] 2: [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 3: [System.ComponentModel.ToolboxItem(false)] 4: public class WebService2 : System.Web.Services.WebService 5: { 6: [WebMethod] 7: public bool Add(TestClass testClass,int id) 8: { 9: return true; 10: } 11: } 12: ? 13: public class TestClass 14: { 15: public int a; 16: public string b; 17: public DateTime c; 18: } 19: ?

?????? WSDL的結構:

?????? 一個WSDL文檔通常包含有以下元素,即types、message、portType、operation、binding、 service元素。這些元素嵌套在definitions元素中。

??????definitions是WSDL文檔的根元素,definitions還聲明各命名空間。

??????types,數據類型定義的容器,它使用某種類型系統(一般地使用XML Schema中的類型系統)。

1: <wsdl:types> 2: <s:schema elementFormDefault="qualified" targetNamespace="http://tempuri.org/"> 3: <s:element name="Add"> 4: <s:complexType> 5: <s:sequence> 6: <s:element minOccurs="0" maxOccurs="1" name="testClass" type="tns:TestClass" /> 7: <s:element minOccurs="1" maxOccurs="1" name="id" type="s:int" /> 8: </s:sequence> 9: </s:complexType> 10: </s:element> 11: <s:complexType name="TestClass"> 12: <s:sequence> 13: <s:element minOccurs="1" maxOccurs="1" name="a" type="s:int" /> 14: <s:element minOccurs="0" maxOccurs="1" name="b" type="s:string" /> 15: <s:element minOccurs="1" maxOccurs="1" name="c" type="s:dateTime" /> 16: </s:sequence> 17: </s:complexType> 18: <s:element name="AddResponse"> 19: <s:complexType> 20: <s:sequence> 21: <s:element minOccurs="1" maxOccurs="1" name="AddResult" type="s:boolean" /> 22: </s:sequence> 23: </s:complexType> 24: </s:element> 25: </s:schema> 26: </wsdl:types>

???? types描述WebMethod的名稱(Add),傳入參數(testClass——包括對TestClass的詳細描述,id),響應信息(AddResponse)。

?????message描述通信消息的數據結構的抽象類型化定義,使用types的描述的類型來定義整個消息的數據結構。

1: <wsdl:message name="AddSoapIn"> 2: <wsdl:part name="parameters" element="tns:Add" /> 3: </wsdl:message> 4: <wsdl:message name="AddSoapOut"> 5: <wsdl:part name="parameters" element="tns:AddResponse" /> 6: </wsdl:message>

??????portTypeoperation描述服務和服務的方法。operation包括輸入和輸出(使用message的描述)。

1: <wsdl:portType name="WebService2Soap"> 2: <wsdl:operation name="Add"> 3: <wsdl:input message="tns:AddSoapIn" /> 4: <wsdl:output message="tns:AddSoapOut" /> 5: </wsdl:operation> 6: </wsdl:portType>

???????binding描述Web Services的通信協議。 <soap:binding/>描述使用SOAP協議,binding還描述Web Services的方法、輸入、輸出。

1: <wsdl:binding name="WebService2Soap" type="tns:WebService2Soap"> 2: <soap:binding transport="http://schemas.xmlsoap.org/soap/http" /> 3: <wsdl:operation name="Add"> 4: <soap:operation soapAction="http://tempuri.org/Add" style="document" /> 5: <wsdl:input> 6: <soap:body use="literal" /> 7: </wsdl:input> 8: <wsdl:output> 9: <soap:body use="literal" /> 10: </wsdl:output> 11: </wsdl:operation> 12: </wsdl:binding>

???????service描述Web Services訪問點的集合。因為包括SOAP1.1和SOAP1.2的描述,所以一個方法有對應兩描述。

1: <wsdl:service name="WebService2"> 2: <wsdl:port name="WebService2Soap" binding="tns:WebService2Soap"> 3: <soap:address location="http://localhost:1552/WebService2.asmx" /> 4: </wsdl:port> 5: <wsdl:port name="WebService2Soap12" binding="tns:WebService2Soap12"> 6: <soap12:address location="http://localhost:1552/WebService2.asmx" /> 7: </wsdl:port> 8: </wsdl:service>

總結

以上是生活随笔為你收集整理的【转】WebServices:WSDL的结构分析的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。