tags:

views:

31

answers:

1

Hi Guys,

I have a Webservice and a client to webservice.

I am using Duplex pattern.

There is a field in client called "id" which is set to some value. The client code is shown below.

string id = "foobar";
InstanceContext context = new InstanceContext(this);
CalcClient client = new CalcClient(context);

How can I access the field "id" in Webservice.

On the server side I am getting a Callback channel in the following way.

ICalcServiceCallback callback = OperationContext.Current.GetCallbackChannel<ICalcServiceCallback>();

I need to access "id" in the server.

Thanks,

A: 

Hi, not sure if that's possible, and the WCF duplex service is certainly not designed to do this!

You could define a new operation contract in your callback contract which returns the ID string, though the callback contract is intended as a way for the server to notify the client certain event has happened as a way to implement eventing with WCF, e.g. client subscribes to the server, and the server periodically publishes an update to the client.

It's for this reason that most callback operations are set to be one-way only. Have a read through on this MSDN article, it's a bit old but still relevant and tells you everything you need to know about duplex service in WCF.

http://msdn.microsoft.com/en-us/magazine/cc163537.aspx

theburningmonk