While I was wandering around the interwebs my brain came up with a, for me at the time, unanswerable question.

” Is REST better than SOAP. “

To be short, yes, in my opinion it is. But for you to understand how i’ve gotten to this answer, I might need to give a little bit more information.

In fact, I’ll start at the beginning.

What is SOAP?
SOAP is short for “Simple Object Access Protocol” and is nothing more than a protocol that enables communication between multiple “objects”. It helps exchanging structured data between entities in a computer network (as is the internet).

What is REST?
REST is short for “Representational state transfer” and can be used for exactly the same thing.

But what is the difference?
REST uses in (almost) every case the HTTP protocol which makes it a lot easier to use. Creating API’s, requesting data and building other code is much easier and the documentation is great. But, that it’s easier doesn’t always mean its better!

Luckily the list is longer!
REST works with a whole bunch of data formats as SOAP only can work with XML. At first hand this might seem like complicating things, and this can actually be true. The upside of this point is that you can use a different data format for every request. Just the one that suits you, but even better, suits the request. Look at JSON. Most of the requests will be better off using JSON because its way faster.

REST and SOAP both work with SSL, so for security for “standard” issues there is no clear winner. When it comes to advanced security, SOAP wins. It has WS-ReliableMessaging which will always provide end-to-end reliability. REST doesn’t have this, it just wants you to retry a 1000 times. Then SOAP also has WS-AtomicTransaction which is needed for ACID Transactions. Not that anyone still uses this, but he, they support it ;-)

REST can be used very fine with the HTTP verbs GET, PUT, POST, DELETE and in that way can provide a basic structure for you to build your API on.

Last and certainly also least
Google, Ebay, Amazon, Yahoo and Flickr, A.K.A the big boys are ALL using REST and banned SOAP for them API’s.

I would always recommend REST. Not only because it seems easier to work with, you can have way more control over your calls (get, put, post, delete) but because of its support for other data formats as SOAP is always way faster.

But after all, SOAP doesn’t suck, I can think up (very rare, but still) situations where it would be equal or even better than REST.

Let me know your thoughts!