WSDL <binding>元素

WSDL <binding>元素提供了有关如何通过线路传输portType实际操作的具体细节。

  • 绑定可以通过多种传输方式提供,包括HTTP GET,HTTP POST或SOAP。
  • 绑定提供了有关用于传输portType操作的协议的具体信息。
  • 绑定提供服务所在的信息。
  • 对于SOAP协议,绑定是使用<soap:binding>,表示传输是基于HTTP协议的SOAP消息。
  • 可以为单个portType指定多个绑定。

绑定元素有两个属性:nametype属性。

<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

此元素用于指定输入和输出消息的详细信息。 对于HelloWorldbody元素指定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>