WCF Routing Service Filter Generator

Posted by Michael Stephenson on Geeks with Blogs See other posts from Geeks with Blogs or by Michael Stephenson
Published on Wed, 10 Oct 2012 22:01:29 GMT Indexed on 2012/10/11 9:38 UTC
Read the original article Hit count: 199

Filed under:

Recently I've been working with the WCF routing service and in our case we were simply routing based on the SOAP Action. This is a pretty good approach for a standard redirection of the message when all messages matching a SOAP Action will go to the same endpoint. Using the SOAP Action also lets you be specific about which methods you expose via the router.

One of the things which was a pain was the number of routing rules I needed to create because we were routing for a lot of different methods. I could have explored the option of using a regular expression to match the message to its routing but I wanted to be very specific about what's routed and not risk exposing methods I shouldn't via the router. I decided to put together a little spreadsheet so that I can generate part of the configuration I would need to put in the configuration file rather than have to type this by hand.

To show how this works download the spreadsheet from the following url:

https://s3.amazonaws.com/CSCBlogSamples/WCF+Routing+Generator.xlsx

In the spreadsheet you will see that the squares in green are the ones which you need to amend. In the below picture you can see that you specify a prefix and suffix for the filter name. The core namespace from the web service your generating routing rules for and the WCF endpoint name which you want to route to.

In column A you will see the green cells where you add the list of method names which you want to include routing rules for. The spreadsheet will workout what the full SOAP Action would be then the name you will use for that filter in your WCF Routing filters.

In column D the spreadsheet will have generated the XML snippet which you can add to the routing filters section in your configuration file.

In column E the spreadsheet will have created the XML snippet which you can add to the routing table to send messages matching each filter to the appropriate WCF client endpoint to forward the message to the required destination.

Hopefully you can see that with this spreadsheet it would be very easy to produce accurate XML for the WCF Routing configuration if you had a large number of routing rules. If you had additional methods in other services you can simply copy the worksheet and add multiple copies to the Excel workbook. One worksheet per service would work well.

 

 

© Geeks with Blogs or respective owner