WSDL - <binding> 元素



<binding> 元素提供了有關如何透過網路實際傳輸portType操作的具體細節。

  • 繫結可以透過多種傳輸方式提供,包括 HTTP GET、HTTP POST 或 SOAP。

  • 繫結提供了有關用於傳輸portType操作的協議的具體資訊。

  • 繫結提供了服務所在位置的資訊。

  • 對於 SOAP 協議,繫結為<soap:binding>,傳輸是在 HTTP 協議之上的 SOAP 訊息。

  • 您可以為單個portType指定多個繫結。

繫結元素有兩個屬性:name 屬性和type 屬性。

<binding name = "Hello_Binding" type = "tns:Hello_PortType">

name 屬性定義繫結的名稱,type 屬性指向繫結的埠,在本例中為“tns:Hello_PortType”埠。

SOAP 繫結

WSDL 1.1 包含 SOAP 1.1 的內建擴充套件。它允許您指定 SOAP 特定的詳細資訊,包括 SOAP 標頭、SOAP 編碼樣式和 SOAPAction HTTP 標頭。SOAP 擴充套件元素包括以下內容:

  • soap:binding
  • soap:operation
  • soap:body

soap:binding

此元素指示繫結將透過 SOAP 提供。style 屬性指示 SOAP 訊息格式的整體樣式。style 值為rpc 指定 RPC 格式。

transport 屬性指示 SOAP 訊息的傳輸方式。值 http://schemas.xmlsoap.org/soap/http 指示 SOAP HTTP 傳輸,而 http://schemas.xmlsoap.org/soap/smtp 指示 SOAP SMTP 傳輸。

soap:operation

此元素指示將特定操作繫結到特定 SOAP 實現。soapAction 屬性指定使用 SOAPAction HTTP 標頭來標識服務。

soap:body

此元素使您能夠指定輸入和輸出訊息的詳細資訊。在 HelloWorld 的情況下,body 元素指定 SOAP 編碼樣式和與指定服務關聯的名稱空間 URN。

以下是示例章節中的程式碼片段:

<binding name = "Hello_Binding" type = "tns:Hello_PortType">
   <soap:binding style = "rpc" transport = "http://schemas.xmlsoap.org/soap/http"/>
   <operation name = "sayHello">
      <soap:operation soapAction = "sayHello"/>
			
      <input>
         <soap:body
            encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
            namespace = "urn:examples:helloservice" use = "encoded"/>
      </input>
			
      <output>
         <soap:body
            encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
            namespace = "urn:examples:helloservice" use = "encoded"/>
      </output>
   </operation>
</binding>
廣告

© . All rights reserved.