I hope most of you must have already started exploring WCF 4.0. Microsoft recently released Visual Studio 2010 RC and you can download it from here. With WCF 4.0 on .NET 4.0, new features have been introduced for application development. Routing provides the mechanism of isolating one or more WCF services directly accessible from the client application. Client application have knowledge of only one WCF service which further routes call from the client to the specific WCF service, based upon filters. The architecture can be described as shown below:
In the setup shown above, the client connects to WCF Routing services hosted on ‘220.127.116.11’, and then based upon filters passed by the client, the request is navigated to the concerned web service. I have already posted an article earlier on this topic which is based on WCF 4.0 Beta 1.
In this article I will be posting only the App.Config file of the routing service which is as shown below:
<!--The Router Table Contains Entries for services-->
<!--Define Services Here-->
<!--Filter For Detecting Messages Headers to redirect-->
<!--Define Routing Table, This will Map the service with Filter-->
The Address provided under the <client> tag, are WCF services, where the routing service will route request from the client application.
Code in the host application is as below:
static void Main(string args)
ServiceHost Host = new ServiceHost(typeof(RoutingService));
Console.WriteLine("Routing Service is Started...............");
catch (Exception ex)
Shared Sub Main(ByVal args() As String)
Dim Host As New ServiceHost(GetType(RoutingService))
Console.WriteLine("Routing Service is Started...............")
Catch ex As Exception
On the client application side, write the following configuration:
Note: The client application must have the knowledge of WCF services to which it needs to send requests. The entire source code of this article can be downloaded over here
Conclusion: The Routing mechanism WCF 4.0 provides an excellent feature for developing SOA based application. Now the client application is free to send request to any WCF service based upon filters.
This article has been editorially reviewed by Suprotim Agarwal.
C# and .NET have been around for a very long time, but their constant growth means there’s always more to learn.
We at DotNetCurry are very excited to announce The Absolutely Awesome Book on C# and .NET. This is a 500 pages concise technical eBook available in PDF, ePub (iPad), and Mobi (Kindle).
Organized around concepts, this Book aims to provide a concise, yet solid foundation in C# and .NET, covering C# 6.0, C# 7.0 and .NET Core, with chapters on the latest .NET Core 3.0, .NET Standard and C# 8.0 (final release) too. Use these concepts to deepen your existing knowledge of C# and .NET, to have a solid grasp of the latest in C# and .NET OR to crack your next .NET Interview.
Click here to Explore the Table of Contents or Download Sample Chapters!