WCF 4.0 Routing Service

Sul Aga photo
Last Updated
Aug 16, 2015


WCF Routing service was a needed solution for a while, now it is shipped with WCF 4 among other new functionalities like service discovery, better support for REST services and WCF Syndication. In this article I will focus on the WCF Routing service, what it is and where it should be used. We will be looking at the configuration needed for this type of services.

What is Routing Service?

Routing service as the name suggests, direct (Route) a service request from one service to the other and sends the response back to the caller. This kind of service behaviour is needed in cretin scenarios. It can be used if you the service offers only one type of communication protocol let’s say tcp and on the other hand the client can only receive or understand http protocol. In this case you setup a Routing service between the client and the service. This routing service will speak with the client using http and with the service using tcp. In other words it will receive the call from the client via http then forward that call to the service using tcp then get the response from the service in tcp and send it to the client in http. This is called Protocol bridging because the routing service sets as a bridge to deliver http to tcp and vice versa. Figure 1 explain protool bridging using WCF routing service.

Figure 1: Protocol Bridging

Content Based Routing

Another useful scenario for using WCF routing is Content Based Routing. In this scenario you setup a filter on the routing service to determine the destination of the call based on its content. For example, let’s say you have a client that needs to call your HR service. But the HR service might be pided into several services based on location for example London HR office and Paris HR office. Best thing to do in this scenario instead of adding all the HR references to the client is setting a WCF Routing Service which will decide where to route messages based on their content. For example if you add a property to the header of the outgoing message from the client then the routing service should be able to determine where to route this call based on the value that you specify in the message header sent from the client. You can add a custom header property to your outgoing message header like this:


Or you can decorate the property that you want to include in your header by using the following field property:

[MessageHeader(Namespace = "MyNameSpace")]
 public string MyCustomHeaderProp { get; set; }

Service Versioning

Routing is also a solution for service versioning. It is not unusual to upgrade your services by adding new services or change existing ones. When you do that then you need to consider current clients consuming your service. By adding additional property to your header message then you should be able to determine which service version this client is interested in. Have a look at Service Versioning using WCF Routing Service where you will find how I am using routing service for service versioning.

Backup List

Another useful feature of routing service is using Backup List. For every filter you specify in the Filter Table tag you can specify a Back Up list. This backup list will be called if the destination is dead or not responding. This is very useful feature for service availability which is a key point in services in which a service has to be up and running all the time. Here is an example of a Config file which is implementing service versioning and Back Up list feature.


WCF Routing Service was introduced in WCF 4.0. This type of sirveces is a solution to many scenarios that developers used to implement manually. This type of service helps in implementing Protocol Bridging, Content based routing, Service Versioning and services Backup List. Please have a look at Service Versioning using WCF Routing Service where I am using WCF Routing Service to implement WCF Service Versioning