The difference between rest Vs Soap,soap and Rest

Source: Internet
Author: User
Tags representational state transfer

Today, someone asked me a question: "Why would someone choose SOAP (Simple Object access, Protocol, and rather than REST (representational state Transfer, representational status pass) It? "My answer is:" I often hear the general empirical law is ' use REST unless you have a clear reason to use SOAP .’”。 He asked again, "for example?" "I thought for a minute, and then honestly answered that I had not yet met such a reason. My background is to build large internet companies.

Though he seemed content with the answer I had just made, I was not satisfied with the answer. I did some homework on this, and this article is a summary of what I did with rest vs soap, the difference between soap and rest, and why someone would choose soap to illustrate. As always, by comparing the meaning of each technique, we learn how to make a trade-off (fortunately, the answer is often REST).
My elaboration of them was clearly somewhat concise, so I made it so easy not to make bricks, but please do not hesitate to correct them.
The best scenario for defining restrest is when you expose a public API over the internet to handle CRUD operations on data. REST focuses on accessing named resources through a consistent interface.
SOAPSOAP provides its own protocol and focuses on exposing certain application logic (not data) as a service. SOAP exposes an operation. SOAP is focused on accessing named operations that implement certain business logic through different interfaces.
SOAP is often referred to as a "Web services", which is a false call. SOAP and the web are basically not words. REST provides a true URL-and HTTP-based "Web services."
Here are some examples of how to invoke them, with explanations attached.
GetUser (User);

Above this is a REST operation because you are accessing a resource (data).
Switchcategory (User, Oldcategory, Newcategory)

Since you are performing an operation, this is a SOAP operation above.
Of course, both of these calls can be either SOAP or REST. The purpose of the presentation is to understand their conceptual differences.
Why REST? Next, explain why REST is almost always the right answer.
REST uses standard HTTP so it's easier to do anything. Creating clients, developing APIs, documentation is easier to understand, and nothing is easier/better than SOAP to do with REST.
REST allows for many different data formats and SOAP supports XML only. While this seems to add complexity to REST because you need to deal with multiple formats, in my experience this actually has a lot of benefits. JSON is generally more suitable for hosting data and parsing it faster. Because of its support for JSON, REST allows us to better support browser clients.
REST has better performance and scalability. REST reads can be cached, while SOAP-based reads cannot be cached.
The argument is not very good (authoritative), but it's worth mentioning that all of Yahoo's services, including Flickr and del.ici.ous, use REST. Amazon and Ebay two are used, although almost all of Amazon's internal use is REST resources. Google used to provide soap only for all of their services, but since 2006 Google has discarded the soap-to-invest REST resource. Interestingly, there was also a dispute about rest Vs SOAP inside Amazon, but ultimately rest dominated the architecture of their Web services.
Why SOAP? Next, let's list some of the reasons you might want to use SOAP.
Web Services Security Soap not only supports SSL like REST, but also supports ws-security (WS = Web services), which adds a lot of enterprise-level security features. So it can provide authentication through mediations, not just end-to-end authentication (SSL). In addition, SOAP provides a standard implementation of data integrity and data privacy. Calling it "Enterprise" is not to say it is more secure, it simply provides a few security tools that are not needed by typical Internet services, and in fact these tools can only be useful in a few "enterprise" scenarios.
Web Services atomicity Transaction if the service requires ACID transactions, then you need SOAP. Although REST also supports transactions, it is not complete and does not have ACID. Fortunately, ACID transactions have little meaning for the internet. REST is limited by the fact that Http,http itself cannot provide a two-phase commit distributed transaction resource, but SOAP can. Internet applications generally do not require this level of transactional reliability, which is sometimes required for enterprise-level applications.
Web Services Message Reliability Rest does not have a standard messaging system that expects clients to handle communication failures by retrying. Soap has built-in success/retry logic and provides end-to-end reliability through Soap mediations.
In summary, SOAP is clearly useful and important. For example, if I go to write an IPhone app that connects to my bank, then of course I need to use SOAP. These three-point features are required by the banking firm. For example, if I transfer money from one account to another, I need to make sure it's done. if the first transfer succeeds, but the response fails, the REST retry at this time will be catastrophic
Resources
    • Why not use SOAP
    • SOAP or REST?
    • Bye, Google SOAP search API
    • SOAP Vs REST
Original link: http://spf13.com/post/soap-vs-rest

The difference between rest Vs Soap,soap and Rest

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.