面向服務架構-第7章 服務描述-WSDL 第4講_第1頁
面向服務架構-第7章 服務描述-WSDL 第4講_第2頁
面向服務架構-第7章 服務描述-WSDL 第4講_第3頁
面向服務架構-第7章 服務描述-WSDL 第4講_第4頁
面向服務架構-第7章 服務描述-WSDL 第4講_第5頁
已閱讀5頁,還剩52頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

面向效勞架構第7章效勞描述—WSDLServicesDescription:WSDLWeb效勞描述語言WSDL〔WebServicesDescriptionLanguage〕是一個推薦標準。用于描述Web效勞的技術調用語法。1999年HP〔惠普〕公司是第一個引入Web效勞概念,eSpeak實現了“電子效勞〞平臺。2000年6月Microsoft提出了“Web效勞〞術語,把Web效勞作為.NET方案重要組件。在Microsoft的SDL〔ServiceDescriptionLanguage和SCL〔SOAPContractLanguage〕和IBM的NASSL〔NetworkAccessibleServiceSpecificationLanguage〕這兩項技術的結合,形成了WSDL的根底。SCL采用XML來描述應用程序所交換的消息,NASSL描述效勞接口和實現細節。2000年9月25日IBM、Microsoft和Ariba提出WSDL1.0。2001年3月15日,他們提交的WSDL1.1成為W3C的Note。2002年7月9日提出WSDL1.2,2003年11月10日提出WSDL2.0,WSDL2.0在2007年6月26日成為W3C正式推薦標準。開展歷史WSDL描述web效勞的三個根本屬性:效勞做些什么?效勞所提供的操作(方法);如何訪問效勞?數據格式以及訪問效勞操作的必要協議;效勞位于何處?由特定協議決定的網絡地址,如URL。WebService接口消息格式約定訪問地址根本屬性告訴效勞的使用者如何將請求消息格式化,通過何種通信協議在何處訪問webservice。WSDL的本質面向效勞視圖標準描述資源與協議變換實現自動效勞部署和調用ContentJAVA2WSDLWSDL2JAVAUDDI資源效勞運行時客戶端〔人〕客戶端〔機器〕發布發現與定位發現與定位操作瀏覽器AJAX實現Web效勞體系結構的松散耦合;無論是請求者還是提供者可以各自獨立地使用平臺、編程語言或分布式對象模型。與IDL的不同:在描述webservice接口的同時,還要定義訪問webservice的機制;需要定義webservice的有效訪問位置,因為在開放的計算環境下,沒有一個公共模塊提供效勞的訪問地址。WSDL特點協議、消息格式WSDL是XML描述的網絡效勞,基于消息機制、包含面向文本或面向過程信息的操作集合操作及消息的抽象定義與它們具體的網絡實現和數據格式綁定是別離的,這樣就可以重用這些抽象定義WSDL文檔框架OperationPortTypeMessageBindingPortServiceSupportsInput&OutputProvidesHowtoencodeFormats&ProtocolsHowtoinvokeImplementsInterfaceAccess

specificationEndpointsWSDL的組成WSDL概念模型return1return1<definitionsnamespace=“://…〞> <types>XMLschematypes</type> <message>definitionofamessage</message> <portType>asetofoperations</portType> <binding>communicationprotocols</binding> <service>alistofbindingandports</service></definitions>WSDL的結構方法名輸入參數1參數2參數x輸出類型類型定義類型定義消息消息操作Echo.java源代碼效勞接口組成了效勞描述中的可重用局部,包括type元素、message和portType。types元素中描述消息中復雜數據類型的使用。message元素指定XML數據類型組成消息的各個局部。操作的輸入或輸出〔參數〕被定義為message元素。Operation元素定義了輸入和輸出數據流中可以出現的XML消息,作為Web效勞交互根本傳輸單元。portType元素中定義了Web效勞的操作,與傳統中間件IDL的接口相似。效勞接口定義Seeconceptmodel效勞實現定義是一個描述給定效勞提供者如何實現特定效勞接口的WSDL文檔。有binding和services。binding元素描述特定效勞接口在作為負載傳輸時的消息傳輸協議(如SOAP)、網絡傳輸協議(如Http)、消息風格(如SOAP/RPCorSOAP/Document)和消息的編碼規那么(如SOAP或literal)Port與binding一一對應,以URI的形式描述了綁定對應的端口類型的Internet訪問地址。service元素。效勞元素包含一組port元素,將port邏輯分組,如同一訪問地址的port可以歸為一組,或一個端口類型對應的多個綁定歸為一組。效勞實現定義Seeconceptmodelwsdl soap

mime soapenc soapenv xsi xsd 名稱空間types元素包含了交換消息的數據類型定義。為了實現最大的互操作性〔interoperability〕和平臺中立性〔neutrality〕,WSDL選用XMLSchemaDataTypes,簡稱XSD作為標準類型系統,并將它作為固有類型系統。<definitions....><types><xsd:schema..../>*</types></definitions>1.類型使用元素〔element〕形式,而不使用屬性(attribute)形式;不包括僅在特殊的協議和數據格式中使用的元素或者屬性;數組類型使用Soap:Array類型,并使用ArrayOfXXX作為數組類型的名;使用XSD編碼表示xsd:anyType。類型—XSD編碼抽象數據類型建議<types><schema……>

<elementname="PO"type="tns:POType"/>

<complexTypename="POType">

<elementname="id"type="string"/>

<elementname="name"type="string"/>

<elementname="items">

<complexType>

<elementname="item"type="tns:Item"minOccurs="0"maxOccurs="unbounded"/>

</complexType>

</element>

</complexType>

<complexTypename="Item">

<elementname="quantity"type="int"/>

<elementname="product"type="string"/>

</complexType>

<elementname="Customer"type="tns:CustomerType"/>

<complexTypename="CustomerType">

<elementname="name"type="string"/>

</complexType>

</schema></types>消息由假設干個邏輯部件〔part〕構成。每個部件使用一個消息類型屬性與某個類型系統的類型相關聯。消息定義語法如下:<definitions....><messagename="nmtoken">*<partname="nmtoken"element="qname"?type="qname"?/>*</message></definitions>消息(message)name屬性指定了消息的名稱。如果消息具有多個邏輯單位,那么需要使用多個part元素。2.消息<messagename="PO"><partname="po"element="tns:PO"/><partname="customer"element="tns:Customer"/></message><messagename="P1"><partname=“address"type=“XSD:string"/></message><messagename="P2"><partname="composite"type="tns:Composite"/></message>可以用XMLSchema定義的元素來描述part消息例如端口類型是一個由抽象操作和抽象消息構成的有名稱的集合。<wsdl:definitions....><wsdl:portTypename="nmtoken">*<wsdl:operationname="nmtoken"><wsdl:inputname="nmtoken"?message="qname"/><wsdl:outputname="nmtoken"?message="qname"/><wsdl:faultname="nmtoken"message="qname"/>*</wsdl:operation></wsdl:portType></wsdl:definitions>表示端口類型名稱表示操作名稱操作中引用到的消息通過message屬性指定3.端口類型定義(portType)消息操作echo.wsdl為一個端口類型定義了四方面的內容:消息傳輸協議網絡傳輸協議消息風格RPC風格操作的輸入輸出消息包含的是對遠程過程調用的輸入和輸出參數,而文檔風格的輸入和輸出消息包含的是交互雙方事先約定的任意XML文檔。編碼規那么定義把消息的各個局部序列化為XML文檔流是所采用的編碼規那么。通常有兩種:字面(literal)和SOAP。字面編碼規那么直接使用types元素或XMLSchema定義的類型來表示消息內容;而SOAP編碼規那么需要把用XMLSchema定義的類型根據SOAP標準定義的編碼規那么轉換后填充為消息內容。4.binding元素<bindingname="TimeServiceSoap"type="s0:TimeServiceSoap"> <soap:bindingstyle="document"transport=":///soap/"/> <operationname="getUTCTime"> <soap:operationsoapAction="://"style="document"/> <input> <soap:bodyuse="literal"/></input> <output><soap:bodyuse="literal"/></output> </operation> <operationname="getOffesetUTCTime"> <soap:operationsoapAction="://"style="document"/> <input> <soap:bodyuse="literal"/> </input> <output> <soap:bodyuse="literal"/> </output> </operation></binding>binding例子關聯的端口類型消息協議消息風格傳輸協議Http包頭的屬性消息內容在SOAP消息體中的表現形式literal/encoded<wsdl:bindingname="nmtoken"type="qname">*<wsdl:documentation..../>?<--extensibilityelement-->*<wsdl:operationname="nmtoken">*<wsdl:documentation..../>?<--extensibilityelement-->*<wsdl:input>?<wsdl:documentation..../>?<--extensibilityelement--></wsdl:input><wsdl:output>?<wsdl:documentation..../>?<--extensibilityelement-->*</wsdl:output><wsdl:faultname="nmtoken">*<wsdl:documentation..../>?<--extensibilityelement-->*</wsdl:fault></wsdl:operation></wsdl:binding>binding元素結構<servicename="TimeService"> <documentation>AsampleTimeservice</documentation> <portname="TimeServiceSoap"binding="s0:TimeServiceSoap"> <soap:addresslocation="://"/> </port> <portname="TimeServiceHttpGet"binding="s0:TimeServiceHttpGet"> <:addresslocation="://"/> </port> <portname="TimeServiceHttpPost"binding="s0:TimeServiceHttpPost"> <:addresslocation="://"/> </port></service>為綁定指定唯一地址來定義一個訪問端口。5.service元素<wsdl:servicename="nmtoken">*<wsdl:documentation..../>?<wsdl:portname="nmtoken"binding="qname">*<wsdl:documentation..../>?<--extensibilityelement--></wsdl:port><--extensibilityelement--></wsdl:service>service元素結構綁定效勞端口“echo.wsdl〞文件Service中的port具有如下的關系:如果一個效勞中有多個訪問端口屬于同一端口類型,但是對應不同的綁定或者地址,那么這些訪問端口可以相互替換。這使得WSDL文檔使用者根據需要選擇訪問端口。通過檢查訪問端口可以確定效勞的端口類型。這使得WSDL文檔的使用者能夠根據它支持的端口類型決定是否與一個特定的效勞通訊。所有訪問端口都不相互通信,即一個效勞的訪問端口的輸出不會是另一個訪問端口的輸入。實例WSDL1.1支持4種消息交換方式,來訪問效勞端口。單向〔One-way〕:效勞訪問端口接收消息;請求響應〔Request-response〕:效勞訪問端口接收請求消息,然后發送響應消息;要求應答〔Solicit-response〕:效勞訪問端口發送要求消息,然后接收應答消息;通知〔Notification〕:效勞訪問端口發送通知消息。消息交換方式單向操作語法:<wsdl:definitions....><wsdl:portType....>*<wsdl:operationname="nmtoken"><wsdl:inputname="nmtoken"?message="qname"/></wsdl:operation></wsdl:portType></wsdl:definitions>input元素指定用于單向操作的抽象消息格式。單向操作請求響應操作語法<wsdl:definitions....><wsdl:portType....>*<wsdl:operationname="nmtoken"parameterOrder="nmtokens"><wsdl:inputname="nmtoken"?message="qname"/><wsdl:outputname="nmtoken"?message="qname"/><wsdl:faultname="nmtoken"message="qname"/>*</wsdl:operation></wsdl:portType></wsdl:definitions>請求響應操作要求應答操作語法<wsdl:definitions....><wsdl:portType....>*<wsdl:operationname="nmtoken"parameterOrder="nmtokens"><wsdl:outputname="nmtoken"?message="qname"/><wsdl:inputname="nmtoken"?message="qname"/><wsdl:faultname="nmtoken"message="qname"/>*</wsdl:operation></wsdl:portType></wsdl:definitions>要求應答操作通知操作語法<wsdl:definitions....><wsdl:portType....>*<wsdl:operationname="nmtoken"><wsdl:outputname="nmtoken"?message="qname"/></wsdl:operation></wsdl:portType></wsdl:definitions>通知操作如果單向操作和通知操作未指定name屬性,那么該屬性名默認為是操作名。如果請求響應或要求應答操作中未指定name屬性,那么該屬性名默認為是操作名+“Request〞/“Responese〞/“Solicit〞。針對于請求應答和要求應答操作可以通過parameterOrder指定一個參數名列表。該屬性的值是一個用空格分開的消息構件名序列。操作中的元素名稱SOAP:binding元素說明WSDL文檔綁定到SOAP協議格式,該元素在使用SOAP綁定時是必需的。<definitions....><binding....><soap:bindingtransport="uri"?style="rpc|document"?></binding></definitions>style屬性值是它所包含的操作子元素的style屬性的默認值。transport屬性是必需的,它的值表示綁定的傳輸方式與SOAP的何種傳輸方式一致。URI值:///soap/表示傳輸方式和SOAP標準的HTTP綁定相一致。soap:binding元素

<definitions....><binding....><operation....><soap:operationsoapAction="uri"?style="rpc|document"?>?</operation></binding></definitions>soap:operation<definitions....><binding....><operation....><input><soap:bodyparts="nmtokens"?use="literal|encoded"?encodingStyle="uri-list"?namespace="uri"?></input><output><soap:bodyparts="nmtokens"?use="literal|encoded"?encodingStyle="uri-list"?namespace="uri"?></output></operation></binding></definitions>soap:body<definitions....><binding....><operation....><fault>*<soap:faultname="nmtoken"use="literal|encoded"encodingStyle="uri-list"?namespace="uri"?></fault></operation></binding></definitions>soap:fault<definitions....><binding....><operation....><input><soap:headermessage="qname"part="nmtoken"use="literal|encoded"encodingStyle="uri-list"?namespace="uri"?>*<soap:headerfaultmessage="qname"part="nmtoken"use="literal|encoded"encodingStyle="uri-list"?namespace="uri"?/>*<soap:header></input><output><soap:headermessage="qname"part="nmtoken"use="literal|encoded"encodingStyle="uri-list"?namespace="uri"?>*<soap:headerfaultmessage="qname"part="nmtoken"use="literal|encoded"encodingStyle="uri-list"?namespace="uri"?/>*<soap:header></output></operation></binding></definitions>soap:header和soap:headerfault<definitions....><port....><soap:addresslocation="uri"/></port></definitions>soap:address1.rpc/encoded2.rpc/literal3.document/encoded4.document/literal消息傳遞模式publicclassmyServices{publicvoidmyMethod(intx){return}}效勞WSDL文檔內容<messagename="myMethodRequest"><partname="x"type="xsd:int"/></message><messagename="empty"/><portTypename="PT"><operationname="myMethod"><inputmessage="myMethodRequest"/><outputmessage="empty"/></operation></portType>1.rpc/encoded樣式SOAP文檔內容<soap:envelope><soap:body><myMethod><xxsi:type="xsd:int">5</x></myMethod></soap:body></soap:envelope>1.rpc/encoded樣式WSDL文檔內容<messagename="myMethodRequest"><partname="x"type="xsd:int"/></message><messagename="empty"/><portTypename="PT"><operationname="myMethod"><inputmessage="myMethodRequest"/><outputmessage="empty"/></operation></portType>2.rpc/literal樣式SOAP文檔內容<soap:envelope><soap:body><myMethod><x>5</x></myMethod></soap:body></soap:envelope>2.rpc/literal樣式WSDL文檔內容<types><schema><elementname="xElement"type="xsd:int"/></schema></types><messagename="myMethodRequest"><partname="x"element="xElement"/></message><messagename="empty"/><portTypename="PT"><operationname="myMethod"><inputmessage="myMethodRequest"/><outputmessage="empty"/></operation></portType>3.document/encodedSOAP文檔內

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論