Chapter: XML and Web Services : Building XML-Based Applications : Web Services Building Blocks: WSDL and UDDI

SOAP Binding

When using WSDL documents to describe Web Services that will exchange SOAP messages (that is, SOAP endpoints), you need to have a way to indicate within the WSDL document all the necessary information about the SOAP messages that will be exchanged.

SOAP Binding

When using WSDL documents to describe Web Services that will exchange SOAP messages (that is, SOAP endpoints), you need to have a way to indicate within the WSDL document all the necessary information about the SOAP messages that will be exchanged. WSDL uses extensibility elements to provide this information. The SOAP binding that is provided with WSDL supplies the following information:

 

   An indication that the WSDL binding is bound to the SOAP protocol.

 

   How to specify the address for the SOAP endpoints.

 

   For the HTTP binding of SOAP, the URI for the SOAPAction HTTP header (explained in Chapter 15).

 

   A list of definitions for all Header elements in the SOAP Envelope.

 

   A way of specifying SOAP roots in XSD.

 

Let’s take a look at some examples of the SOAP binding in WSDL.

 

soap:binding, soap:operation, soap:header, and soap:body

 

The following example shows a SOAP binding of a request/response operation over HTTP:

 

<binding name=”MyServiceSoapBinding” type=”tns:MyServicePortType”> <soap:binding style=”rpc”

 

transport=”http://schemas.xmlsoap.org/soap/http” /> <operation name=”MyMethod”>

 

<soap:operation SOAPAction=”http://mySite.com/MyMethod” style=”rpc” /> <input>

 

<soap:body use=”encoded” namespace=”http://mySite.com/myService” encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/” />

 

<soap:header message=”tns:MyMethod” part=”MyHeader” use=”literal”/> </input>

 

<output>

 

<soap:body use=”encoded” namespace=”http://mySite.com/myService” encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/” />

 

</output>

 

</operation>

 

</binding>

 

Note that the style attribute of the soap:binding element is set to rpc. In the case of a one-way operation over SMTP, for example, the style attribute would have a value of document (and document is the default if the attribute is omitted). The transport attribute (here, set to the URI of the HTTP binding in the SOAP specification) indicates to which transport of SOAP this binding corresponds.

 

The soap:operation element includes the SOAPAction attribute, which specifies the value of the SOAPAction header for this operation (required only for HTTP), as well as the style attribute, which indicates either RPC messages (containing parameters and return values) or documents.

The soap:header and soap:body elements define how message parts appear in the SOAP Header and Body elements, respectively. The soap:header and soap:body ele-ments can each take up to four attributes:

 

   The optional parts attribute (not shown in our example) is used when parts of the message may appear outside the SOAP Envelope, as is the case when the message is in MIME multipart/related format. In that case, the value of the parts attribute indicates which parts appear within the SOAP Envelope.

 

   The required use attribute indicates whether the message parts are encoded. If the value of use is encoded, each message part references an abstract type using the type attribute. In this case, the encoding is specified by the encodingStyle

 

attribute. The alternative to encoded is literal, which indicates that each part ref-erences a concrete schema using the element attribute (for simple parts) or the type attribute (for composite parts).

 

   The encodingStyle attribute’s values are lists of URIs, which represent encodings used within the message, exactly like the corresponding attribute in the SOAP specification (see Chapter 15).

 

   The namespace attribute (not shown in our example) is an input to the encoding defined by the encodingStyle attribute.

 

soap:address, soap:fault, and soap:headerfault

 

There are a few additional elements in the SOAP binding worth mentioning. First, the soap:address element simply assigns a URI to a port:

 

<service  name=”MyService”>

 

<port name=”MyServicePort” binding=”tns:MyServiceBinding”> <soap:address location=”http://www.mySite.com/MyServiceURL/” />

 

</port>

 

</service>

 

The soap:fault element specifies the contents of the SOAP Fault element:

 

<fault>

 

<soap:fault name=”MyFault” use=”encoded” encodingStyle=”http://schemas.xmlsoap.org/soap/encoding/”

 

<http://schemas.xmlsoap.org/soap/encoding/>/>

 

</fault>

 

Finally, the soap:headerfault element follows the syntax of the soap:fault element but refers to SOAP Fault in Header elements.

Other Bindings

 

In addition to the SOAP binding, the WSDL specification also provides for HTTP GET and POST bindings as well as a MIME binding. We’re not going to cover how to use these bindings in depth. However, an outline of the various elements that each binding uses is provided in Table 16.2.

 

TABLE 16.2    Other WSDL Bindings


In addition, the MIME binding allows the soap:body element as a MIME element. This element will have a content type of text/xml.


Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
XML and Web Services : Building XML-Based Applications : Web Services Building Blocks: WSDL and UDDI : SOAP Binding |


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.