4.1.4 Establish a Callback Context

To enable duplex communication with the server, the client sends another Context Participating Message to the server (as in section 4.1.2) that is also a Callback Context Establishing Message.

The client invokes a business logic function that creates a new customer resource and associates it with a new context identifier. The context identifier has a single pair (property name, property value).

Property name

Property value

instanceId

c4b4e186-a5eb-4a8c-9f64-f8bb099e84eb

The client adds a CALLBACK_CONTEXT_XML element as a SOAP header to the message to specify the endpoint reference to which to send callback messages. The endpoint reference also contains a context identifier for the client.

 <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" 
 xmlns:a="http://www.w3.org/2005/08/addressing">
 <s:Header>
 <a:Action 
 s:mustUnderstand="1">http://machine1.example.org/Sample/IShoppingCart/Purchase</a:Action>
 <a:MessageID>urn:uuid:31d9ce06-a90b-4d81-9a0b-b1b8eaf67b28</a:MessageID>
 <a:ReplyTo>
 <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
 </a:ReplyTo>
 <Context xmlns="http://schemas.microsoft.com/ws/2006/05/context">
 <Property name="instanceId">1a1913b1-cb24-4d94-91d2-cf414a569481</Property>
 </Context>
 <CallbackContext xmlns="http://schemas.microsoft.com/ws/2008/02/context">
 <CallbackEndpointReference>
 <a:Address>http://machine3.example.org</a:Address>
 <a:ReferenceParameters>
 <Context xmlns="http://schemas.microsoft.com/ws/2006/05/context">
 <Property name="instanceId">c4b4e186-a5eb-4a8c-9f64-f8bb099e84eb</Property>
 </Context>
 <a:ReferenceParameters>
 </CallbackEndpointReference>
 </CallbackContext>
 <a:To s:mustUnderstand="1">http://machine2.example.org/ShoppingCart</a:To>
 </s:Header>
 <s:Body>
 <Purchase xmlns="http://machine1.example.org/Sample">
 <customerId>571</customerId>
 </Purchase>
 </s:Body>
 </s:Envelope>
  

When the server receives the Server Context Establishing Message, it creates an endpoint reference that is isomorphic to the endpoint reference in the CALLBACK_CONTEXT_XML element from the SOAP message and stores it.

The client then closes the connection with the server.