Skip to content
Tutorials Center
My learning

Topics

Lesson 17 of 36 ยท WS-Security and Standards

WS-Addressing and WS-ReliableMessaging

Learn how WS-Addressing puts routing and reply information into SOAP headers, how asynchronous callbacks work, and how WS-ReliableMessaging numbers, acknowledges and retransmits messages.

HTTP assumes a simple shape: the client asks, the server answers on the same connection. Many real business processes do not fit that shape. A mortgage check may take an hour, so the answer must arrive later, maybe at a different address. A message may pass through a queue, and the network may lose it. Two WS-* standards make SOAP handle these cases: WS-Addressing (where is this message going, and where should the answer go?) and WS-ReliableMessaging (did it arrive, exactly once, in order?).

WS-Addressing

WS-Addressing (W3C) moves addressing information out of the transport and into the SOAP header, so it survives any transport and any number of hops. The namespace is http://www.w3.org/2005/08/addressing (prefix wsa).

Header Meaning
wsa:To The destination URI of this message.
wsa:Action The intent of the message; replaces SOAPAction and is usually the WSDL action URI.
wsa:MessageID A unique URI for this message (often urn:uuid:...).
wsa:ReplyTo An endpoint reference (EPR): where the response should be sent.
wsa:FaultTo Where faults should go, if different from ReplyTo.
wsa:From Who sent it (optional).
wsa:RelatesTo In a reply: the MessageID of the request it answers.
XML
<soap:Header>
  <wsa:To>https://credit.example/ws/check</wsa:To>
  <wsa:Action>urn:credit/CheckRequest</wsa:Action>
  <wsa:MessageID>urn:uuid:7f2b0c3e-0a41-4f7e-9a7c-3d5c8f2e1b11</wsa:MessageID>
  <wsa:ReplyTo><wsa:Address>https://bank.example/callbacks/credit</wsa:Address></wsa:ReplyTo>
</soap:Header>

The special address http://www.w3.org/2005/08/addressing/anonymous means "reply on the HTTP response of this request" (the usual synchronous behavior), and .../none means "no reply wanted".

Asynchronous request and callback

With WS-Addressing, a client can send a request with a ReplyTo pointing at its own web service. The server accepts quickly (HTTP 202 Accepted), does the work, and later sends a new SOAP message to the callback address with RelatesTo set to the original MessageID. The client uses RelatesTo to match answer and question.

sequenceDiagram
    participant C as Client (also a server)
    participant S as Credit service
    C->>S: POST /check (MessageID=A, ReplyTo=callback)
    S-->>C: 202 Accepted (empty)
    Note over S: works for a while
    S->>C: POST callback (RelatesTo=A, result)
    C-->>S: 200 / 202

Two independent HTTP exchanges, tied together by MessageID and RelatesTo.

The next program runs both roles on loopback. The service replies after a delay to whatever ReplyTo says, and the client matches replies to pending requests by RelatesTo.

Node.js Async reply with ReplyTo and RelatesTo

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Both requests got an immediate 202, and the real answers arrived later on a different connection, matched correctly by RelatesTo.

WS-ReliableMessaging

HTTP can fail in the middle: you send a payment, the connection drops, and you do not know whether the server received it. Retrying blindly may charge twice. WS-ReliableMessaging (OASIS, WS-RM) adds a protocol on top of SOAP to give delivery guarantees independent of the transport:

  • At least once: every message is delivered one or more times.
  • At most once: no message is delivered twice (duplicates are dropped).
  • Exactly once: both together.
  • In order: messages are handed to the application in the order they were sent.

It works with sequences. The sender creates a sequence (CreateSequence, answered by an id), numbers each message (wsrm:Sequence header with MessageNumber), keeps messages until the receiver acknowledges them (SequenceAcknowledgement with the ranges received), and retransmits unacknowledged messages after a timeout. The receiver drops duplicates and, if ordering is required, holds back out-of-order messages. At the end the sender closes the sequence (LastMessage, TerminateSequence).

sequenceDiagram
    participant S as Sender
    participant R as Receiver
    S->>R: CreateSequence
    R-->>S: sequence id
    S->>R: message 1
    S--xR: message 2 (lost)
    S->>R: message 3
    R-->>S: Ack (1, 3)
    S->>R: message 2 (retransmitted)
    R-->>S: Ack (1-3)
    S->>R: LastMessage, TerminateSequence

The receiver's acknowledgements tell the sender what is still missing.

Here the same protocol is simulated over a "network" that drops every first transmission of message 2 and duplicates message 3. The receiver delivers each message exactly once and in order.

Node.js Exactly-once, in-order delivery

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

After round 1, message 3 has arrived but is held back because 2 is missing (the application's list is still just debit 100); after retransmission, 2 and 3 are released in order.

Using them in practice

  • Reliable messaging is optional and policy-driven: a WS-Policy assertion in the WSDL says the service requires it (see the next lesson), and frameworks such as Apache CXF, WCF (with reliableSession) and Metro enable it with configuration.
  • It adds state on both sides and latency; many teams choose idempotent operations plus message queues (JMS, MQ) instead. Make operations safe to repeat by sending a unique request id and having the server remember processed ids.
  • WS-Addressing is far more common than WS-RM: you will see wsa: headers in many production traces even when no reliable messaging is used.

When a call may be retried, put an idempotency key (such as the WS-Addressing MessageID) in the request and make the server store results by key. Then a duplicate request returns the old answer instead of charging twice.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which WS-Addressing header tells the receiver where to send the response?

    ReplyTo holds an endpoint reference for the response. RelatesTo appears in the reply and points to the request's MessageID.
  2. 2. What is the role of wsa:RelatesTo in an asynchronous reply?

    The client matches replies to pending requests using RelatesTo.
  3. 3. Which guarantee means each message is processed exactly one time?

    Exactly-once delivery combines retransmission (at least once) with duplicate elimination (at most once).
  4. 4. What does a sender in WS-RM do with a message that is not acknowledged?

    Unacknowledged messages stay in the sender's buffer and are retransmitted.

Summary

  • WS-Addressing puts To, Action, MessageID, ReplyTo, FaultTo and RelatesTo in the SOAP header, independent of the transport.
  • Asynchronous calls use ReplyTo for the callback and RelatesTo to correlate the answer.
  • WS-ReliableMessaging numbers messages in sequences, acknowledges them and retransmits missing ones to give exactly-once, in-order delivery.
  • Many teams use queues and idempotency keys instead of WS-RM.

Next: The WS-* Standards Landscape