Why would one use REST instead of SOAP based services?

Web ServicesRest

Web Services Problem Overview


Attended an interesting demo on REST today, however, I couldn't think of a single reason (nor was one presented) why REST is in anyway better or simpler to use and implement than a SOAP based Services stack.

What are some of the reasons Why anyone in the "real world" use REST instead of the SOAP based Services?

Web Services Solutions


Solution 1 - Web Services

Less overhead (no SOAP envelope to wrap every call in)

Less duplication (HTTP already represents operations like DELETE, PUT, GET, etc. that have to otherwise be represented in a SOAP envelope).

More standardized - HTTP operations are well understood and operate consistently. Some SOAP implementations can get finicky.

More human readable and testable (harder to test SOAP with just a browser).

Don't need to use XML (well you kind of don't have to for SOAP either but it hardly makes sense since you're already doing parsing of the envelope).

Libraries have made SOAP (kind of) easy. But you are abstracting away a lot of redundancy underneath as I have noted. yes in theory SOAP can go over other transports so as to avoid riding atop a layer doing similar things, but in reality just about all SOAP work you'll ever do is over HTTP.

Solution 2 - Web Services

RESTful services are much simpler to consume than SOAP based (regular) services. The reason for this is that REST is based on normal HTTP requests which enables intent to be inferred from the type of request being made (GET = retrive, POST = write, DELETE = remove, etc...) and is completely stateless. On the other hand you could argue that it is less flexible as it does away with the concept of a message envelope that contains request context.

In my experience SOAP has been preferred for services within the enterprise and REST has been preferred for services that are exposed as public APIs.

With tools like WCF in the .NET framework it is very trivial to implement a service as REST or SOAP.

Some relevant reading:

Solution 3 - Web Services

I'll assume that when you say "web services" you mean SOAP and the WS-* set of standards. (Otherwise, I could argue that REST services are "web services".)

The canonical argument is that REST services are a closer match to the design of the web - that is, the design of HTTP and associated infrastructure. Thus, using a REST service will be more compatible with existing web tools and techniques.

Of course, once you drill into specifics, you find out that both approaches have strengths in different scenarios. Is it those specifics that you're interested in?

Solution 4 - Web Services

The overhead isn't that important as good architecture.

REST isn't a protocol it is an architecture that encourage good scalable design. It is often chosen because too much freedom in RPC can easily lead to a poor design.

The other reason is predictable cost of RESTful protocols over HTTP because it can leverage existing technologies (mainly proxies). RPC initial cost is quite low but it tend to increase significantly with load intensification.

Solution 5 - Web Services

Got to read Roy Fielding's most excellent dissertation on the topic. He makes an excellent case and was definitely WAY ahead of his time when he wrote it (2000).

Solution 6 - Web Services

REST is implementation-agnostic and much more transparent, and this makes it great for public APIs, especially for big websites like Flickr, Amazon or Digg that are using their APIs as marketing tools and really want people to consume their data. They don't want to be hand-holding 1000s of novice developers who are trying to debug their scripting language of choice's buggy SOAP library.

Versus SOAP and WSDL, which are better for internal applications, where you have drop-in libraries and known clueful people on both ends. (And you maybe don't have to care about things like Internet-scale load-balancing, HTTP caching etc.) Then you get APIs that are self-documented, preserve types etc. with zero work.

Solution 7 - Web Services

Steve Vinoski's blog and his latest articles are definitely worth perusing. He's a former CORBA guru, who wrote probably the best book on the subject with Michi Henning, "Advanced CORBA® Programming with C++". However, he has since seen the error of his client/server ways, and now swears by REST.

Solution 8 - Web Services

REST allows your non-mutating operations (that generally use the GET verb) to be cached. That is, cached by the client and/or cached by proxies. This can be a huge win!

Solution 9 - Web Services

REST is basically just a way to implement web services. It is just a way to use HTTP correctly to query the web services you are trying to hit.

http://www.xfront.com/REST-Web-Services.html http://en.wikipedia.org/wiki/Representational_State_Transfer

Solution 10 - Web Services

It is super simple and slim. You could do it with browser via http verb: GET. I haven't find a browser can manually do generic http POST request easily

Solution 11 - Web Services

Here's one data point: Amazon offers its APIs in both REST and SOAP formats and 85% of the usage is REST.

REST is easier to implement, easier to understand and higher performance.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAngryHackerView Question on Stackoverflow
Solution 1 - Web ServicesKendall Helmstetter GelnerView Answer on Stackoverflow
Solution 2 - Web ServicesEric SchoonoverView Answer on Stackoverflow
Solution 3 - Web ServicesBruceView Answer on Stackoverflow
Solution 4 - Web ServicesPiotr CzaplaView Answer on Stackoverflow
Solution 5 - Web ServicesPikoView Answer on Stackoverflow
Solution 6 - Web ServicesjoelhardiView Answer on Stackoverflow
Solution 7 - Web ServicesJason EtheridgeView Answer on Stackoverflow
Solution 8 - Web ServicesDavidView Answer on Stackoverflow
Solution 9 - Web ServicesEric HolscherView Answer on Stackoverflow
Solution 10 - Web ServicesRay LuView Answer on Stackoverflow
Solution 11 - Web ServicespbreitenbachView Answer on Stackoverflow