Comparison of rest and soap--rest

Source: Internet
Author: User
Tags html page soap web services advantage firewall

I have an inference that, in the computer world, all the important concepts that the developer remembers, there is a cool name acronym, or the developer will soon leave it behind. Ajax, SOAP, and rest, for example, attest to this.

Rest can be widely used in the computer field, and its path is unusual. This term was created by Roy Fielding. Fielding graduated from the University of California, Irvine, for the first time in his doctoral dissertation to propose the concept of rest. On the web side, we must admit that fielding is very proficient and has helped create the HTTP 1.0 specification, which has provided the basic guidelines for the Web since 1996. He is very experienced in web standards, which lays a solid foundation for his doctoral dissertation.

Fielding points out that components deployed on the web, which are used in a representative state transfer (REST) design constraint, can take full advantage of the web's useful features and that the World Wide Web (Wide) can achieve the best results. You can understand rest--. When a browser gets and displays the individual elements that make up an HTML page, it is getting a representation of the current state of the resource. In Fielding's doctoral dissertation, he cites the rest-style design constraints and explains why these constraints can take full advantage of the useful features of the web, make it optimal, and the key to these constraints. At the same time, in the paper, he also contains some discussion about "non-conformance" between rest and some of the current web styles, and how these web styles are causing the design to fail to take advantage of Web features.

Fielding that the way to use HTTP to host application protocols across firewalls, XML-RPC and soap, is "fundamentally misguided concepts." "The way they're used violates the concept of a firewall, and as a result, firewall vendors are trying to detect the protocols they are hosting in order to protect the system." Since most SOAP applications use HTTP to traverse firewalls, you can see where the conflict between rest and soap begins. Fielding that if you intend to use HTTP, you should take full advantage of the meaning of HTTP itself.

The rest style emphasizes that the interaction between the customer and the service is enhanced through a limited operation or a "verb" and a standard interface between the components, which is an excuse provided by the HTTP protocol. By assigning each resource its own URL for flexibility, rest can invoke a client with a resource type of hundreds of URIs, the key being that rest can give you an infinite number of "nouns." Rest uses HTTP verbs-a simple well-defined set of operations: POST, GET, Put,delete to request and respond, thus avoiding ambiguity. For example, get can simply return the expression of a resource without being able to create any other content.

In the early days of web development, as people were experimenting with the integration of Web applications by collecting elements from a variety of different sources, there were a number of examples of immature explorations of such Web services-parsing information from HTTP pages for use by page creators without planning. This web analogy of "screen scraping" suggests that the rest-style approach comes before more complex web services.

  rest is a style rather than a standard

You might consider the architectural style of the software as an abstraction of the upper-level design pattern. However, according to Fielding, the design pattern stack is not the same as the architectural style, because the pattern is very close to the specific problem.

Because rest is a style of hypertext systems, not Web services, the title "Comparison of Rest and soap" In this article is somewhat misleading. However, many software designers confuse it, and when they consider how to create a Web service, they conclude that soap is too complex, and that simple rest-like design is more appropriate.

comparison of rest and RPC styles

The schema of a remote procedure call is applied in a Web service based on XML-RPC or RPC-style soap, but it has a completely different style. The client issues a command to enable the service to make a specific operation. In other words, RPC has a tendency to verbs.

Rest emphasizes that resources (nouns) have a uniform interface to address them, whereas RPC emphasizes that the process (verb) has a uniform interface to excite them. An RPC-based architecture with no limit to the number of verbs. Rest says that we use four verbs-very familiar, HTTP standard get, POST, put, and delete--to make requests and responses, and rest uses resource addressing to handle its variability.

  A simple example of rest

Suppose we want a Web service to expose a subset of the directories from which users will be able to get descriptions, pictures, installation instructions, and so on. In order to get a description of the number "n1996-01", the user needs to format a GET request, similar to the following URL:

Http://company.com/catalog/description/n1996-01

When the request is processed, "/catalog" is mapped to a service, and then the "description/n1996-01" is interpreted by the service to locate the resource. When you create a response, the service needs to use the header file of the content type (content-type) to specify the return format. In this case, it is assumed that the return format is HTML or XML, which the client can use to control the layout of the page. If a picture is to be obtained, the request will be addressed to "/catalog/picture/n1996-01", and the response returned will be the picture content type (content-type).

  Business applications for rest

In recent years, most web business enterprises have begun to be very interested in rest. The Google Data API, currently in beta, uses rest rules to provide simple protocols. The response to an HTTP GET request for a service is to use an atom or an RSS-formatted XML data. Google also uses Atom and post, put, and delete operations to complete public protocols. Ebay Services provides access to services by using different language tools, including document/text-style soap and restful styles.

So is the rest style a competitive alternative to the RPC style that XML-RPC and soap have? Of course, I would never think so, in the next article, I will try to show you the realm of soap invincible.

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.