tl;dr
For this question, the answer is supposed to be AB. A I can understand but I can’t find any information about a standalone CreateChannnel method like it’s used in B
Can anyone explain why answer B is considered correct or is it not correct and I’m better of ditching these practice exams alltogether?
Background
I am trying to learn WCF using some practice exams. I have already encountered several questions where I’m not sure that the given answer is the correct one.
The following question, besides the obvious spelling mistakes (intetface INameService) is seriously adding to my doubts.
The question goes like this
QUESTION 21
A Windows Communication Foundation (WCF) solution uses the following
contracts. (Line numbers are included for reference only.)
01 [ServiceContract(CallbackContract=typeof(INameService))]
02 public interface IGreetingService
03 {
04 [OperationContract]
05 string GetMessage();
06 }
07
08 [ServiceContract]
09 public intetface INameService
10 {
11 [OperationContract]
12 string GetName();
13 }
When the client calls GetMessage on the service intetface, the service
calls GetName on the client callback. In the client, the class
NameService implements the callback contract.The client channel is created as follows:
22 InstanceContext callbackContext = new Instance Context(new NameService("client"));
23
24
25 DuplexChannelFactory <IGreetingService> factory =
new DuplexChannelFactory<IGreetingServices>(typeof(NameService),binding,address);
26 IGreetingService greetingService = factory.CreateChannel();
You need to ensure that the senvice callback is processed by the
instance of NameService. What are two possible ways to achieve this
goal? (Each correct answer presents a complete solution. Choose two.)
and I can choose from following answers
A.Change line 25 to the following code segment:
DuplexChannelFactory factory = new
DuplexChannelFactory(callbackContext, binding,
address);B.Change line 26 to the following code segment: IGreetingService
greetingServicefactory = CreateChannel(callbackContext);C.Add the following code segment after line 26:
callbackContextIncomingChannelsAdd((IDuplexChannel)greetingService)D.Add the following code segment after line 26:
callbackContext.OutgoingChannels.Add((IDuplexChannel)greetingService)
For this question, the answer is supposed to be AB. A I can understand but I can’t find any information about a standalone CreateChannnel method like it’s used in B
Can anyone explain why answer B is considered correct or is it not correct and I’m better of ditching these practice exams alltogether?
The answer B is a misprint. It should read: