WCF and REST

I’m on a project that was using WCF and we’ve managed to make the transition to using REST (well, to be honest so far its just POX).

REST is a joy and I really find it such a pleasant experience compared to RPC let alone WS-*.

However WCF and REST just are not good bed fellows which is a big problem. Some of the problems are that it doesn’t support linking out of the box, content negotiation isn’t there, no support for common HTTP/REST patterns, it limits the design/granularity of your resource handlers (MVC controllers), and the REST starter kit (at least when I looked at it) was appalling.

There are also lots of annoyances that you only discover when you come to use it and unfortunately, as Seb discovered when he developed our REST framework on top of WCF, WCF lacks some key extension points meaning you end up having an extremely painful time getting the functionally you need.

Anyway the point of this post isn’t to beat up on WCF, it is just to make you aware of the issues. If all you want to be able to do is a bit of simple CRUD then you might find WCF to be a good solution, however just be aware that it isn’t designed to scale out to handle more interesting problems or more RESTful solutions. I’m also not really sure it gives you much, when compared to a proper REST framework or even building on top of ASP.NET MVC.

On the plus side the WCF team did contact me and Seb and we gave feedback which apparently will feed into a release post-WCF 4. However my feeling is that if they don’t really make improvements then WCF will lose out to some of the great REST frameworks that are now appearing in .NET-land.

Related Articles:

Post Footer automatically generated by Add Post Footer Plugin for wordpress.

This entry was posted in REST, WCF. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

5 Responses to WCF and REST

  1. mob says:

    I feel your pain, we went through the same thing. I ended up writing an OSS library to fix some of the pain points in WCF REST that we were experiencing (http://wcfrestcontrib.codeplex.com/). And yes, the RSK is “appalling”. It does not encourage good RESTful design, especially the templates. Thats bad news for REST newcomers since they may follow what comes out of Redmond if they don’t know any better. And the starter kit (And the API) should be encouraging proper RESTful design.

    At least you were able to talk to the guys on the WCF REST team. I continually got put off by the two leads and finally gave up. It’s almost like they didn’t want to listen. And their responses on the Connect site to some of my issues were not very encouraging either. It really seemed like they didn’t get it. The only one who I was briefly in contact with who seemed to get it was the WCF PM, he was a really sharp guy.

    A friend of mine just switched from WCF REST to OpenRasta and he really likes it. I think I’ll be trying it out for my next REST project. Like you said, the good REST stacks will probably end up being OSS frameworks.

    m

  2. Vish says:

    Hi Colin

    One correction to your blog post – .NET 4.0 will have a lot of WCF improvements that correspond to asks we have got from you and others. Specifically 4.0 will have:

    1. Content negotiation and richer format support for binary/text/views
    2. Some linking support
    3. Http exceptions
    4. Conditional get/put support
    5. Ability to use System.Web.Routing so that you dont need .svc files or .svc in the URL
    6. Samples illustrating how to use WCF extensibility, and making it easier to do so (for example, adding Forms processing to WCF)
    7. Support for JSONP

    And some other features.

    4.0 Beta2, which will come out sometime this year, should have all these features.

    Your feedback will be welcome.

  3. Jesse Ezell says:

    REST is much easier with WCF when you throw out all the contract bullshit and use IRequestChannel / Message class and the http message properties directly. That makes it a shit framework for end users, but if you are building a REST framework, that is a much better place to start.

    That said… I would be much more interested in someone developing a generic / non-HTTP REST framework on top of WCF that yet another MVC framework for http…

  4. Colin Jack says:

    @Vish
    Ok sorry, those improvements are great. I’d argue that first 2 are key. 3/5/7 matter less than the others. I can do 4 currently but better linking/content negotiation and a *much* better story around extensibility are key, we’ve got framework for that but it was ridiculously difficult. On extensibility instead of examples, or in addition to, why not look at mob’s contrib?

    @Jesse
    Ahh ok, we’re not using WCF client-side at all. The support there is beyond dire. Not sure I want to drop back to the Message class, I know its an option but not an overly attractive one.

    @mob
    Yeah MS doesn’t seem to be setup to listen, people on the teams seem interested but they’ve got pressures on all sides. Great on the Contrib, will need to give it a look over and agree that it looks like OSS is going to end up beating WCF hands-down unless there are serious improvements.

  5. JOY says:

    Great! The articles so far have been full of great material. Glad to hear the serious will continue. Keep ‘em coming!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>