Difference Between REST and SOAP

We had a question today on what’s the real advantage of going with REST over SOAP. It’s tempting to say that REST is the next best thing after sliced bread while SOAP is the devil’s spawn but here’s a more reasonable attempt at explaining the difference –

  • SOAP is a protocol on top of HTTP whereas REST is a design principle of designing services with basic HTTP protocol.
  • REST uses HTTP verbs GET, POST, PUT, DELETE, etc for the things that they were intended – SOAP is mainly an RPC with XML that primarily uses POST requests
  • REST doesn’t try to handle state; SOAP protocol is designed to handle state of a particular client through session (which adds a bit of overhead)
  • HTTP is already handled by browsers and all web clients, as well as any web server – on the other hand SOAP protocol needs an additional layer of software, and each vendor has it’s own implementation (which may or may not fully adhere to the SOAP protocol).
  • SOAP exposes API in form of WSDL which allows client-side code generation – this makes it easier to get started but also introduces maintainance issues
  • Versioning is more difficult with SOAP – even additional properties getting added will break the clients if they are on a previous version – on the other hand, versioning is much simpler with RESTful services, since any additional properties added on the server side are just ignored at the client side if they are not required
  • If there are strict contracts to be forced between a service and a Client, SOAP has explicit ways of doing that – REST has no such mechanisms
  • A lot of client side libraries (such as backbone.js) make it much easier to consume RESTful web services
  • Since SOAP is a huge abstraction on top of the HTTP protocol, things get really difficult to debug when the abstraction breaks down – for e.g. when a configuration has a problem. Debugging issues in HTTP calls is relatively much easier since there is no proprietary stack in between your code and the client calls.

Can you think of any other differences?

UPDATE: I recently posted an interview with Demis Bellot on InfoQ that explains in a lot more detail the perils of SOAP – you should read it.

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax