This project is read-only.

REST and WCF, with ServiceRoute

Topics: Web Api
Feb 25, 2011 at 11:57 PM


I have a rest style web-page with many WCF services.  I would like to keep the REST architecture through the service url's...I am really now sure how to do this.

I currently have 2 services, one for ItemA and one for ItemB.  ItemA is a container for a bunch of ItemB elements....

You could think of ItemA as a Container (which there are many types), and ItemB as the indivigual objects within a container.

So now, I want to may my Services to this style, so in order to get my ItemA's(Containers), it's simple....

I would do something like the following.... RouteTable.Routes.Add(new ServiceRoute(string.format("ItemA.svc", ItemA);

But now the problem is when I need to define the RouteTables for ItemB, because it needs to be of the following...



I have no clue how to define a variable path for a ServiceRoute.

I am also not sure how I would go about overriding the behaviour of ServiceRoute.

Anyone have some idea's?



Feb 25, 2011 at 11:59 PM


I really want to keep these are two services.

I need to figure out how to map these URI's to the correct service.

Feb 28, 2011 at 3:33 PM

Hi stringa,

Can you explain this snipet you provided? RouteTable.Routes.Add(new ServiceRoute(string.format("ItemA.svc", ItemA);

Also if you could show a few samples of complete urls and complete routing you are trying to achieve it would be useful. FYI I was able to extend the ServiceRoute to accept a RegEx instead of a "prefix", but it didn't work in my case.



Mar 1, 2011 at 7:36 PM

This might help

Mar 12, 2011 at 7:16 PM

I would be interested in extending ServiceRoute to use Regular Expressions?


Are there any good examples of this?