Skip to main content

Envelope

Required

SOAP 1.1: xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"

SOAP 1.2: xmlns:soap="http://www.w3.org/2003/05/soap-envelope"

The Envelope is the mandatory root element of every SOAP message. It declares the SOAP namespace, which distinguishes SOAP 1.1 from SOAP 1.2. The Envelope wraps the Header (optional) and Body (required). No other elements may appear at the Envelope level per the spec.

Details

The Envelope is the outermost XML element of every SOAP message. Its namespace URI is the version discriminator – processors use it to determine which SOAP version to apply.

SOAP 1.1 namespace: http://schemas.xmlsoap.org/soap/envelope/ SOAP 1.2 namespace: http://www.w3.org/2003/05/soap-envelope

Children: The Envelope MUST contain exactly one Body element. It MAY contain exactly one Header element, which MUST appear before the Body if present. No other elements may appear as direct children of the Envelope per the spec.

Namespace declarations: The Envelope is the standard place to declare all namespaces used in the message (xmlns:xsi, xmlns:xsd, business namespace prefixes). This keeps namespace declarations at the top of the message for readability.

Version faults: If a SOAP 1.2 processor receives a message with the SOAP 1.1 namespace, it MUST return a VersionMismatch fault.

Attributes

AttributeDescription
xmlns:soapSOAP namespace declaration – determines version. 1.1: xmlsoap.org/soap/envelope. 1.2: w3.org/2003/05/soap-envelope
xmlns:xsiOptional XML Schema Instance namespace for xsi:type and xsi:nil attributes
soap:encodingStyleSOAP 1.1 only: encoding style URI. Deprecated in SOAP 1.2.

Examples

Minimal SOAP 1.2 envelope
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
  xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
  xmlns:ex="http://example.com/service">
  <soap:Body>
    <!-- payload here -->
  </soap:Body>
</soap:Envelope>
SOAP 1.1 envelope with namespace declarations
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
  xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:svc="http://example.com/CustomerService">
  <soap:Header>...</soap:Header>
  <soap:Body>...</soap:Body>
</soap:Envelope>

See Also