Open In App

WSDL <binding> Element

Last Updated : 16 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

WSDL <binding> Element is used to provide details on how a portType operation will actually be transmitted over the wire. It can be delivered using a variety of protocols, such as HTTP GET, HTTP POST, or SOAP. For the SOAP protocol, the transport is SOAP messages on top of the HTTP protocol, and the binding is <soap:binding>.

Syntax:

<binding name="Greetings_Binding" type="tns:Greetings_PortType">
<!-- SOAP Binding and related elements go here -->
</binding>

SOAP Binding: Built-in SOAP 1.1 extensions are available in WSDL 1.1. It enables you to specify SOAP-specific information, such as HTTP SOAPAction headers, SOAP encoding styles, and SOAP headers for headers. The following are some examples of the SOAP extension elements.

  • soap:binding: This element denotes that SOAP will be used to make the binding available. The SOAP message format’s overall style is indicated via the style attribute. An RPC format is specified by a style value of rpc.
  • soap:operation: This element denotes the connection between a certain operation and a particular SOAP implementation. The SOAPAction HTTP header should be used to identify the service, according to the soapAction attribute.
  • soap:body: You can define the specifics of the input and output messages using this element. In the case of HelloWorld, the body element defines the namespace URN connected to the requested service as well as the SOAP encoding type.

The below examples illustrate the WSDL <binding> Element:

Example 1:

XML




<binding name = "Greeting_Binding" type = "tns:Greeting_PortType">
   <soap:binding style = "rpc" transport = "..."/>
   <operation name = "Greeting">
      <soap:operation soapAction = "Greeting"/>
             
      <input>
         <soap:body encodingStyle = "..." namespace = "urn:examples:Greeting" use = "encoded"/>
      </input>   
      <output>
         <soap:body
            encodingStyle = "..."
            namespace = "urn:examples:Greeting" use = "encoded"/>
      </output>
   </operation>
</binding>


In this example, we have defined a binding named “Greeting_Binding” for the “Greeting_PortType” with SOAP-based settings for the “Greeting” operation.

Example 2:

XML




<binding name = "Greeting_Binding" type = "tns:Greeting_PortType">
   <soap:binding style = "rpc" transport = "..."/>
   <operation name = "Greeting">
      <soap:operation soapAction = "Greeting"/>
             
      <input>
         <soap:body
            encodingStyle = "..."
            namespace = "urn:examples:Greeting" use = "encoded"/>
      </input>
             
      <output>
         <soap:body
            encodingStyle = "..."
            namespace = "urn:examples:Greeting" use = "encoded"/>
      </output>
   
      <input>
         <soap:body
            encodingStyle = "..."
            namespace = "urn:examples:Bye" use = "encoded"/>
      </input>
             
      <output>
         <soap:body
            encodingStyle = "..."
            namespace = "urn:examples:Bye" use = "encoded"/>
      </output>
   </operation>
</binding>


In this second example, we have expanded upon the previous one by including additional input and output elements within the “Greeting” operation.

In conclusion, the WSDL `<binding>` element is essential for configuring how portType operations are transmitted, especially in context of SOAP-based services.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads