Curious: What is the currently recommended way to encode REST web services in C #?

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

The requirements are pretty vanilla: HTTP GET / POST for a small number of resource types, XML and JSON output, must live in the same application with the ASMX SOAP web service.

My criteria:

A) performance

B) development complexity (including learning curve)

C) maintainability

Thanks!

+4
source share
3 answers

If you already have data in a structured form in a database such as SQL Server, and you want to expose these bits of data (for example, your customers, their orders, etc.), then WCF data services are probably one of The most effective and efficient ways to provide your data. It handles many major problems for you and allows you to focus on what you want to expose and what to hide. And it even supports things like query in query strings, and also inserts and updates quite easily.

If you have more unstructured data, both bare WCFs with a set of REST or ASP.NET MVC starters seem pretty valuable. I haven’t done much with one of the two, but both of them are quite relevant, productive enough for developers and should fit well with your environment.

So, I assume that in your position I would first check the WCF data services and use it if it matches the account, and if not, choose between the WCF REST Starter Kit (which also works with classic ASP.NET web formats, or winforms, or console applications, or WPF, or Silverlight) - or check out ASP.NET MVC if you are planning this way already in your project.

+2
source

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

Creating RESTful services with OpenRasta is much easier than with WCF in my experience. It also affects ease of maintenance. I did not test the performance, but I never noticed that it suffers in this area, and because of the clean architecture, I would not be surprised if it were faster.

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 did not use Data Services, but from what I read, I do not think they consider RESTful to be true, but they can meet your requirements. I dont know.

+5
source

If you are using the .NET 4 environment, REST has much better support with RouteHandlers. If you want to implement on earlier versions, I would just execute my own HTTP handler and use the IIS6 wildcard routing (aspnet_isapi.dll) to handle 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 rest of the service. There is some additional complexity, but mostly around deployment.

0
source

Source: https://habr.com/ru/post/1301685/


All Articles