When a WS-RM client talks to a WS-RM enable server there are three messages that goes between them. First the client requests the server with a WS-RM create sequence first try to create a sequence by sending a message with CreateSequence element. This is to initiate a WS-RM session and the request looks like below (note the SOAP body).
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">http://localhost:8281/services/StockQuoteProxy</wsa:To>
<wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">urn:uuid:F6BE3F51CABFB86C131305006461276</wsa:MessageID>
<wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<wsrm:CreateSequence xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
<wsrm:AcksTo>
<wsa:Address xmlns:wsa="http://www.w3.org/2005/08/addressing">http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsrm:AcksTo>
<wsrm:Offer>
<wsrm:Identifier>urn:uuid:C9C5EC706B1630B02F70948019826771537414401</wsrm:Identifier>
</wsrm:Offer>
</wsrm:CreateSequence>
</soapenv:Body>
</soapenv:Envelope>
Once the WS-RM enabled server receive this request he responds with a create sequence response which looks like below.
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:MessageID>urn:uuid:8FBBE3295CC69847831305006465945</wsa:MessageID>
<wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequenceResponse</wsa:Action>
<wsa:RelatesTo>urn:uuid:F6BE3F51CABFB86C131305006461276</wsa:RelatesTo>
</soapenv:Header>
<soapenv:Body>
<wsrm:CreateSequenceResponse xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
<wsrm:Identifier>urn:uuid:8FBBE3295CC69847831305006465893</wsrm:Identifier>
<wsrm:Accept>
<wsrm:AcksTo>
<wsa:Address xmlns:wsa="http://www.w3.org/2005/08/addressing">http://localhost:8281/services/StockQuoteProxy</wsa:Address>
</wsrm:AcksTo>
</wsrm:Accept>
</wsrm:CreateSequenceResponse>
</soapenv:Body>
</soapenv:Envelope>
Once the sequence is established, client sends the request to the server with the pre-negotiated sequence ID.
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">http://localhost:8281/services/StockQuoteProxy</wsa:To>
<wsa:FaultTo xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:FaultTo>
<wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">urn:uuid:F6BE3F51CABFB86C131305006461045</wsa:MessageID>
<wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">urn:getQuote</wsa:Action>
<wsrm:Sequence xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" soapenv:mustUnderstand="1">
<wsrm:Identifier>urn:uuid:8FBBE3295CC69847831305006465893</wsrm:Identifier>
<wsrm:MessageNumber>1</wsrm:MessageNumber>
<wsrm:LastMessage />
</wsrm:Sequence>
</soapenv:Header>
<soapenv:Body>
<m0:getQuote xmlns:m0="http://services.samples">
<m0:request>
<m0:symbol>IBM</m0:symbol>
</m0:request>
</m0:getQuote>
</soapenv:Body>
</soapenv:Envelope>
Client keeps on sending above message till the server responds with a valid response message with 200 OK HTTP header. If the server is not ready with a response, it will respond with 202 Accepted HTTP header for all requests. Once the server is ready with a response it will send the response message with sequence ID as follows.
HTTP/1.1 200 OK
Content-Type: text/xml; charset=UTF-8
Date: Tue, 10 May 2011 05:47:48 GMT
Transfer-Encoding: chunked
85a
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsa:FaultTo xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Address>http://www.w3.org/2005/08/addressing/anonymous</wsa:Address>
</wsa:FaultTo>
<wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">urn:uuid:CD6DD195597E970CCC7102452795842-1496332077</wsa:MessageID>
<wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">//services.samples/SimpleStockQuoteServicePortType/getQuoteResponse</wsa:Action>
<wsa:RelatesTo xmlns:wsa="http://www.w3.org/2005/08/addressing">urn:uuid:F6BE3F51CABFB86C131305006461045</wsa:RelatesTo>
<wsrm:Sequence xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" soapenv:mustUnderstand="1">
<wsrm:Identifier>urn:uuid:C9C5EC706B1630B02F70948019826771537414401</wsrm:Identifier>
<wsrm:MessageNumber>1</wsrm:MessageNumber>
<wsrm:LastMessage />
</wsrm:Sequence>
<wsrm:SequenceAcknowledgement xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" soapenv:mustUnderstand="0">
<wsrm:Identifier>urn:uuid:8FBBE3295CC69847831305006465893</wsrm:Identifier>
<wsrm:AcknowledgementRange Lower="1" Upper="1" />
</wsrm:SequenceAcknowledgement>
</soapenv:Header>
<soapenv:Body>
<ns:getQuoteResponse xmlns:ns="http://services.samples">
<ns:return xmlns:ax21="http://services.samples/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax21:GetQuoteResponse">
<ax21:change>-2.6700218511136207</ax21:change>
<ax21:earnings>-8.794748965262057</ax21:earnings>
<ax21:high>-187.17305566079403</ax21:high>
<ax21:last>187.8527959982049</ax21:last>
<ax21:lastTradeTimestamp>Tue May 10 11:17:47 IST 2011</ax21:lastTradeTimestamp>
<ax21:low>194.26444313628625</ax21:low>
<ax21:marketCap>4.0781086886418656E7</ax21:marketCap>
<ax21:name>IBM Company</ax21:name>
<ax21:open>196.0840596773702</ax21:open>
<ax21:peRatio>-17.81582827663666</ax21:peRatio>
<ax21:percentageChange>1.4459782819162954</ax21:percentageChange>
<ax21:prevClose>-184.65158740663455</ax21:prevClose>
<ax21:symbol>IBM</ax21:symbol>
<ax21:volume>18332</ax21:volume>
</ns:return>
</ns:getQuoteResponse>
</soapenv:Body>
</soapenv:Envelope>
Note the http status code.
Now both client and the server are done with the actual message exchange. Then client sends a request(terminate sequence) to terminate the sequence as follows:
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">http://localhost:8281/services/StockQuoteProxy</wsa:To>
<wsa:MessageID xmlns:wsa="http://www.w3.org/2005/08/addressing">urn:uuid:F6BE3F51CABFB86C131305006468790</wsa:MessageID>
<wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence</wsa:Action>
<wsrm:SequenceAcknowledgement xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm" soapenv:mustUnderstand="0">
<wsrm:Identifier>urn:uuid:C9C5EC706B1630B02F70948019826771537414401</wsrm:Identifier>
<wsrm:AcknowledgementRange Lower="1" Upper="1" />
</wsrm:SequenceAcknowledgement>
</soapenv:Header>
<soapenv:Body>
<wsrm:TerminateSequence xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
<wsrm:Identifier>urn:uuid:8FBBE3295CC69847831305006465893</wsrm:Identifier>
</wsrm:TerminateSequence>
</soapenv:Body>
</soapenv:Envelope>
Server responds to the sequence termination message, accepting to terminate the sequence as follows.
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:ReplyTo>
<wsa:Address>http://localhost:8281/services/StockQuoteProxy</wsa:Address>
</wsa:ReplyTo>
<wsa:MessageID>urn:uuid:8FBBE3295CC69847831305006472014</wsa:MessageID>
<wsa:Action>http://schemas.xmlsoap.org/ws/2005/02/rm/TerminateSequence</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<wsrm:TerminateSequence xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm">
<wsrm:Identifier>urn:uuid:C9C5EC706B1630B02F70948019826771537414401</wsrm:Identifier>
</wsrm:TerminateSequence>
</soapenv:Body>
</soapenv:Envelope>
Note that although each of above messages are separate SOAP messages, in most cases they will be exchanged in a single socket connection as HTTP Keep-Alive header is used. As you have observed these messages go between the client and the server ( and when you monitor you should see three pair of request/response).
Unlike in WS-Security case when you enable WS-RM for a web service you can't see any WS-RM specific information on the service's WSDL. When you generate clients against a WS-RM enabled service you'll have to enable the required parameters at the client code.
0 comments:
Post a Comment