A Windows Communication Foundation (WCF) service listens for messages at net.tcp://www.contoso.com/MyService.
It has a logical address at http://www.contoso.com/MyService. The configuration for the WCF client is as follows:
<endpoint address=”http://www.contoso.com/MyService”
binding=”netTcpBinding”
bindingConfiguraton=”NetTcpBinding_IMyService”
contract=”ServiceReference1.IMyService”
name=”NetTcpBinding_IMyService”/>
The generated configuration does not provide enough information for the client to communicate with the server.
You need to update the client so that it can communicate with the server. What should you do?
A.
In the client configuration, change the value of the address attribute to
net.tcp://www.contoso.com/MyService
B.
In the client configuration, change the value of the address attribute to
net.tcp://www.contoso.com/MyService listen=http://www.contoso.com/MyService.
C.
After instantiating the client and before invoking any service operation, add this line of code.
EndpointBehaviors.Add(new EndpointDiscoveryBehavior(){ Enabled = true });
D.
After instantiating the client and before invoking any service operation, add this line of code.
client.Endpoint.Behaviors.Add(new ClientViaBehavior(new Uri(“net.tcp://www.contoso.com/IMyService”)));
Explanation:
The ClientViaBehavior is used by clients to specify the URI for which the transport channel should be created.If such a behavior exists in the behavior collection on a client endpoint, the transport uses the URI that it provides,
while all the other channel layers in the stack use the EndpointAddress provided at ChannelFactory construction time.
This EndpointAddress also becomes the WS-Addressing To header.Use this behavior when the immediate network destination is not the intended processor of the message to enable multiple-hop
conversations when the calling application does not necessarily know the ultimate destination or when the destination Via header is not an address.You can also set this value using the <clientVia> element in a client application configuration file.
ClientViaBehavior Class
(http://msdn.microsoft.com/en-us/library/system.servicemodel.description.clientviabehavior.aspx)
D