You are designing an n-tier solution for use by multiple groups of users. The solution consists of a client application that collects information from users and transmits it to a business layer for processing. The business layer sends the information to a service layer by using Windows Communication Foundation (WCF). The service layer exists on multiple servers.
The solution must send the collected information to a specific server in the service layer based on the user’s group.
You need to recommend an approach that will allow the information to be sent to the correct server.
What should you recommend?
A. Impersonate the client in the business layer.
B. Implement a duplex contract on the service layer.
C. Create a Windows Workflow Foundation (WF) activity on the client.
D. Implement the WCF 4 Routing Service.
Correct Answer: D
Explanation/Reference:
Explanation: D
Routing service in context mode can give you what you want: see explanation. Routing Service can also be context or content.
Explanation/Reference:
You can use WCF routing to create a layer of abstraction between service layers. With WCF routing, you can create a single interface that sends requests to one of several different web services. You also can use routing to convert between different communication standards and data formats and to provide an Internet interface for intranet services. Figure 1-2 illustrates WCF routing.
Just like every website is identified by a unique URL, all web services use context-based routing. When you use context-based routing, you identify a service endpoint using a unique host name/IP address, Transfer Control Protocol (TCP) or User Datagram Protocol (UDP) port For example, identifying a service with the URL http://contoso.com/myservice.asmx is context-based routing, and Microsoft Internet Information Services (IIS) would use the URL to distinguish requests from web services located at http://contoso.com/myotherservice.asmx or http://contoso.com:8080/myservice.asmx.
Content-based routing identifies a service by looking within a message. When you use content-based routing, you identify a service endpoint using specific method and parameter values. For example, imagine a web service that processes transactions for three different credit card companies. The content-based router could examine the message to determine which credit card company should process the transaction, and then forward the message to the appropriate service.
Responses would be routed through the routing service as well.
Content-based routing is typically transparent to the client.