WS-ReliableMessaging interoperability between Microsoft WCF and Sun WSIT

As promised I am going to start blogging about the different Web Services interoperability scenarios I represented as part of my session at SOAWorld 2007. I’ve decided to start with a WS-ReliableMessaging scenario interoperability between Windows Communication Foundation (WCF) and Sun Project Tango (WSIT). The complete source code of this example can be downloaded from here. WS-ReliableMessaging (WS-RM) proposes a model based on SOAP messaging to achieve reliable communication between a service and its consumers. Although OASIS recently announced the version 1.1 the current implementations on .NET and Java environments are based on the previous version. As of today, technologies such as Microsoft WCF, BEA WebLogic, Sun WSIT, IBM WebSphere among others provides WS-RM implementations based on SOAP 1.1 and 1.2. However, similarly to other complex WS-* protocols, WS-RM interoperability represents a complex challenge that needs to be addressed in order to promote a wide adoption of this protocol. As I mentioned before there are several vendors that implement WS-RM Feb 2005. For the purposes of this sample I’ve decided to use Sun WSIT as the service provider and Microsoft WCF as the service consumer.

Show me the code!!

Implementing the WSIT service

Creating a Web Service using Sun WSIT is very similar to creating a Java class with a few annotations. The following code illustrated the WSIT service used as part of this demo. Just for this time, I’ve decided to give my readers a break and not implement a calculator so I went with the second most popular service contract in history.

public class EchoWS
    public String Echo(String msg)
        return msg;
 In order to add WS-RM capabilities to the service we have to configure a couple of sections in the Web Service configuration file.
 xmlns:soap="" name="EchoWSService" targetNamespace="http://ws/" xmlns:tns="http://ws/" xmlns:wsp="" xmlns:wsu="" xmlns:wsaws="" xmlns:wsrm="" xmlns:sunrm=""
Other WSDL elements...
<service name="EchoWSService">
<wsdl:port name="EchoWSPort" binding="tns:EchoWSPortBinding"/>
<wsp:Policy wsu:Id="EchoWSPortBindingPolicy">
         <wsaws:UsingAddressing xmlns:wsaws=""/>


Implementing a WCF client

The first step for implementing a WCF client for the service created on the previous section is generating a WCF proxy using the svcutil.exe tool. After that, we can create the client logic as its showed in the following code.
private static void Test()
SimpleWSClient proxy = new SimpleWSClient();
Console.WriteLine(proxy.Echo("simple message 1"));
Finally we need to configure the client for supporting WS-RM. This is done adding the reliablesession section to the application configuration file. In order to achieve interoperability with Sun WSIT we’ve decided to rely on WS-Addressing 1.1.
<binding name="SimpleWSPortBinding">
<reliableSession maxPendingChannels="4" maxRetryCount="8" ordered="true" />
<!--Soap11WSAddressing10 encoding-->
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap11WSAddressing10" writeEncoding="utf-8" />
Other configuration elements....
<endpoint address="http://wsitserver/EchoWSService?WSDL"
binding="customBinding" bindingConfiguration="SimpleWSPortBinding"
contract="SimpleWS" name="SimpleWSPort" />

Show me the messages!!

After deploying the service (we are using Sun Glassfish as the application server) and running the client the following SOAP message sequence is produced.  The first message, originated by WCF, requests the creation of a WS-RM sequence to group the messages that are going to be exchanged between the WCF client and the WSIT service.
<s:Envelope xmlns:s="" xmlns:a="">
<a:Action s:mustUnderstand="1"></a:Action>
<a:To s:mustUnderstand="1">http://localhost:8080/WSApplication/EchoWSService?WSDL</a:To>
<CreateSequence xmlns="">

WS-RM Create Sequence message request

After receiving this message the WSIT engine replies with a sequence identifier.
<S:Envelope xmlns:S="">
<To xmlns=""></To>
<Action xmlns="">
<MessageID xmlns="">uuid:3b34e870-f77b-4e81-803a-0fdaf7a03bd5</MessageID>
<RelatesTo xmlns="">urn:uuid:c94288be-8c5e-450c-b5c1-9afa3dad727b</RelatesTo>
<ns2:CreateSequenceResponse xmlns:ns6="" xmlns:ns5="" xmlns:ns4="" xmlns:ns3="" xmlns:ns2="">

WS-RM Create Sequence response message

Now the WCF client produces the first message to invoke the Echo operation. The message is sent under the WS-RM session previously created and it is identified by a sequence number.
<s:Envelope xmlns:s="" xmlns:r="" xmlns:a="">
<r:Sequence s:mustUnderstand="1">

<a:Action s:mustUnderstand="1">Echo</a:Action>
<a:To s:mustUnderstand="1">http://localhost:8080/WSApplication/EchoWSService?WSDL</a:To>
<Echo xmlns="http://ws/" xmlns:i="">
<arg0 xmlns="">simple message 1</arg0>


WS-RM Echo request

Finally the WSIT service produces the Echo response together with the acknowledgement for the Echo request.
<S:Envelope xmlns:S="">
<To xmlns=""></To>
<Action xmlns="">http://ws/EchoWS/EchoResponse</Action>
<MessageID xmlns="">uuid:2e5673ab-aa45-495b-9711-51a7f77cd389</MessageID>
<RelatesTo xmlns="">urn:uuid:d08a30f1-2364-4823-b7e7-af6f0eb8ebc1</RelatesTo>
<ns2:Sequence xmlns:ns4="" xmlns:ns3="" xmlns:ns2="">

<ns2:AckRequested xmlns:ns4="" xmlns:ns3="" xmlns:ns2="">
<ns2:SequenceAcknowledgement xmlns:ns4="" xmlns:ns3="" xmlns:ns2="">
<ns2:AcknowledgementRange Upper="1" Lower="1"></ns2:AcknowledgementRange>

<ns2:EchoResponse xmlns:ns2="http://ws/">
<return>simple message 1</return>

WS-RM Echo response and sequence acknowledgment message

Well, I hope that looked simple enough for illustrating a very complex WS interoperability problem. Obviously, real world enterprise service present complex message exchange patterns that require a careful design of the WS-RM sequences and acknowledgements.
One of the things I want to highlight is that although WS-RM represents the best Standard to exchange message in a reliable manner it is JUST NOT ENOUGH!! for real enterprise SOA scenarios. Other factors such as durable services, durable messaging, SLAs agreements among others need to be taken into consideration when comes to designing truly reliable services.

Where are we?

WS-RM is the most widely adopted protocol for achieving reliable communications between services and consumers. Although achieving WS-RM interoperability is challenging is different achievable with the current state of the WS-RM implementations. This article has showed how to achieve WS-RM interoperability between Sun WSIT and Microsoft WCF.

No Comments