Encoding

After binding has been specified, you need to determine how a SOAP message will be encoded within a WSDL document.

  • The use attribute in the WSDL document defines the encoding style and can contain either of the two values, encoded or literal:
    • If the value of use is encoded, it specifies that encoding will follow the rules defined in the SOAP 1.1 specification.
    • If the value of use is literal, it indicates that the rules to encode the message parts are specified by an XML schema.
  • This combination of binding and encoding produces the following modes of messaging:
    • RPC/encoded
    • RPC/literal
    • Document/encoded
    • Document/literal
    • Document/literal wrapped

In the code example, the use attribute within the body element is set to encoded.

<definitions name="SchoolLibrary"
targetNamespace="http://www.school.com/Library.wsdl">
<xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  
  <message name="getBookRequest">
    <part name="Title" type="xsd:string"/>
  </message>

  <message name="getBookResponse">
    <part name="return" type="xsd:string"/> 
  </message>
 
  <interface name=”LibInterface”>
    <operation name="getBook">
      <input message="getBookRequest"/>
      <output message="getBookResponse"/>
    </operation>
  </interface>

  <binding name="LibBinding" type="LibInterface">
    <operation name="getBook">
      <input message="lib:getBookRequest"/>
      <output message="lib:getBookResponse"/>
    </operation>
  </binding>
  <binding name="LibBinding" type="LibInterface">
    <soap:binding
    transport="http://schemas.xmlsoap.org/soap/http"
    style="rpc"/>
    <operation name="getBook">
    <soap:operation soapAction="getBook"/>
    <input>
    <soap:body encodingStyle=
    "http://schemas.xmlsoap.org/soap/enoding/"
    use="encoded"/>
    </input>
    <output>
    <soap:body encodingStyle=
    "http://schemas.xmlsoap.org/soap/encoding/"
    use="encoded"/>
    </output>
    </operation>
</binding>

<definitions
>

Click the Next button to continue.