WSE Support for Reliable Messaging


In version 2.0, WSE supports the WS-Addressing specification, but WS-ReliableMessaging is not yet supported. WSE support for WS-Addressing consists of a set of input and output message filters that read and write the SOAP headers defined in WS-Addressing. WSE automatically adds the appropriate addressing headers to all outgoing SOAP messages. In addition, WSE provides a full API for programmatically creating and accessing addressing objects, and you can explicitly define the addressing objects for outgoing messages to override the values that are automatically generated by WSE.

Creating Custom Address Headers

One of the things that you can do with WSE is to explicitly define the ReplyTo and FaultTo headers in an outbound message. This lets you redirect this type of response message to a different endpoint than the one from which the request was originally sent. When using the WSE, this can be accomplished programmatically by instantiating both a ReplyTo and a FaultTo object in the Microsoft.Web.Services.Addressing namespace, defining appropriate address URI values for each, and adding them to the SoapContext for the outgoing message, as in the following example:

 // Create a new SoapContext for the request message 
SoapContext myContext = myService.RequestSoapContext;

// Define a different reply address for the request
ReplyTo replyAddress = new ReplyTo(new
Uri("http://example.com/DocumentService/ResponseHandler.asmx"));

// Define a reply address for fault messages
FaultTo faultAddress = new FaultTo(new
Uri("http://example.com/DocumentService/FaultHandler.asmx"));

// Add the custom ReplyTo and FaultTo addressing headers to the SoapContext
myContext.Addressing.ReplyTo = replyAddress;
myContext.Addressing.FaultTo = faultAddress;

// Security headers added here

// Call the GetDocument method
myService.GetDocument(docID);

Based on this code, WSE generates the following SOAP request message:

 <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:wsa="http://schemas.xmlsoap.org/ws/2003/03/addressing"
xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility">
<soap:Header>
<wsa:Action
wsu:Id="Id-94388c39-0fe3-473e-8a95-679bcd75fc8a"
>http://example.com/documentservice/GetDocument</wsa:Action>
<wsa:FaultTo
wsu:Id="Id-913d1551-eeb7-424f-b2d0-53f66697798b">
<wsa:Address>
http://example.com/DocumentService/FaultHandler.asmx
</wsa:Address>
</wsa:FaultTo>
<wsa:From wsu:Id="Id-4851c756-f3a6-43be-9d71-e7d8368eb897">
<wsa:Address>
http://schemas.xmlsoap.org/ws/2003/03/addressing/role/anonymous
</wsa:Address>
</wsa:From>
<wsa:MessageID
wsu:Id="Id-012a16ac-490d-4c03-8b37-473f37faef0e"
>uuid:127ce5d7-8d06-4a02-b764-73fe61a8ab62</wsa:MessageID>
<wsa:ReplyTo wsu:Id="Id-758cb1e1-813b-4ed0-9682-91cd083fd3b1">
<wsa:Address>
http://example.com/DocumentService/ResponseHandler.asmx
</wsa:Address>
</wsa:ReplyTo>
<wsa:To
wsu:Id="Id-78733b74-d9f1-4271-b3c4-7d18ff1cc2df"
>http://localhost/documentservice/documentservice.asmx</wsa:To>
<wsu:Timestamp>
<wsu:Created
wsu:Id="Id-0b355b9c-493e-49ef-b920-eb51c6801f86"
>2003-08-15T22:58:40Z</wsu:Created>
<wsu:Expires
wsu:Id="Id-f4058af7-ee2d-4866-915c-0b759d0c5639"
>2003-08-15T23:03:40Z</wsu:Expires>
</wsu:Timestamp>

</soap:Header>
<soap:Body wsu:Id="Id-b079ec45-be0b-400e-a6a3-f0af290e70d8">
<GetDocument xmlns="http://example.com/documentservice">

</GetDocument>
</soap:Body>
</soap:Envelope>

In the same way, the values of address headers in an incoming message can be accessed by reading the relevant property from the AddressingHeaders object, which is accessed from the SoapContext.Addressing property of the incoming message.




Understanding Web Services Specifications and the WSE
Understanding Web Services Specifications and the WSE (Pro Developer)
ISBN: 0735619131
EAN: 2147483647
Year: 2006
Pages: 79

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net