Duplex
Duplex is a Two-Way Communication Process. In which, a consumer send a message to the service and the service sends a notification that the request processing has been done. It is just like that we send some command about the printing of some papers to the Printer machine. The printer machine start communication by making the connection with our machine, and start printing the paper.
- Duplex service allows calling back some operation (function) on the client.
- Duplex service also knows as Call Backs.
- All Binding does not support duplex service.
- Duplex communication is not standard. They are absolute Microsoft feature.
- wsDualHttpBinding supports duplex communication over HTTP binding.
- Duplex communication is possible over netTcpBinding and netNamedPipeBinding
- [ServiceContract(CallbackContract = typeof (DuplexServiceCallback))]
- public interface IMyService
- {
- [OperationContract(IsOneWay = true)]
- void AddName(string name);
- [OperationContract]
- string GetName(string name);
- }
Message Exchange Patterns in WCF:
The Message Exchange Pattern (MEP) provides a way of communication between client and server. MEP is a beauty of WCF. A services do some task depend on us or send a response to our request. The communication between client and server are done in form of messages. When we send a message as request and get a message as response from the service. The WCF Services support three types of Message Exchange Pattern:
- Request-Response
- One-Way
- Duplex
Why we need the Message Exchange Pattern:
- When we want the calling of the function to not take more time.
- We just want to call the function and not want wait for the response.
- When we want that function call is not blocking and at the same time we want something out of the function (response) for our application.
- When we want a two-way communication mechanism.