Microsoft Exam Questions

Which code segment should you use?

You are creating an application that consumes a Windows Communication Foundation (WCF) service.
The service implements the IService contract. The client application contains the CallbackHandler class, which implements IServiceCallback.
You need to ensure that a client proxy is created that can communicate with the service over a duplex channel.
Which code segment should you use?

A.
var handler = new CallbackHandler();
var clientFactory = new DuplexChannelFactory<IService>(new WSHttpContextBinding());
var client = clientFactory.CreateChannel(new InstanceContext(handler), new EndpointAddress(“…”));

B.
var handler = new CallbackHandler();
var clientFactory = new DuplexChannelFactory<IService>(typeof(CallbackHandler), new WSDualHttpBinding());
var client = clientFactory.CreateChannel(new InstanceContext(handler), new EndpointAddress(“…”));

C.
var handler = new CallbackHandler();
var clientFactory = new DuplexChannelFactory<IService>(new WSHttpBinding());
var client = clientFactory.CreateChannel(new InstanceContext(handler), new EndpointAddress (“…”));

D.
var handler = new CallbackHandler();
var clientFactory = new DuplexChannelFactory<IService>(typeof(CallbackHandler), new WSDualHttpBinding());
var client = clientFactory.CreateChannel(new EndpointAddress(“…”));

Explanation:
DuplexChannelFactory<TChannel> Class
(http://msdn.microsoft.com/en-us/library/ms576164(v=vs.90).aspx)