3.3 Example 3 (WCF): Reliable Messaging with TCP as Transport

This example illustrates how reliable messaging can be used in Windows Communication Foundation (WCF). This example describes the main scenario of the Use a Web Service with Reliable Messaging use case.

The code example shows that the following interface is used to establish the service contract.

 public interface IMessage
     void Message1();
     void Message2();

The user is required to add the following configuration entries to enable reliable messaging over TCP.

       <service name="<ServiceName>" >
                <add baseAddress="net.tcp://<ServerName>:<Port>/service"/>
          <endpoint address=""
                    contract="IMessage" />
          <!-- Configure a CustomBinding that supports tcp transport
               and text encoding -->
          <binding name="TcpBinding">
          <!--  This will enable the WS Reliable messaging  -->
             <reliableSession flowControlEnabled ="false"/>
             <textMessageEncoding messageVersion="Soap12WSAddressing10"/>

The user sends two messages and finally a third message with the <LastMessage> element tag.

The .NET Message Framing Protocol ([MC-NMF]) is used to frame the SOAP messages over TCP. This example focuses on SOAP messages, which are sent by using [MC-NMF] messages to frame them, as follows:

The Initiator and Receiver exchange a set of Preamble messages, as described in [MC-NMF] sections and After a session is established by using Preamble messages, the Initiator and Receiver send and receive SOAP messages, as described in [MC-NMF] sections,,, and After the message exchange is complete, the Initiator and Receiver close the session by sending an End Record message, as described in [MC-NMF] section and