?

Log in

Previous Entry | Next Entry

In case you fresher to WCF start with www.questpond.com  video on WCF from



This is a message exchange pattern where both client and server have the ability to send messages to each other.
In Duplex communication Client connects to a service and provides the service with a channel using which server can send messages back to client.

How it works?

In order to make this work we need a pair of interfaces,

  • First interface will be your service contract which contains operation contracts which client can invoke.

  • Second interface contain operations which will act as a call back method for server. In simple words, contain methods which can be invoked by server.

How server contract come to know about Callback interface?

In the service contract attribute we specify the callback interface as follows.

[ServiceContract(CallbackContract=typeof(IClientCallback))]

What about the client? I mean, after client implement the interface how it provide the actual instance?

It can be done via overloaded version of proxy class created at client side.

public class ClientCallBack : IClientCallback
{…..
 

InstanceContext instanceContext = new InstanceContext(new ClientCallBack ());

// Create a client
MyServiceClient client = new MyServiceClient (instanceContext);
 

At Server side, how callback methods will be accessed?

Using OperationContext class as follows,

OperationContext.Current.GetCallbackChannel<IClientCallback>().CallBackMethod();

Copy right www.questpond.com

Buy 600+ Real Time Interview Videos

Call +91-22-66752917 or mail us on questpond@questpond.com for more details on C#, .NET, ASP.NET, SQL Server interview question videos.

SQL Server interview question videos

Latest Month

January 2017
S M T W T F S
1234567
891011121314
15161718192021
22232425262728
293031    

Tags

Powered by LiveJournal.com