Operations:
The object or component- oriented programming model offered only single way for client to call a method. Client will issue a call, block while the call was in progress, and continue executing once the method returned.
The WCF will support:
1. Request-Replay
2. One-Way
3. Call back
1. Request-Reply:
By default all WCF will operated in the Request-Replay mode. It means that, when client make a request to the WCF service and client will wait to get response from service (till receiveTimeout).
Apart from NetPeerTcpBinding and the NetMsmqBinding all other bindings will support request-reply operations.
2. One-Way
In One-Way operation mode, client will send a request to the server and does not care whether it is success or failure of service execution. There is no return from the server side, it is one-way communication.
Client will be blocked only for a moment till it dispatches its call to service. If any exception thrown by service will not reach the server.
One-way operation can be enabled by setting IsOneWay property to true in Operation contract attribute.
[ServiceContract]
public interface IMyService
{
[OperationContract(IsOneWay=true)]
void MyMethod(EmployeeDetails emp);
}
One-Way Operations and Sessionful Services:
Let us see the example, what will happen when you use the one-way communication with Sessionful service.
[ServiceContract(SessionMode = SessionMode.Required)]
interface IMyContract
{
[OperationContract(IsOneWay = true)]
void MyMethod();
}
[ServiceContract(SessionMode = SessionMode.Required)]
interface IMyContract
{
[OperationContract]
void MyMethod1();
[OperationContract]
string MyMethod2();
[OperationContract(IsOneWay = true, IsInitiating = false,
IsTerminating = true)]
string CloseSessionService(int id);
}
3. Call back:
Till now we have seen that the all clients will call the service to get the things done. But WCF also provides the service to call the client. In which, service will act as client and client will act as service.
- HTTP protocols are connectionless nature, so it is not supported for callback operation. So BasicHttpBinding and WSHttpBinding cannot be used for this operation.
- WCF support WSDualHttpBinding for call back operation.
- All TCP and IPC protocols support Duplex communication. So all these binding will be used for callback operation.
The below code snippet of the server service and client and explanation for the same
No comments:
Post a Comment
Please Give Your Valuable Comments on this Topic