Difference between REST & SOAP based web services

Arun60
Tera Expert

Hi all,

Does any body knows what are the major differences between soap and rest based web services with some simple examples. Which one is more preferable and why ?

Thanks

Arun Tanwar

7 REPLIES 7

veeresh3
Tera Expert

Hi,


Please go through the below points.



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.






What is a REST Web Service




The acronym REST stands for Representational State Transfer, this basically means that each unique URL is a representation of some object. You can get the contents of that object using an HTTP GET, to delete it, you then might use a POST, PUT, or DELETE to modify the object (in practice most of the services use a POST for this).




Who's using REST?




All of Yahoo's web services use REST, including Flickr, del.icio.us API uses it, pubsub, bloglines, technorati, and both eBay, and Amazon have web services for both REST and SOAP.




Who's using SOAP?




Google seams to be consistent in implementing their web services to use SOAP, with the exception of Blogger, which uses XML-RPC. You will find SOAP web services in lots of enterprise software as well.




REST vs SOAP




As you may have noticed the companies I mentioned that are using REST api's haven't been around for very long, and their apis came out this year mostly. So REST is definitely the trendy way to create a web service, if creating web services could ever be trendy (lets face it you use soap to wash, and you rest when your tired). The main advantages of REST web services are:




Lightweight - not a lot of extra xml markup Human Readable Results Easy to build - no toolkits required SOAP also has some advantages:




Easy to consume - sometimes Rigid - type checking, adheres to a contract Development tools For consuming web services, its sometimes a toss up between which is easier. For instance Google's AdWords web service is really hard to consume (in CF anyways), it uses SOAP headers, and a number of other things that make it kind of difficult. On the converse, Amazon's REST web service can sometimes be tricky to parse because it can be highly nested, and the result schema can vary quite a bit based on what you search for.




Which ever architecture you choose make sure its easy for developers to access it, and well documented.




1)           SOAP is a protocol.                                                                                                                   REST is an architectural style.


2) SOAP stands for Simple Object Access Protocol.                                 REST stands for REpresentational State Transfer.


3) SOAP can't use REST because it is a protocol.                                       REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.


4) SOAP uses services interfaces to expose the business logic. REST uses URI to expose business logic.


5) JAX-WS is the java API for SOAP web services.                                 JAX-RS is the java API for RESTful web services.


6) SOAP defines standards to be strictly followed.                                 REST does not define too much standards like SOAP.


7) SOAP requires more bandwidth and resource than REST.                 REST requires less bandwidth and resource than SOAP.


😎 SOAP defines its own security.                                                                 RESTful web services inherits security measures from the underlying transport.


9) SOAP permits XML data format only.                                                 REST permits different data format such as Plain text, HTML, XML, JSON etc.


10) SOAP is less preferred than REST.                                                 REST more preferred than SOAP.




Thanks,


Veeresh



Please mark Correct, If it's Helpful


This is great, concise, and I'll be steering other people towards it as a resource - thanks!

Brad Tilton
ServiceNow Employee
ServiceNow Employee

Hi Arun,



They're 2 different technologies and there are some different resources out there that can explain the differences.



REST vs. SOAP: How to choose the best Web service


http://spf13.com/post/soap-vs-rest



The general rule is REST if you can, SOAP if you must.


ftvbyhujnmk
Kilo Expert

Hi Arun,



I would like to add one more point..


REST is more secured than SOAP.   using SOAP we can encrypt the data while transfer.



Thanks


Trinadha