WCF or ASP.NET MVC

5 06 2008

For .NET developers the current framework for developing RESTful applications (without resorting to custom HttpHandler’s and what not) is Windows Communication Foundation (WCF). REST-support is a feature that was added on late in the game and partially due to much pressure from the developer community. However WCF is one of those frameworks that is “all things to all men”. It’s the framework that allows any type of distributed communication (SOAP, MSMQ, binary over TCP/IP) making it (IMO) pretty bloated. Because REST was afterthought, resources are exposed using interfaces and ServiceContracts which doesn’t always seem very natural. Additionally, there isn’t inherent support for HTML (or at least I’m not aware of it) and even if your services don’t serve HTML representations, it should still be a format that could easily served (without concatenating strings).

Interestingly, Microsoft has revealed and released bits that they are working on an alternative to ASP.NET namely ASP.NET MVC. While this newer framework trumps up the fact that it allows developers to develop web applications using the MVC design pattern, what I find more intriguing is that as a framework, it allows development of services in a RESTful manner using a web framework (which WCF is not) that can serve all web formats. There are a lot of posts that talk about how ASP.NET MVC can be used RESTfully.

So the question I have is this: Why would anyone use WCF for RESTful web services once ASP.NET MVC is publicly available?


Actions

Information

2 responses

22 07 2008
Zygimantas

WCF has the advantage that you can output the same service to multiple channels (JSON, REST, WS, TCP) with no code changes.

28 07 2008
Eb

Zygimantas -

I think you are possibly mixing up a couple of things and possibly calling them “channels” e.g. REST and WS are not channels. However, I do believe I understand your point which is the possible exposure of the same service over HTTP, TCP, MSMQ etc.

If your architectural style is REST, then it potentially influences your technology choice and in my opinion ASP.NET MVC may be the better choice. If the architectural style is RPC, then WCF may be a better solution.

Leave a comment