WSDL - 绑定元素

< binding> 元素提供了有关如何通过网络实际传输 portType 操作的具体细节.

  • 绑定可通过多种传输提供,包括HTTP GET,HTTP POST或SOAP.

  • 绑定提供了有关用于传输 portType 操作的协议的具体信息.

  • 绑定提供服务的信息位于.

  • 对于SOAP协议,绑定是< soap:binding> ,传输是SOAP消息在顶部HTTP协议.

  • 您可以为单个 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消息格式的整体样式.样式值 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 = "https://img01.yuandaxia.cn/Content/img/tutorials/wsdl/"/>
   <operation name = "sayHello">
      <soap:operation soapAction = "sayHello"/>
			
      <input>
         <soap:body
            encodingStyle = "https://img01.yuandaxia.cn/Content/img/tutorials/wsdl/"
            namespace = "urn:examples:helloservice" use = "encoded"/>
      </input>
			
      <output>
         <soap:body
            encodingStyle = "https://img01.yuandaxia.cn/Content/img/tutorials/wsdl/"
            namespace = "urn:examples:helloservice" use = "encoded"/>
      </output>
   </operation>
</binding>