WCF Router: One-way and Request-Response

To prepare my exam 70-513, I found the following questions:

The Windows Communication Foundation (WCF) service implements a one-way and request-response contract. The service is displayed over TCP transport. Customers use a router to communicate with the service. The router is implemented as follows. (Line numbers are included for reference only.)

01 ServiceHost host = new ServiceHost(typeof(RoutingService)); 02 host.AddServiceEndpoint ( 03 typeof(ISimplexDatagramRouter), 04 new NetTcpBinding(), "net.tcp://localhost/Router" 05 ); 06 List<ServiceEndpoint> lep = new List<ServiceEndpoint>(); 07 lep.Add ( 08 new ServiceEndpoint ( 09 ContractDescription.GetContract( 10 typeof(ISimplexDatagramRouter) 11 ), 12 new NetTcpBinding(), 13 new EndpointAddress("net.tcp://localhost:8080/Logger") 14 ) 15 ); 16 RoutingConfiguration rc = new RoutingConfiguration(); 17 rc.FilterTable.Add(new MatchAllMessageFilter(), lep); 18 host.Description.Behaviors.Add(new RoutingBehavior(rc)); 

The request-response operation does not work. You need to make sure that the router can handle one-way and response requests. What should you do?

  • A. Change line 03 as follows

    TypeOf ((IRequestReplyRouter)

  • B. Change line 03 as follows

    TypeOf ((IDuplexSessionRouter)

  • S Change line 10 as follows

    TypeOf ((IRequestReplyRouter)

  • D Change line 10 as follows

    TypeOf ((IDuplexSessionRouter)

They say that the correct answer is B , but I cannot understand (and I need to understand :)). I would answer answer A , since there are no callback methods, we don’t need to have a DuplexSessionRouter, no? And then should IRequestReply be enough?

What am I missing?

+1
source share
1 answer

The routing service uses contracts that define the shape of the channels used to receive and send messages, and therefore the shape of the input channel must match the shape of the output channel.

So, if you are routing to endpoints using the request-response channel form, then you should use a compatible contract on incoming endpoints, such as IRequestReplyRouter.

This means that if destination endpoints use contracts with multiple communication patterns (for example, mixing one-way and two-way operations), you cannot create one service endpoint that can receive and forward messages to all of them. A workaround is to use a duplex contract in a routing service such as IDuplexSessionRouter.

Literature:

http://msdn.microsoft.com/en-us/magazine/cc546553.aspx

http://msdn.microsoft.com/en-us/library/ee517422.aspx

+5
source

Source: https://habr.com/ru/post/897566/


All Articles