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>