SOAP Request Envelope XML

SOAP (Simple Object Access Protocol) is the XML-based messaging protocol that dominated enterprise web service integration throughout the 2000s and early 2010s. Despite REST's dominance for new APIs, SOAP remains deeply embedded in financial systems, healthcare platforms (HL7), enterprise ERP systems (SAP, Oracle), government services, and any industry with formal interchange standards. When you need to integrate with these systems, understanding SOAP's XML structure is essential. A SOAP message is an XML document with a specific structure defined by the SOAP specification (this example uses SOAP 1.2, the current version). The root element is soapenv:Envelope, which wraps the entire message. Inside the envelope are two optional sections: soapenv:Header for message-level metadata and soapenv:Body for the actual request or response content. The soapenv: prefix on all SOAP elements refers to the SOAP namespace (xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"). The web: prefix refers to the target web service's namespace (xmlns:web="http://webservice.example.com/"), which the service's WSDL document defines. Namespace prefixes in XML are arbitrary aliases — what matters is the full namespace URI they reference. The SOAP Header in this example contains an AuthHeader element with authentication credentials. SOAP headers are processed by intermediaries (security gateways, routing proxies) and by the final endpoint before the body is executed. The WS-Security standard defines more sophisticated authentication mechanisms including digital signatures and encrypted tokens for high-security SOAP services. The SOAP Body contains the actual operation request: GetUserDetails with UserId and IncludeAddress parameters. The WSDL (Web Service Definition Language) document for the service defines the exact element names and types expected in the body. When constructing a SOAP request, you must consult the WSDL to know the correct namespace and element structure. Generating SOAP requests from WSDL: tools like SoapUI can import a WSDL URL and automatically generate sample SOAP request envelopes for every operation. This is far more practical than constructing requests manually, especially for services with complex schemas. Once you have a working sample request from SoapUI, paste it here to format it clearly before adapting it for your integration code. REST vs SOAP trade-offs: SOAP's verbosity (this request is 10+ lines of XML for a simple query) is its biggest practical disadvantage. Its advantages are formal contracts (WSDL), built-in WS-Security standards, guaranteed message delivery (WS-ReliableMessaging), and transactions (WS-Transaction) — features that enterprise systems rely on and that REST doesn't standardize. Real-world integration scenario: connecting a modern microservice to a bank's payment SOAP API, where you construct requests using a SOAP library (node-soap in Node.js, zeep in Python, JAX-WS in Java) that handles the envelope structure automatically, leaving you to specify only the operation name and parameters. Tips: never parse SOAP responses with custom XML parsing — use a SOAP client library that understands the WSDL contract and provides typed access to response elements. Manual SOAP parsing is error-prone and fragile across service updates.

Example
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
    xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"
    xmlns:web="http://webservice.example.com/">
  <soapenv:Header>
    <web:AuthHeader>
      <web:Username>apiuser</web:Username>
      <web:APIKey>abc123xyz</web:APIKey>
    </web:AuthHeader>
  </soapenv:Header>
  <soapenv:Body>
    <web:GetUserDetails>
      <web:UserId>12345</web:UserId>
      <web:IncludeAddress>true</web:IncludeAddress>
    </web:GetUserDetails>
  </soapenv:Body>
</soapenv:Envelope>
[ open in XML Formatter → ]

FAQ

What is the difference between SOAP and REST?
SOAP is a strict XML-based protocol with a formal contract (WSDL), built-in error handling, and support for WS-Security. REST is an architectural style using plain HTTP and JSON, lighter and easier to use but without a formal contract standard.
What does the SOAP Header contain?
The Header carries metadata like authentication tokens, message IDs, routing instructions, or transaction context. It is processed by intermediaries or the endpoint before the Body is acted on.
How do I test a SOAP endpoint?
Use curl with a Content-Type: application/soap+xml header and the envelope as the POST body, or use tools like SoapUI or Postman (which supports SOAP requests). The XML formatter helps prepare the envelope before sending.

Related Examples