Main differences between SOAP and RESTful web services in Java

Gandalf StormCrow picture Gandalf StormCrow · Jan 25, 2010 · Viewed 623.4k times · Source

For now I have a slight idea about the differences between SOAP and RESTful services.

My question is when I should use SOAP, and when I should use RESTful; which one is "better" when it comes to performance/speed or request handling?

I'm implementing it for the first time in RESTful (Java) and I want know more about it; I've dealt with SOAP before.

This is a follow-up question to this post.

Answer

dj_segfault picture dj_segfault · Jan 25, 2010

REST is almost always going to be faster. The main advantage of SOAP is that it provides a mechanism for services to describe themselves to clients, and to advertise their existence.

REST is much more lightweight and can be implemented using almost any tool, leading to lower bandwidth and shorter learning curve. However, the clients have to know what to send and what to expect.

In general, When you're publishing an API to the outside world that is either complex or likely to change, SOAP will be more useful. Other than that, REST is usually the better option.