REST vs SOAP
Last modified on October 15th, 2014 by Joe.
This article is to compare REST vs SOAP. There is huge difference between REST and SOAP. Comparing SOAP and REST is not just right as they are different things. It is like comparing orangutan and octopus, I have high regard for both of them. But still, as it is a popular topic lets have a discussion on SOAP vs REST.
Roy Fielding was a member of the team that wrote the specification for HTTP and co-founder of Apache HTTP server project. He introduced the word REST and the concept in his doctoral thesis in 2000. REST disruptively took over as an architectural style for web services implementation.
- SOAP stands for Simple Object Access Protocol. REST stands for REpresentational State Transfer.
- SOAP is a XML based messaging protocol and REST is not a protocol but an architectural style.
- SOAP has a standard specification but there is none for REST.
- Whole of the web works based on REST style architecture. Consider a shared resource repository and consumers access the resources.
- Even SOAP based web services can be implemented in RESTful style. REST is a concept that does not tie with any protocols.
- SOAP is distributed computing style and REST is web style (web is also a distributed computing model).
- REST messages should be self-contained and should help consumer in controlling the interaction between provider and consumer(example, links in message to decide the next course of action). But SOAP doesn’t has any such requirements.
- REST does not enforces message format as XML or JSON or etc. But SOAP is XML based message protocol.
- REST follows stateless model. SOAP has specifications for stateful implementation as well.
- SOAP is strongly typed, has strict specification for every part of implementation. But REST gives the concept and less restrictive about the implementation.
- Therefore REST based implementation is simple compared to SOAP and consumer understanding.
- SOAP uses interfaces and named operations to expose business logic. REST uses (generally) URI and methods like (GET, PUT, POST, DELETE) to expose resources.
- SOAP has a set of standard specifications. WS-Security is the specification for security in the implementation. It is a detailed standard providing rules for security in application implementation. Like this we have separate specifications for messaging, transactions, etc. Unlike SOAP, REST does not has dedicated concepts for each of these. REST predominantly relies on HTTPS.
- Above all both SOAP and REST depends on design and implementation of the application.
This of course, begs the question: “Which is the octopus, which is the orangutan, and why?”
Rest win !!!
good summary. can you please give a simple example where each one is preferred or appropriate?
I think rest is today world of WS.
Although it is always said that REST dominant over SOAP but as i think REST is only suitable to small or mid size application as far as the enterprise level development specially in vertical industry like banking etc is concerned SOAP is preferably used due to its security and governance implementation …am i right joe sir?
:-) its my attempt at humour and long way to go. So happy to see you comment Matt. Thank you.
I remember instances when you tried hard to impart RESTful philosophy to us and many discussions on uniform URL, atomicity and status codes.
My personal preference is to always go with RESTful services unless otherwise there is a specific mandate that requires SOAP based services.
In restricted security scenarios where we need something more than transport security then we can think about SOAP.
The web based banking transactions we do rely only on the HTTPS. End user authenticates over HTTPS, once authenticated every action done by that user is legitimate. Web based banking transactions work based on this principles.
If the above is fine, then RESTful services can be used for banking transactions too. SOAP has well defined, detailed WS-Security specification.
In REST we just use HTTPS to secure our messages over network. In SOAP using WS-Security spec, we can use message encryption, signature and all these over HTTPS. If we feel transport security alone is not sufficient, we can go with SOAP and WS-Security. It is all left to the requirement and chance we can take.
SOAP has the advantage over RESTful services in message level security.
i think , octopus and orangutan used as a term and reference to make readers clear how to compare this two things SOAP vs REST, recently i write a REST service using jersey framework and face difficulty to design URL for different service , expecting more on REST from Joe. Thanks a lot for such a good site.
Rest-ful APIs can be consumed using simple GET requests, intermediate proxy servers / reverse-proxies can cache their response very easily. On the other hand, SOAP requests use POST and require a complex XML request to be created which makes response-caching difficult
then the question aries how you will compensate WS-security, session, WS_transactions etc with REST?
This is nice info about SOAP and REST. It would be nice if you have code based examples as well.
https://javapapers.com/web-service/soap-web-service-introduction/ – refer this for a SOAP hello world service.
Soon I will write example code for REST web services too.
Nice attempt to compare REST and SOAP. Yes, it is like comparing Oranges with Apples. I am sharing this through my
It was very good attempt. but, it seems like summary. As yogesh said, it would be more powerful if there is code based examples. I am waiting for that.
A tip for you : You have a habit of saying ” does not has” like for example “But SOAP doesn’t has any such requirements”
The correct grammar is “it does not have”. Lot of desis do that mistake.
“But SOAP doesn’t have any such requirements”
which is the best one to implement in online shopping website development
The intelligent, resourceful and complex octopus is SOAP. And, the colorful, inventive, free spirited orangutan is REST.
Wow! I really like this :-)
Am new to this webservices. The above differences you mentioned sounds good. I have one basic query, what is the difference between Rest vs Restful. In some places you have mentioned Rest and Restful in some other places. Both are same ? or different. If its different, can you tell me where both stands and what is the difference ?
REST is the acronym for the concept (just the name). When we say RESTful, it is adhering to REST’s philosophy.
RESTful services means, services that follows the REST philosophy(rules/concepts).
hi Joe please call me
if you are staying in Bangalore.
Actually, I think most people would agree that the orangutan is the more intelligent of the two. However, the octopus is probably the smartest invertebrate creature living today.
As you said,Even SOAP based web services can be implemented in RESTful style.Does the SOAP services supports http methods other than post.
If you only uses GET, you are not using REST. In REST, you use POST when you update the state (database) on the server.
Never use GET to update state, as it is supposed to be omnipotent.
REST only works over HTTP and HTTPS. WS/SOAP works over HTTP, HTTPS, SMTP, XMPP, etc etc.
So you can send SOAP requests through email, securely, if you want.
SOAP support transactions too.
So there are more difference than stated in this article.
Yes, most SAOP frameworks can produce RESTful interfaces too. So you get both world there.
REST works on HTTP channel, while SOAP works on HTTP, FTP, SMTP channels.
Rest requires no client side library written in WSDL like SOAP.
thats correct. we require third party libraries for soap. ex. in android, we require KSOAP2 Library. but for REST, we dont require anything like this.
Not sure if it was intentional or not, but I think the key missing thing is do explain in brief what is SOAP and what is REST. That is what I was looking for. So I will go to wikipedia. The information was very useful. Thanks.
Can any one answer my question plz.
i would like to know more about REST can u please provide more information on it i had google out but still unclear with concept also is REST and ROA are same n what is SOAP vs SOA
I want to take a seminar In REST topic in my college, So can u plz give some like.
It should be… lot of desis make that mistake.
This is nice info about SOAP and REST with nice content. It would be nice if you have code based examples as well.
Expecting more examples soon Joe.
Thanks, Sridhar Goranti
Thanks for your efforts and the useful information.
still want to know more of the concepts about both ,I am a beginner and I would like to understand them both and then to read the comparison again.
am working on bigdata, so which one is more usefull?
and whether the soap without wsdl act as rest?
Your website content is very simple and straight forward. Please be aware of few grammatical mistakes. I don’t think “doesn’t has” is correct it should be like “doesn’t have”
Really nice post … But which one is good at scalability?
Very nice summary, very very useful. Thanks Joe.
Awesome differences Thanks.
i am planning to create a mobile application.having a few clarifications whether i could use SOAP for this?? could you help me out your suggestions for this ?? and also let me know what could be suitable either REST/SOAP if it comes for mobile apps.
Hi Joe , I am a big fan of your website , I have been following your website for past 3-4 years. I like your blogs because of the simplicity and ease of understanding. I have one question for you , Using a RestFul Webservice , How can we invoke or call SOAP Based webService ?
[…] tutorial we will see about how to Tweet / post using Java via Twitter API. Twitter provides a rich REST API to create Twitter enabled applications. It provides the complete possibilities, right from reading […]
on the corp of your restful WS you have to write a SOAP Client , So by invoking the REST WS , the responsible method will invoke the SOAP client too and their you SOAP WS will be invoked by the rest WS , The SOA architecture is something like this
Very useful info. Thanks joe
Your initial description compare “apples to apples” this is over exaggerated.
Both are same…you did not describe much about what is different in terms of the purposes, covered only the implementation and technical’s.
But good try by consolidating all technical/implementation differences.
nice comparison (Y)
Nice introduction to web services .. Thanks
Joe, The article is good. Can you please suggest a common framework to use REST as well SOAP based webservice. I can think of Apache CXF. But i need your suggestion. Thanks.
Hi, Can you please tell me few similarities between SOAP and REST. Thanks
Is SOAP outdated?. Why should we use REST instead of SOAP?… What do you think is the best?. Which is most widely used? What percentage of companies are really using SOAP? IS one alternative to another?.If i learn both ,wont I get confused?. Is it mandatory to learn both ? Isn’t it enough to learn either SOAP or REST?..
No! SOAP and REST should be used as the situation demands. It depends on the use cases you are applying. Its better you learn both.
CAn any one please explaing what does it means by ‘REST follows stateless model’?
Also are SOAP and WSDL one and the same?
Thanks for explaining in simple words,it’s easy to understand the differences.
I have searched various article but they were heavy to digest,,,
Thanks for posting wonderful info,,,:)