SOAP Syntax

SOAP Building Blocks

A SOAP message is a standard XML document that includes the following elements:

  • Required Envelope element, which can identify this XML document as a SOAP message
  • Optional Header element, containing header information
  • Required Body element, containing all the call and response information
  • Optional Fault element, providing information about the errors that occurred during the processing of this message

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

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

and the default namespace for SOAP encoding and data types:

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

Grammar Rules

Here are some important grammar rules:

  • SOAP Messages Must Be Encoded in XML
  • SOAP Messages Must Use SOAP Envelope Namespace
  • SOAP Messages Must Use SOAP Encoding Namespace
  • SOAP Messages Cannot Contain DTD References
  • SOAP Messages Cannot Contain XML Processing Instructions

Basic Structure of SOAP Messages

<?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>