REST vs SOAP

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.
Ads by Google
  • 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 Web Service tutorial was added on 13/11/2012.

«

»

58 Responses to “REST vs SOAP”

  1. Matt Kleidemran says:

    This of course, begs the question: “Which is the octopus, which is the orangutan, and why?”

    • Joe says:

      :-) 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.

    • 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.

  2. Mario Guerrero says:

    Rest win !!!

  3. Vijay says:

    good summary. can you please give a simple example where each one is preferred or appropriate?

    • Joe says:

      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.

      • akash says:

        then the question aries how you will compensate WS-security, session, WS_transactions etc with REST?

      • Anders says:

        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.

  4. Shaan says:

    I think rest is today world of WS.

  5. MD SHAUKAT ALI says:

    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?

    • Joe says:

      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.

  6. Rajesh says:

    SOAP has the advantage over RESTful services in message level security.

  7. Rahul S says:

    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

    • Anders says:

      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.

  8. Yogesh Nerkar says:

    Hi Joe,

    This is nice info about SOAP and REST. It would be nice if you have code based examples as well.

    Yogesh

  9. Nice attempt to compare REST and SOAP. Yes, it is like comparing Oranges with Apples. I am sharing this through my

  10. karthikeyan says:

    Dear Joe,
    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.

  11. Friend of Joe says:

    Hi Joe,

    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”

  12. mani says:

    which is the best one to implement in online shopping website development

  13. Mauro Dutra says:

    The intelligent, resourceful and complex octopus is SOAP. And, the colorful, inventive, free spirited orangutan is REST.

    • Joe says:

      Wow! I really like this :-)

      • Bill says:

        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.

  14. Karthik says:

    Hi Joe,

    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 ?

    Thanks,
    Karthik.

    • Joe says:

      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).

  15. Anonymous says:

    thanks .very useful information.

  16. Mahesh says:

    hi Joe please call me
    if you are staying in Bangalore.
    9740324405

  17. Sridhar says:

    Hi Joe,

    As you said,Even SOAP based web services can be implemented in RESTful style.Does the SOAP services supports http methods other than post.

  18. dkm says:

    REST works on HTTP channel, while SOAP works on HTTP, FTP, SMTP channels.

    Rest requires no client side library written in WSDL like SOAP.

    • dev07 says:

      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.

  19. Saurabh says:

    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.

  20. rahul says:

    sir,
    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

  21. Vijay says:

    I want to take a seminar In REST topic in my college, So can u plz give some like.

  22. Sridhar.Goranti says:

    Hi Joe,

    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

  23. Alaa Agha Karss says:

    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.

  24. ps says:

    am working on bigdata, so which one is more usefull?

    and whether the soap without wsdl act as rest?

  25. Anonymous says:

    nice

  26. raghav says:

    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”

  27. Amay says:

    Really nice post … But which one is good at scalability?

  28. Ashok says:

    Very nice summary, very very useful. Thanks Joe.

  29. Shoebuddin says:

    Awesome differences Thanks.

  30. siva says:

    good stuff

  31. Gowtham says:

    Hi Joe,

    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.

  32. 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 ?

    • Ahmed Drira says:

      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

  33. […] 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 […]

  34. sysadmin says:

    Very useful info. Thanks joe

  35. sskcar says:

    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.

  36. Amine says:

    nice comparison (Y)

  37. Bijoy says:

    Nice introduction to web services .. Thanks

  38. Rajesh says:

    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.

  39. Lakshmi says:

    Hi, Can you please tell me few similarities between SOAP and REST. Thanks

  40. noname says:

    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?..

    • Joe says:

      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.

  41. Abhijit says:

    CAn any one please explaing what does it means by ‘REST follows stateless model’?
    Also are SOAP and WSDL one and the same?

Leave a Reply