A Windows Communication Foundation (WCF) client configuration file contains the following XML segment in the system.serviceModel element.
<client>
<endpoint address=”net.tcp://server/ContosoService”
binding=”netTcpBinding”
contract=”Contoso.IContosoService”
name=”netTcp”/>
<endpoint address=”net.pipe://localhost/ContosoService”
binding=”netNamedPipeBinding”
contract=”Contoso.IContosoService”
name=”netPipe” />
</client>
You need to create a channel factory that can send messages to the endpoint listening at net.pipe://localhost/ContosoService.
Which code segment should you use?
A.
ChannelFactory<Contoso.IContoso> factory = new ChannelFactory<Contoso.IContoso>(“Contoso.IContoso”);
B.
ChannelFactory<Contoso.IContoso> factory = new ChannelFactory<Contoso.IContoso>(“netNamedPipeBinding”);
C.
ChannelFactory<Contoso.IContoso> factory = new ChannelFactory<Contoso.IContoso>(“netPipe”);
D.
ChannelFactory<Contoso.IContoso> factory = new ChannelFactory<Contoso.IContoso>(“net.pipe//localhost/ContosoService”);
Explanation:
ChannelFactory<TChannel> Constructor .NET Framework 4
(http://msdn.microsoft.com/en-us/library/ms576132.aspx)Initializes a new instance of the ChannelFactory<TChannel> class.
ChannelFactory<TChannel> Constructors:
ChannelFactory<TChannel>() Initializes a new instance of the ChannelFactory<TChannel> class.
ChannelFactory<TChannel>(Binding) Initializes a new instance of the ChannelFactory<TChannel> class.
ChannelFactory<TChannel>(ServiceEndpoint) Initializes a new instance of the ChannelFactory<TChannel> class that produces channels with a specified endpoint.
***ChannelFactory<TChannel>(String) Initializes a new instance of the ChannelFactory<TChannel> class with a specified endpoint configuration name.
ChannelFactory<TChannel>(Type) Initializes a new instance of the ChannelFactory<TChannel> class.
ChannelFactory<TChannel>(Binding, EndpointAddress) Initializes a new instance of the ChannelFactory<TChannel> class with a specified binding and endpoint address.
ChannelFactory<TChannel>(Binding, String) Initializes a new instance of the ChannelFactory<TChannel> class with a specified binding and remote address.
ChannelFactory<TChannel>(String, EndpointAddress) Initializes a new instance of the ChannelFactory<TChannel> class associated with a specified name for the endpoint configuration and remote address.
Why is answer d incorrect ?ChannelFactory factory = new ChannelFactory(“net.pipe//localhost/ContosoService”);
Isn’t it same as ChannelFactory(ServiceEndpoint)
Question says:
endpoint address=”net.pipe://localhost/ContosoService”
Option D mentions:
ChannelFactory(“net.pipe//localhost/ContosoService”);
Colon (:) after net.pipe is missing. Some Questions are just visual puzzles.
So, The right answer is C.