WS-Addressing — Standardized Message Routing for SOAP Web Services
In this tutorial, you will learn about WS. We cover key concepts, practical examples, and best practices to help you master this topic.
WS-Addressing is a SOAP standard that defines XML elements for routing messages, specifying source, destination, reply-to addresses, and message correlation IDs.
What You'll Learn
- WS-Addressing headers and their purposes
- Asynchronous message patterns
- Routing through intermediaries
Why It Matters
WS-Addressing enables complex message exchange patterns beyond simple request-response, supporting asynchronous processing and multi-hop routing.
Code Examples
<!-- WS-Addressing headers in SOAP -->
<soap:Header>
<wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">
uuid:a1b2c3d4-e5f6-7890-abcd-ef1234567890
</wsa:MessageID>
<wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">
http://example.com/orders/processor
</wsa:To>
<wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">
http://example.com/orders/PlaceOrder
</wsa:Action>
<wsa:ReplyTo xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Address>http://example.com/callback</wsa:Address>
</wsa:ReplyTo>
<wsa:From xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Address>http://client.example.com</wsa:Address>
</wsa:From>
<wsa:RelatesTo xmlns:wsa="http://www.w3.org/2005/08/addressing"
RelationshipType="http://www.w3.org/2005/08/addressing/reply">
uuid:original-message-id
</wsa:RelatesTo>
</soap:Header>
# WS-Addressing headers in Python (using zeep)
from zeep import Client
from zeep.transports import Transport
from requests import Session
session = Session()
session.headers.update({
'Content-Type': 'text/xml; charset=utf-8',
'SOAPAction': 'PlaceOrder'
})
transport = Transport(session=session)
client = Client('http://example.com/orders?wsdl', transport=transport)
# WS-Addressing is handled automatically by the SOAP library
result = client.service.PlaceOrder(
CustomerID='12345',
ItemID='ABC-789'
)
Common Mistakes
1. Missing MessageID
Every message should have a unique ID for correlation and tracking.
2. Incorrect ReplyTo Address
The ReplyTo must be a valid endpoint that can receive the response.
3. Not Using RelatesTo for Correlation
Without RelatesTo, responses cannot be matched to their requests.
4. Confusing To with Endpoint URL
The To header and the HTTP endpoint can differ when routing through intermediaries.
5. Ignoring Action Header
The Action header identifies the intended operation, enabling content-based routing.
Practice Questions
- What is the purpose of WS-Addressing?
- What does the
ReplyToheader specify? - How does
RelatesToenable message correlation? - What is the
Actionheader used for? - Why might
Todiffer from the HTTP endpoint?
Answers:
- To provide transport-neutral addressing and routing for SOAP messages.
- The endpoint where the response should be sent.
- It links a response to its original request message.
- To identify the intended operation for content-based routing.
- When messages pass through intermediaries before reaching the final destination.
Challenge: Design a WS-Addressing flow for an order processing system where an initial request goes to a router, then to a processor, and the response returns to a callback endpoint.
FAQ
What's Next
Learn about WS-Security for authentication and encryption, then compare REST vs SOAP.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro