WSDL 端口可描述由某個 web service 提供的界面(合法操作)。
WSDL 端口
<portType> 元素是最重要的 WSDL 元素。
它可描述一個 web service、可被執行的操作,以及相關的消息。
端口定義了指向某個 web service 的連接配接點。可以把該元素比作傳統程式設計語言中的一個函數庫(或一個子產品、或一個類),而把每個操作比作傳統程式設計語言中的一個函數。
操作類型
請求-響應是最普通的操作類型,不過 WSDL 定義了四種類型:
類型 | 定義 |
---|---|
One-way | 此操作可接受消息,但不會傳回響應。 |
Request-response | 此操走可接受一個請求并會傳回一個響應 |
Solicit-response | 此操作可發送一個請求,并會等待一個響應。 |
Notification | 此操作可發送一條消息,但不會等待響應。 |
One-Way 操作
一個 one-way 操作的例子:
<message name="newTermValues">
<part name="term" type="xs:string"/>
<part name="value" type="xs:string"/>
</message>
<portType name="glossaryTerms">
<operation name="setTerm">
<input name="newTerm" message="newTermValues"/>
</operation>
</portType >
在這個例子中,端口 "glossaryTerms" 定義了一個名為 "setTerm" 的 one-way 操作。
這個 "setTerm" 操作可接受新術語表項目消息的輸入,這些消息使用一條名為 "newTermValues" 的消息,此消息帶有輸入參數 "term" 和 "value"。不過,沒有為這個操作定義任何輸出。
Request-Response 操作
一個 request-response 操作的例子:
<message name="getTermRequest">
<part name="term" type="xs:string"/>
</message>
<message name="getTermResponse">
<part name="value" type="xs:string"/>
</message>
<portType name="glossaryTerms">
<operation name="getTerm">
<input message="getTermRequest"/>
<output message="getTermResponse"/>
</operation>
</portType>
在這個例子中,端口 "glossaryTerms" 定義了一個名為 "getTerm" 的 request-response 操作。
"getTerm" 操作會請求一個名為 "getTermRequest" 的輸入消息,此消息帶有一個名為 "term" 的參數,并将傳回一個名為 "getTermResponse" 的輸出消息,此消息帶有一個名為 "value" 的參數。
綁定到 SOAP
一個 請求 - 響應 操作的例子:
<message name="getTermRequest">
<part name="term" type="xs:string" />
</message>
<message name="getTermResponse">
<part name="value" type="xs:string" />
</message>
<portType name="glossaryTerms">
<operation name="getTerm">
<input message="getTermRequest" />
<output message="getTermResponse" />
</operation>
</portType>
<binding type="glossaryTerms" name="b1">
<soap:binding style="document"
transport="http://schemas.xmlsoap.org/soap/http" />
<operation>
<soap:operation
soapAction="http://example.com/getTerm" />
<input>
<soap:body use="literal" />
</input>
<output>
<soap:body use="literal" />
</output>
</operation>
</binding>
binding 元素有兩個屬性 - name 屬性和 type 屬性。
name 屬性定義 binding 的名稱,而 type 屬性指向用于 binding 的端口,在這個例子中是 "glossaryTerms" 端口。
soap:binding 元素有兩個屬性 - style 屬性和 transport 屬性。
style 屬性可取值 "rpc" 或 "document"。在這個例子中我們使用 document。transport 屬性定義了要使用的 SOAP 協定。在這個例子中我們使用 HTTP。
operation 元素定義了每個端口提供的操作符。
對于每個操作,相應的 SOAP 行為都需要被定義。同時您必須如何對輸入和輸出進行編碼。在這個例子中我們使用了 "literal"。
UDDI 是一種目錄服務,企業可以使用它對 Web services 進行注冊和搜尋。
UDDI,英文為 "Universal Description, Discovery and Integration",可譯為“通用描述、發現與內建服務”。
什麼是 UDDI?
UDDI 是一個獨立于平台的架構,用于通過使用 Internet 來描述服務,發現企業,并對企業服務進行內建。
- UDDI 指的是通用描述、發現與內建服務
- UDDI 是一種用于存儲有關 web services 的資訊的目錄。
- UDDI 是一種由 WSDL 描述的 web services 界面的目錄。
- UDDI 經由 SOAP 進行通信
- UDDI 被建構入了微軟的 .NET 平台
UDDI 基于什麼?
UDDI 使用 W3C 和 IETF* 的網際網路标準,比如 XML、HTTP 和 DNS 協定。
UDDI 使用 WSDL 來描述到達 web services 的界面
此外,通過采用 SOAP,還可以實作跨平台的程式設計特性,大家知道,SOAP 是 XML 的協定通信規範,可在 W3C 的網站找到相關的資訊。
*注釋:IETF - Internet Engineering Task Force
UDDI 的好處
任何規模的行業或企業都能得益于 UDDI。
在 UDDI 之前,還不存在一種 Internet 标準,可以供企業為它們的企業和夥伴提供有關其産品和服務的資訊。也不存在一種方法,來內建到彼此的系統和程序中。
UDDI 規範幫助我們解決的問題:
- 使得在成百萬目前線上的企業中發現正确的企業成為可能
- 定義一旦首選的企業被發現後如何啟動商業
- 擴充新客戶并增加對目前客戶的通路
- 擴充銷售并延伸市場範圍
- 滿足使用者驅動的需要,為在全球 Internet 經濟中快速合作的促進來清除障礙
UDDI 如何被使用
假如行業釋出了一個用于航班比率檢測和預訂的 UDDI 标準,航空公司就可以把它們的服務注冊到一個 UDDI 目錄中。然後旅行社就能夠搜尋這個 UDDI 目錄以找到航空公司預訂界面。當此界面被找到後,旅行社就能夠立即與此服務進行通信,這樣由于它使用了一套定義良好的預訂界面。
誰在支援 UDDI?
UDDI 是一個跨行業的研究項目,由所有主要的平台和軟體提供商驅動,比如:Dell, Fujitsu, HP, Hitachi, IBM, Intel, Microsoft, Oracle, SAP, 以及 Sun, 它既是一個市場經營者的團體,也是一個電子商務的上司者。
已有數百家公司參與了這個 UDDI 團體。
描述于 W3C 工作草案的完整 WSDL 1.2 文法已列在下面:
<wsdl:definitions name="nmtoken"? targetNamespace="uri">
<import namespace="uri" location="uri"/> *
<wsdl:documentation .... /> ?
<wsdl:types> ?
<wsdl:documentation .... /> ?
<xsd:schema .... /> *
</wsdl:types>
<wsdl:message name="ncname"> *
<wsdl:documentation .... /> ?
<part name="ncname" element="qname"? type="qname"?/> *
</wsdl:message>
<wsdl:portType name="ncname"> *
<wsdl:documentation .... /> ?
<wsdl:operation name="ncname"> *
<wsdl:documentation .... /> ?
<wsdl:input message="qname"> ?
<wsdl:documentation .... /> ?
</wsdl:input>
<wsdl:output message="qname"> ?
<wsdl:documentation .... /> ?
</wsdl:output>
<wsdl:fault name="ncname" message="qname"> *
<wsdl:documentation .... /> ?
</wsdl:fault>
</wsdl:operation>
</wsdl:portType>
<wsdl:serviceType name="ncname"> *
<wsdl:portType name="qname"/> +
</wsdl:serviceType>
<wsdl:binding name="ncname" type="qname"> *
<wsdl:documentation .... /> ?
<-- binding details --> *
<wsdl:operation name="ncname"> *
<wsdl:documentation .... /> ?
<-- binding details --> *
<wsdl:input> ?
<wsdl:documentation .... /> ?
<-- binding details -->
</wsdl:input>
<wsdl:output> ?
<wsdl:documentation .... /> ?
<-- binding details --> *
</wsdl:output>
<wsdl:fault name="ncname"> *
<wsdl:documentation .... /> ?
<-- binding details --> *
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ncname" serviceType="qname"> *
<wsdl:documentation .... /> ?
<wsdl:port name="ncname" binding="qname"> *
<wsdl:documentation .... /> ?
<-- address details -->
</wsdl:port>
</wsdl:service>
</wsdl:definitions>