4.2.1 Establishing Context Using HTTP
A client establishes context with a server by sending the server a Client Context Initiating Message. This message is an HTTP request message [RFC2616] that does not contain an HTTP Client Message Header.
-
POST /ShoppingCart/ HTTP/1.1 Content-Type: application/xml; charset=utf-8 Host: machine2.example.org Content-Length: 87 Expect: 100-continue Connection: Keep-Alive <Create xmlns="http://machine1.example.org/Sample"><customerId>15</customerId></Create>
When the server receives this message, it invokes a business logic function according to its rules for processing HTTP messages. This function creates a new shopping cart resource, associates it with a new context identifier, and creates a response message. The context identifier has a single pair (property name, property value).
|
Property name |
Property value |
|---|---|
|
instanceId |
0b29289f-45b0-4d37-9c40-6a481945477a |
The server then transforms the response message into a Server Context Establishing Message by adding an HTTP Server Message Header and sends it to the client. This header is isomorphic to the context identifier that is associated with the shopping cart.
-
HTTP/1.1 200 OK Content-Length: 60 Content-Type: application/xml; charset=utf-8 Server: Microsoft-HTTPAPI/2.0 Set-Cookie: WscContext="77u/PENvbnRleHQgeG1sbnM9Imh0dHA6Ly9zY2hlbWFzLm1pY 3Jvc29mdC5jb20vd3MvMjAwNi8wNS9jb250ZXh0Ij48UHJvcGVydHkgbmFtZT0iaW5zdGFuY2 VJZCI+ODIxOWQ2NjItYTAzMi00YzA4LWFjZWItNzZiN2ZmYWYzNTAyPC9Qcm9wZXJ0eT48L0N vbnRleHQ+";Path=/ShoppingCart/ Date: Thu, 21 Feb 2008 22:01:38 GMT <CreateResponse xmlns="http://machine1.example.org/Sample"/>
When the client receives the Server Context Establishing Message, it creates a context identifier that is isomorphic to the HTTP Server Message Header and stores it.