next up previous contents
Next: Security Up: SOAP - Simple Object Previous: Error Handling   Contents


Encoding and Data Types

Data transmitted in a SOAP package has to be encoded in some way. SOAP itself permits any encoding style in its body as far as it is XML compliant. For compatibility reasons, the SOAP specification suggests an encoding style in section 5 of the SOAP standard that is commonly used.

SOAP encoding is based on XML Schema and inherits its built-in data types. However, some data types which are commonly used in common computer languages, like arrays or structures are not covered in the XML Schema standard. The encoding of these data types for issuing remote procedure calls is mandatory, hence the SOAP standard itself specifies these specific data types.

Listing 7 shows a SOAP messages with SOAP encoded data. The data type of the element is added by adding a specific attribute to the XML tag.

language=XML
\begin{lstlisting}[caption={SOAP Encoding Example},
label=ex_soapenc_named]
<s:...
...loat''>7.23</q:value>
</q:curConvert>
</s:Body>
</s:Envelope>
\end{lstlisting}

Another variant of encoding SOAP messages is the encoding of data in anonymous tags, as shown in Listing 8. Here the name of the tag is not specified, so there is no meaningful identification of the element. This implementation works well with array data types where there is no need for naming the element.

language=XML
\begin{lstlisting}[caption={Anonymous SOAP Encoding},
label=ex_soapenc_anon]
.....
...UR</SOAP-ENC:string>
<SOAP-ENC:float>7.23</SOAP-ENC:float>
...
\end{lstlisting}

An alternative to SOAP encoding would be to constrain SOAP message data by an external XML Schema document, similar to the examples in section 2.2. This way the SOAP Message has to contain a reference to a proper XML Schema document or a namespace in which the data types of the elements are defined18.

With the use of SOAP Encoding, serialization of various data types of common computer languages, like C/C++, Java, Perl or Python can be accomplished. Encoding is not machine dependent which greatly improves interoperability between Web Services. SOAP messages are like any XML document human legible, so developers can easily debug common problems by looking at the message itself.


next up previous contents
Next: Security Up: SOAP - Simple Object Previous: Error Handling   Contents
Hermann Himmelbauer 2006-09-27