tags:

views:

19

answers:

1

I have a duplex Wcf service and I'd like to get a reference to IDuplexChannel, IDuplexSessionChannel or IOutputChannel so that I can use the non-blocking BeginSend method.

On my server, inside of the handler for the initiating method I have the following (I have tried every interface that I listed in place of IOutputChannel. None of them seem to exist.)

_clientCb = OperationContext.Current.GetCallbackChannel<IDxClientCb>();
_channel = OperationContext.Current.Channel;
_duplexChannel = _channel as IOutputChannel;
Debug.Print("Service IOutputChannel null: {0}", _duplexChannel == null);

Similarly, in the client I have tried to cast the return value of DuplexChannelFactory.CreateChannel() to any of these interfaces and I always get back a null.

How do I get a reference to one of these?

+1  A: 

Why do you want to do that? If you want to do async operations, just declare your callback contract with async operations and use those instead? (see http://msdn.microsoft.com/en-us/library/ms734701.aspx)

tomasr
Well using channel.BeginSend is a viable option as mentioned here http://kennyw.com/work/indigo/286 and I also wanted access to those interfaces so that I can send raw Messages if I want to do things like using CreateBufferedCopy to serialize a message once and broadcast it to a number of clients.
wizlb
Also, my duplex contract and callback contract are all marked one-way. Is it possible to apply the async pattern to those types of messages?
wizlb
OK, I went with async operations instead although I would still like to find out how to get a reference to those interfaces.
wizlb