Understanding the true Rest architecture style

Source: Internet
Author: User
Tags soap json representational state transfer rfc ruby on rails wsdl

This is the second in the depth of the Deep Exploration Rest column series that will take you through the origins of the rest architecture, the web, the nature and characteristics of the rest architecture, and the comparison of rest architectures with other architectural styles.

Introduction

With the rapid development of mobile internet and cloud computing, as a web developer, if you have not heard of the buzzword of "REST", it is obviously outdated. Exaggerated point said, even "out of the door are embarrassed to greet others." Still, most people (including some experienced architects) remain in the "elephant" phase of understanding rest as a mooring. Often hear all kinds of rest-like statements, such as: "Our new API decides not to use Web Service (SOAP+WSDL), but to Http+json directly, that is, to develop in a restful way," says one. "Without soap, or even XML, it automatically becomes a restful." Others argue that rest is not fundamentally different from traditional Web service, but that there are more requirements for how the URI is constructed, which requires that the Web service be fully achievable. The subtext is: both Yu, He Senliang. The Web service is good enough, why do you have to toss any rest. Are these different versions of rest, indeed? What is rest? Is it a new technology, a new architecture, or a new specification?

In order to understand what rest is, we need to look back at the first years of web development and tell you how rest is derived from the source.

The development of Web technology and the origin of rest

The Web (www World Wide web) is an all-encompassing kaleidoscope of different people looking at different points of view about what the Web is all about. As Web developers, we need to understand the web in terms of technology. From a technical architecture perspective, the Web's technical architecture includes four cornerstones:

Uri

HTTP

Hypertext (in addition to HTML, it can also be XML or JSON with a hyperlink)

Mime

These four cornerstones support each other, prompting the web's magnificent building to evolve at a geometric speed. On top of these four cornerstones, the development of web development technology can be roughly divided into the following phases:

Static content phase: In this initial phase, the Web is used primarily by a number of research institutes. The web consists of a large number of static HTML documents, most of which are academic papers. A Web server can be viewed as a shared file server that supports hypertext.

CGI program phase: At this stage, the Web server adds a few programming APIs. Applications written through these APIs can provide some dynamically changing content to the client. The communication between the Web server and the application is done through the CGI (Common Gateway Interface) protocol, and the application is called a CGI program.

Scripting language phase: At this stage, the server side of ASP, PHP, JSP, ColdFusion, such as scripting language Technology support session, the browser side of the Java applet, JavaScript and other technologies. Using these technologies, you can provide richer dynamic content.

Thin client application phase: At this stage, a Web server-independent application server appears on the server side. At the same time, the web MVC Development mode, various web MVC development Framework is becoming popular, and occupies the dominant position. Web applications developed based on these frameworks are usually thin client applications because they generate all of the dynamic content on the server side.

RIA Application phase: At this stage, there are multiple Ria (Rich Internet application) technologies that dramatically improve the user experience of Web applications. The most widely used RIA technology is dhtml+ajax. Ajax technology enables you to dynamically update local content in a page without refreshing the page. It also spawned a large number of Web front-end DHTML development Libraries, such as prototype, Dojo, ExtJS, Jquery/jquery UI, and so on, and many development libraries support the development of one page application (single page application). Other RIA technologies include Adobe Flex, Microsoft's Silverlight, Sun's JavaFX (now owned by Oracle), and so on.

Mobile Web Application phase: At this stage, a large number of mobile device-oriented Web application development technology has emerged. In addition to Android, IOS, Windows phone and other operating system platform native development technology, based on HTML5 development technology has become very popular.

From the development process of the Web development technology mentioned above, the web has gradually become more and more dynamic from the stage of the main supporting static document conceived by its designers at first. The interactive pattern of Web applications has become increasingly complex: from static documents to content-oriented portals, E-commerce sites, search engines, social networking sites, to entertainment-oriented massively multiplayer online games, mobile games.

In the Internet industry, practice always goes before the theory. Web Development to 1995 years, in the CGI, ASP and other technologies, after many years, the main static document-oriented http/1.0 protocol has been unable to meet the development needs of Web applications, so need to design a new version of the HTTP protocol. In the http/1.0 agreement group, a young man stood out and showed extraordinary insight, and later became the head of the http/1.1 Agreement Expert Group. The young man is the core developer of the Apache HTTP server, Roy Fielding, and co-founder of the Apache Software Foundation.

Roy Fielding and his colleagues in the design of the http/1.1 protocol, for the great success of the Web, the technical framework of the factors made a deep summary. Fielding these summaries into a set of theoretical frameworks, and then uses the guiding principles in this set of theoretical frameworks to guide the design direction of the http/1.1 protocol. The first draft of the http/1.1 agreement was released in January 1996 and, after more than three years of revision, became the official specification of the IETF in June 1999 (including RFC 2616 and RFC 2617 for client authentication). The http/1.1 protocol was so successful that, for 10 years after its release, few people thought it necessary to revise. The theoretical framework used to guide the design of the http/1.1 protocol was initially communicated among members of the expert Group in the form of memoranda, except for the ietf/w3c circle of experts, which was not widely circulated outside the world. Fielding, after completing the design of the http/1.1 agreement, returned to the University of California, Irvine, to pursue his doctorate. The following year (2000) in his doctoral dissertation architectural Styles and the design of network-based Software architectures, fielding more systematic, The theoretical framework was elaborated and a new architectural style was derived using the theoretical framework, and an abbreviated acronym for this architectural style was given to the "REST"--representational state Transfer (the expression transition).

In the author's opinion, fielding this doctoral thesis in the Web history of value, no less than the Web Father Tim Berners-lee about hypertext of the classic paper. Unfortunately, this doctoral thesis has not received enough attention for nearly 5 years after its birth. For example, Web Service-related specifications soap/wsdl designers obviously don't understand what rest is, what kind of protocol http/1.1 is, and why it's designed to look like this.

This situation has improved significantly after 2005 years, with the advent of new web development technologies such as Ajax, Ruby on rails, and a movement to return to Web architecture design roots in the Web development technology community, and the rest architecture style has received increasing attention. In January 2007, the Ruby on Rails version 1.2, which supports rest development, is officially released and will support rest development as a priority in the future development of rails. Ruby on Rails founder Dhh made a wonderful speech called "World of Resources", DHH's powerful influence in the Web development technology community, leaving rest at the center of the Web Development technology arena.

Today, a variety of popular web development frameworks, almost no support for rest development. Most Web developers learn about rest development by reading a document from a rest development framework, and by using some example code. However, there are very large limitations to learning rest through example code. Because rest is not a specific technique or a specific specification, rest is actually a very rich architectural style. Learning Rest through example code does not fully understand what rest is except by learning an interesting web development technique. It's even a mistake to think that these simple example codes are the rest itself, and rest is just a simple web development technology. Like elephant, some people feel like the nose, some people feel like the ears, some people feel like legs, some people feel like the tail. They all believe that the elephant they feel, is the most real elephant, and the other people's feelings are wrong.

For web developers who do not understand rest, people are accustomed to displaying some examples of code to make them understand rest, and I disagree with this approach. If web developers want to get a deeper understanding of what rest is, it's hard to avoid Fielding's doctoral thesis. The author's introduction to rest in this article is also based on Fielding's doctoral thesis. Nevertheless, I strongly suggest that readers of this article personally go through Fielding's doctoral thesis, as if they wanted to understand that Confucius's thoughts should be read directly to the Analects, rather than read the same as the others. The author in this article is just trying not to do a Chang the scriptures wrong. So, let's do the following.

This doctoral thesis in fielding, entitled Architectural Styles and the design of network-based Software architectures (Chinese version of Architecture style and web-based software architecture) ), a set of web-based software (called "Distributed Application") design method is proposed, which is worthy of careful reading and deep understanding of all distributed application developers.

In the first three chapters of the thesis, fielding a set of methodologies for researching and evaluating software architecture on the basis of critically inheriting predecessors ' research results. The core of this methodology is the concept of "architectural style". Architecture style is a method of researching and evaluating software architecture design, which is more abstract than architecture. An architectural style is defined by a set of mutually collaborative architectural constraints. Schema constraints are constraints that the software's operating environment imposes on the architecture design.

In the fourth chapter of the thesis, fielding studies the requirements of the web such a distributed system for software architecture design. In the fifth chapter, Fielding the requirements of chapter fourth web as some architectural constraints, and deduces the new architecture style of rest by progressively adding various architectural constraints.

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.