Tuesday, May 22, 2012

WCF-Request-Reply Operations

Request-Reply Operations 

Request-reply communication mean when client send request to service, It expect reply from service It is a special form of two-way communication where there is exactly one reply for each request, and it is always initiated by the client. It also mean that there is no further client execution take place until response received from service so after the client sends a request, it must wait for a response before it can send another request.
A common use of request-reply communication is an HTTP request from a browser is an exampleThe browser makes an HTTP request to the server, such as GET or POST, the server processes that request, and then a reply is sent back.WCF handles request-reply communication using the IRequestChannel and IReplyChannel.

Even if the method returns no reply WITH void the infrastructure creates and sends an empty message to the CLIENT. To prevent the sending of an empty reply message, use a one-way contract for the operation.
There are two methods to create request reply communication
1 . Make IsOneway parameter in operational contract FALSE
        [OperationContract(IsOneWay = false)]
        void Multiply(int i, int j);

2 . Do not include isOneWay attribute
  
                 [OperationContract]
        void Multiply(int i, int j);

Apart from NetPeerTcpBinding and the NetMsmqBinding all other bindings will support request-reply operations.

1 comment :

  1. Thanks lavi, excellent articles from wcf. thank you very much. its very understandable and easy to learn. Expecting more articles from you.

    ReplyDelete