Home/SOAP Track/SOAP Envelope & Namespaces

SOAP Envelope & Namespaces

Understand the SOAP envelope structure, XML namespaces, and how to construct valid SOAP requests.

The SOAP Envelope

Every SOAP message is an XML document wrapped in an Envelope element. The Envelope contains an optional Header and a required Body. The Header carries metadata (auth tokens, transaction IDs). The Body carries the actual request or response payload.

Namespaces Matter

XML namespaces prevent element name collisions. The SOAP envelope uses http://schemas.xmlsoap.org/soap/envelope/ (SOAP 1.1) or http://www.w3.org/2003/05/soap-envelope (SOAP 1.2). The carrier's service uses its own namespace. Get the namespace wrong and you'll get cryptic 'element not found' faults.
Carrier Reality

UPS's SOAP API uses different namespaces for different service versions. Upgrading from v1 to v2 means updating every namespace URI — miss one and the request silently fails.

Building a SOAP Request

Start with the Envelope, declare namespaces on it, add auth in the Header, and construct the Body with the operation element. Use the carrier's WSDL to find the correct operation name, namespace, and parameter types. Don't hand-build SOAP — use a library, but understand the structure so you can debug.

Practice Drills

What are the two main child elements of a SOAP Envelope?

Build a SOAP 1.1 envelope to call CreateShipment in the carrier namespace http://carrier.com/shipping/v1.

SOAPAction: http://carrier.com/shipping/v1/CreateShipment

Namespace: http://carrier.com/shipping/v1

Fields: Origin=US, Destination=DE, Weight=5.0