Introduction
Routing Service is an intermediary between the client and the back-end services. It has the ability to receive messages from clients and route them to the appropriate service, based on the message content. The client needs not to have the multiple endpoints, whereas the routing service has the aggregation of various service endpoints, and the messages will be routed based on the message content. If you are not familiar with the Routing basics, you can refer to my last article “Basics of WCF Routing”. This topic will help you understand the Routing Service configuration. Moreover, it also tells how filters are applied to route the back-end service, based on the message content.
Architecture
To configure the Routing, one has to configure the following components -
- Routing Service
- Contracts
- Service Behaviour
- Filters
- Endpoint
Before you know how to configure these components, let’s first understand what exactly the purpose is of configuring each component.
Routing Service
Routing service is implemented as a WCF service in the System.ServiceModel.Routing assembly. It’s already available in the WCF to route messages over any protocol, using a different message exchanging patterns like one way, two way, Request-Response and duplex messaging. We only need to define the name, address, binding, and contract according to our requirements.
Contracts
Service contract of Routing service supports different Message Exchange Patterns (MEPs), like request-reply, duplex session, and simplex session channels. These Interfaces are required to process the messages from channels.
| Contract | Description |
| IDuplexSessionRouter | Defines the interface required to process messages from duplex session channels |
| IRequestReplyRouter | Defines the interface required to process messages from request-reply channels. |
| ISimplexDatagramRouter | Defines the interface required for processing messages from simplex datagram. |
| ISimplexSessionRouter | Defines the interface required to process messages from simplex session channels |
Filter
The Job of the Message Filter is to inspect specific sections of a message, such as - address, endpoint. To send the message to the desired endpoint, the incoming message should match the filters applied.
FilterTable
Once the filters are matched with filter data in the earlier step, here we are associating the filter with the endpoint name.
Endpoint
Endpoints are used for associating the address and binding with the endpoint name. The Routing service refers the address with the associated endpoint and routes the messages accordingly.
Routing Configuration
So far, we have seen what are all the components required and why these are required to configure Routing . Now, I am going to explain to you in detail, the steps involved in configuring the simple routing.

In the above diagram, you can find that Client always connects to the Front-end service. Then, front-end service will inspect the message content and route the messages to the Food Inventory service or Materials inventory service, based on the message content it receives from the client. To accomplish this configuration, let me explain to you in detail-
Step 1 - Let’s start with configuring back-end services first. I would recommend you guys to configure and host the back-end services in IIS. As soon as the IIS gets started, these services will also get started automatically, unlike the self hosting where we have to start it manually. First, create the Food Inventory Service Library and do the IIS hosting. If you need assistance in creating IIS hosting, please refer my old article (http://www.c-sharpcorner.com/article/iis-hosting-in-wcf/). We don’t have any complex configuration in back-end service. In the below snapshot, you can see the snapshot of my Food Inventory configuration for your reference

Hope you have done the IIS hosting for Food Inventory. Once you are done with it, we will go for creating a Materials Inventory Service.
Step 2 - In step 2, you have to repeat the same steps (what you have done for Food Inventory) to the Material Inventory. Create the Material Inventory Service and host it in the IIS. In the below snapshot, you can see the Materials Inventory Service configuration, for your reference. So far, you are not able to find a single configuration in Routing. All the routing configuration will happen only on the next step i.e on Front-end service or Main Service.

Step 3 - Step 3 is the most important configuration in the Routing. As I mentioned in the architecture section here, we need to configure the following in the Front-end service







Dewesh PushkarPosted Apr 3, 2019, 4:54 AM
How can we host wcf lib(Main routing Service) project on IIS, as it has no svc file. could you please share step by step process and how to test it?
Dewesh PushkarPosted Apr 3, 2019, 4:36 AM
How can we host wcf lib(Main routing Service) project on IIS
Prasanna MuraliPosted Oct 9, 2016, 9:43 AM
Nice post..