Showing posts with label duplex message exchange patter in wcf. Show all posts
Showing posts with label duplex message exchange patter in wcf. Show all posts

Tuesday, 8 October 2013

Duplex Message Exchange Pattern in WCF with Example

Duplex Message Exchange Pattern in WCF

Duplex message exchange pattern is a way in WCF in which client and service both can send messages to each other independently. Duplex message exchange pattern also known as callback.

As both client and service need to be connected to exchange messages this patter is quite complicated and slower than other message exchange pattern.
To implement the duplex we have to create the separate interface and we have to create method which can be either request-reply or one way type.

Following are the steps to implement duplex service in wcf:-

Step 1:-

Open the visual studio->File->New->Website->WcfService

Step 2:-

Create interface which you use to call back from service to the client:-

[ServiceContract]
public interface IDuplexCheck
{
    [OperationContract(IsOneWay=true)]
    void showstatus(string res);

}

Step 3:-

Create the interface for the service in which you define your operation:-

[ServiceContract(CallbackContract=typeof(IDuplexCheck))]

public interface IService
{

    //IsOneWay=False represents the duplex communication
    [OperationContract(IsOneWay=false)]
   
    void dataupdated();
}