RESTful services: WCF versus ASP.NET MVC
Asked Answered
S

3

20

A very common approach to implementing RESTful services is by utilizing ASP.NET MVC to do so over WCF.

ASP.NET MVC has excellent RESTful support by via flexible URL routing and flexible HTTP Method mapping to controller actions.

WCF 4.0 now has excellent support for implementing RESTful service also using the same ASP.NET routing mechanism as ASP.NET MVC.

Question What are your experiences working with either of the 2 approaches to create RESTful services and pros and cons encountered?

Syrupy answered 26/3, 2011 at 20:10 Comment(0)
T
10

WCF services can be self-hosted. No IIS required. ASP.NET MVC is focused on delivering HTML, whereas the existing .net 4 WCF stack is focused more on XML and JSON.

The new http://wcf.codeplex.com is the next generation of REST on WCF and will be significantly more capable than the existing stack.

The new stack will be much better at supporting all different media types. It provides much better access to the underlying HTTP protocol. It will be much more testable and will make it easier to plug in reusable handlers to add standard behaviours.

Tellurize answered 27/3, 2011 at 20:3 Comment(2)
you have raised some good points. From what I have seen if the intent is to host the WCF services only in IIS (similar to MVC) some additional plumbing code will be needed to return an Xml ActionResult or switch between JSON and XML for the same action as opposed to making changes to the endpoint via configuration in WCF. Seeing that ASP.NET MVC is also very testable (similar to WCF) are there any other key differences to be noted between the 2? I would also be very interested in feedback from users that did eventually pick the MVC route over the WCF one.Syrupy
I don't really enjoy working with beta and preview versions, thus the new WCF Web API is not something I wish to do just yet. "Announcement: WCF Web API is now ASP.NET Web API! ASP.NET Web API released with ASP.NET MVC 4 Beta. The WCF Web API and WCF support for jQuery content on this site wll removed by the end of 2012." Also then wcf.codeplex.com/discussions/319671 As of today is is still BETA nuget.org/packages/AspNetWebApiTheodolite
T
2

Take a look at Podcast from Scott Hanselminutes with Glenn Block where they discuss same issue and compares MVC and new WCF Web API. http://www.hanselminutes.com/default.aspx?showID=284

Tega answered 23/5, 2011 at 12:16 Comment(0)
D
1

I'd say WCF is better suited to build services, you can do it with asp.net mvc but it requires more ceremony

Dortch answered 26/3, 2011 at 21:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.