Click below for Step by Step and Interview Q & A (dotnetinter) wrote,
Click below for Step by Step and Interview Q & A
dotnetinter

Explain WCF Duplex services? ( WCF Interview questions)

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();

Tags: csharp interview questions, it interview questions with answers, programming interview questions, wcf duplex interview questions, wcf interview questions, wcf(windows communication foundation)
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments