开发者

Curious: Whats currently the recommended way of coding REST web services in C#?

So, what do the experts recommend? WCF Rest Toolkit? ADO.NET (now WCF) Data Services AKA Astoria? Hand rolling it using ASP.NET MVC? Other?

Requirements are fairly vanilla: HTTP GET/POST for a small number of resource types, XML and JSON output, needs to live in the same appdomain with a SOAP ASMX web service.

My criteria are:

A) performance

开发者_Python百科

B) development complexity (including the learning curve)

C) maintainability

Thanks!


The best framework for REST services I have seen is OpenRasta, which is built from the ground-up to enable REST simply. http://trac.caffeine-it.com/openrasta

Building RESTful services with OpenRasta is much simpler than with WCF in my experience. This is also then reflected in the ease of maintenance. I haven't tested performance, but have never noticed it to suffer in this area, and because of the clean architecture I would not be surprised if it were quicker.

Some other links for you:

http://codebetter.com/blogs/kyle.baley/archive/2009/04/19/openrasta-or-how-to-speak-rest.aspx http://blog.huddle.net/we-love-openrasta http://www.vimeo.com/3385419

I haven't used the Data Services, but from what I've read I don't think they count as truly RESTful, but they may meet your requirements. I don't know.


If you already have your data in a structured form in a database like SQL Server, and you want to expose those bits of data (e.g. your customers, their orders etc.), then the WCF Data Services is probably one of the most efficient and productive ways to expose your data. It handles a lot of the underlying goo for you and lets you concentrate on what you want to expose, and what to hide. And it even supports things like querying in the query strings, and inserts and updates quite easily.

If you have more non-structured data, both bare-bones WCF with the REST starter kit or ASP.NET MVC seem to be quite valuable choices. Haven't done much myself with either of the two, but both are quite current, quite productive for developers and should fit nicely in your environment.

So I guess in your position, I'd check out WCF Data Services first and use it, if it fits the bill - and if not, choose between WCF REST Starter Kit (which also works with classic ASP.NET webforms, or winforms, or console apps, or WPF, or Silverlight) - or check out ASP.NET MVC if you're going that way already in your project.


If you use the .NET 4 framework REST has much better support using RouteHandlers. If you are looking to implement on earlier versions, I would just implement your own HTTP handler and use IIS6 wildcard routing (aspnet_isapi.dll) to process your requests.

With the REST starter kit you are limited to having a .svc file, but if you implement your own handler you can parse the requests manually and have much more granular control over the restful service. There is some additional complexity but its mostly around deployment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜