PrepAway - Latest Free Exam Questions & Answers

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?

PrepAway - Latest Free Exam Questions & Answers

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)

8 Comments on “Which code segment should you use?

  1. Abhishek says:

    The question says “a client proxy is created that can communicate with the service over a duplex channel..”.
    CreateChannel(InstanceContext, EndpointAddress) :Creates a duplex channel between a service and a callback instance on the client.
    The correct answer is B.




    0



    0

Leave a Reply