What SOAP is and how the envelope works
The XML messaging protocol behind enterprise web services, and the three parts every SOAP message is built from.
A protocol, not an architecture
SOAP (originally Simple Object Access Protocol) is a specification for exchanging structured XML messages over a transport, in practice almost always HTTP. It is deliberately strict: the message shape, the encoding and the error format are all defined, which is why banks, insurers, telecoms and government systems standardised on it.
- SOAP 1.1 uses the namespace
http://schemas.xmlsoap.org/soap/envelope/and theSOAPActionHTTP header. - SOAP 1.2 uses
http://www.w3.org/2003/05/soap-envelopeand moves the action into theContent-Typeparameter. - Security is standardised separately as WS-Security: signing, encryption and tokens travel inside the header.
- The contract is published as a WSDL document, which is what makes code generation possible.
Envelope, header, body
| Part | Required | Purpose |
|---|---|---|
Envelope | Yes | The root element; declares the SOAP version and namespaces |
Header | No | Out-of-band data: credentials, correlation ids, routing, WS-Security |
Body | Yes | The actual call or response payload |
Fault | No | Appears inside the body on failure, with a code, reason and details |
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:q="urn:example:quotes">
<soap:Header>
<q:Auth>
<q:Token>8f2c1a</q:Token>
</q:Auth>
</soap:Header>
<soap:Body>
<q:GetQuote>
<q:symbol>AAPL</q:symbol>
</q:GetQuote>
</soap:Body>
</soap:Envelope>Attributes on a header block control who has to understand it: soap:mustUnderstand="1" means the receiver must process it or fail the call, and soap:actor (1.1) or soap:role (1.2) names the node it is addressed to. A fault is never mixed with a normal response body — it replaces it.
FAQ
Is SOAP still used?
Can SOAP return JSON?
Related
WSDL contracts and code generation Calling a SOAP service, and why REST usually wins
Last refreshed 2026-09-18.