06 - WSDL 2.0 Binding Element

The binding element describes how a web service is going to be bound to a protocol. We have already defined what are the abstract messages that our web service could be exchanging, but we still have to specify how these messages will be exchanged between the client and the web service provider.

With the binding element you specify a concrete message format and a transmission protocol detailed for an interface. Each operation and fault in an interface must have these details.

The following is an example of the binding element in a WSDL 2.0 file. 

<binding name = "myServiceInterfaceSOAPBinding" 
          interface = "tns:myServiceInterface"
          type = "http://www.w3.org/ns/wsdl/soap"
          wsoap:protocol = "http://www.w3.org/2003/05/soap/bindings/HTTP/">
    <operation ref = "tns:checkServiceStatusOp" 
      wsoap:mep = "http://www.w3.org/2003/05/soap/mep/soap-response"/>
    <fault ref = "tns:dataFault" 
      wsoap:code = "soap:Sender"/>
</binding>

Binding

A binding element has the following attributes:

<binding name = "myServiceInterfaceSOAPBinding"

The name attribute defines the name of the binding. With this name you can reference it when defining a service endpoint. Every binding name must be unique within the WSDL 2.0 target namespace.

interface = "tns:myServiceInterface"

The interface attribute defines the name of the interface (previously defined in the WSDL 2.0) we are referring in this binding.

type = "http://www.w3.org/ns/wsdl/soap"

The type attribute defines which message format is going to be used. In our example is SOAP.

wsoap:protocol = "http://www.w3.org/2003/05/soap/bindings/HTTP/">

The wsoap:protocol attribute defines the underlying transport protocol. This defines that the messages are going to be transported using HTTP.

Operation

The operation element within the binding element defines which previously defined operation we are binding.

<operation ref = "tns:checkServiceStatusOp"

The ref attribute of the operation element references a specific operation (already defined in the interface section).

wsoap:mep = "http://www.w3.org/2003/05/soap/mep/soap-response"/>

The wsoap:mep attribute defines the message exchange pattern for SOAP

Fault

The fault element within the binding element defines which previously defined fault we are binding.

<fault ref = "tns:dataFault"

The ref attribute of the fault element references a specific fault (already defined in the interface section).

wsoap:code = "soap:Sender"/>

The wsoap:code attribute of the fault element defines the fault code that will trigger sending this fault message.

Like us on Facebook