Herong's Tutorial Notes on Web Service and SOAP
Dr. Herong Yang, Version 4.00

Using SOAP Encoding in SOAP Messages

This section describes an example on how SOAP Encoding can be used in SOAP messages.

SOAP encoding can be used in SOAP header blocks and SOAP bodies by specifying the SOAP "encodingStyle" attribute as encodingStyle="http://schemas.xmlsoap.org/soap/encoding/". Here is a SOAP message example with SOAP encoding:

<?xml version="1.0"?>
<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope">
 <env:Header 
    env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
    xmlns:enc="http://www.w3.org/2003/05/soap-encoding">
  <h:expense xmlns:h="http://www.yang.com"
     env:role="http://www.w3.org/2003/05/soap-envelope/role/next"
     env:mustUnderstand="true">
  </h:expense>
 </env:Header>

 <env:Body 
    env:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
    xmlns:enc="http://www.w3.org/2003/05/soap-encoding">
  <b:travel enc:nodeType="struct" xmlns:b="http://www.yang.com">
   <b:currency enc:id="euro">
    <b:rate>0.72</b:rate>
   </b:currency>
   <b:flight>429.00</b:flight>
  </b:travel>
  <b:shopping enc:nodeType="struct" xmlns:b="http://www.yang.com">
   <b:currency enc:ref="#euro"/>
   <b:paris enc:nodeType="array" enc:arraySize="3"
      enc:itemType="xsi:float">
    <b:item>29.00</b:item>
    <b:item>99.00</b:item>
    <b:item>19.00</b:item>
   </b:paris>
  </b:shopping>
 </env:Body>
</env:Envelope>

Last update: 2007.

Sections in This Chapter

What Is SOAP Encoding?

Multiple References and Circular References

Node Types - simple, struct, array

SOAP Encoding Attributes and Namespace

Using SOAP Encoding in SOAP Messages

Dr. Herong Yang, updated in 2009
Using SOAP Encoding in SOAP Messages