Latest web development tutorials

SOAP Syntax

SOAP Building Blocks

A SOAP message is an ordinary XML document containing the following elements:

  • Envelope required elements, the XML document can be identified as a SOAP message
  • Optional Header element that contains header information
  • Body required elements, including all the calls and responses
  • Optional Fault element provides information about the process this error message information

All of the above elements are declared in default namespace for the SOAP envelope in:

http://www.w3.org/2001/12/soap-envelope

And namespace for SOAP encoding and data types by default:

http://www.w3.org/2001/12/soap-encoding


Syntax Rules

Here are some important syntax rules:

  • SOAP message must be encoded in XML
  • SOAP message must use the SOAP Envelope namespace
  • SOAP message must use the SOAP Encoding namespace
  • SOAP message must not contain a DTD reference
  • SOAP message can not contain XML processing instructions

The basic structure of a SOAP message

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Header>
...
</soap:Header>

<soap:Body>
...
<soap:Fault>
...
</soap:Fault>
</soap:Body>

</soap:Envelope>