Learning rest together (3) -- how simple is rest?

Source: Internet
Author: User

Original address: http://rest.elkstein.org/

Learn rest: a tutorial

A fast-training courseRest-
Re
PresentationalSTateTRansfer, a new approach to systems architecture and a lightweight alternative to Web Services

Rest-transition of expressive state-quick learning tutorial, a new system architecture method that can replace the lightweight Web service protocol.

_______________________________________________________________________________________

We use a simple web service as an example to query the detailed information of a given user in the telephone number book application. We only have the user ID.

With Web Services and soap, the request looks like the following:

<?xml version="1.0"?><soap:Envelopexmlns:soap="http://www.w3.org/2001/12/soap-envelope"soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"> <soap:body pb="http://www.acme.com/phonebook">  <pb:GetUserDetails>   <pb:UserID>12345</pb:UserID>  </pb:GetUserDetails> </soap:Body></soap:Envelope>

(The specific content is not important. This is just an example .) This content (via the http post request) is sent to the server. The result may be an XML file, but the file will be embedded into the corresponding SOAP envelope as "payload.

So how does rest work? The query looks like the following:

http://www.acme.com/phonebook/UserDetails/12345

Note that this is not the content of the request message-it is just a URL. This URL uses a simple GET request to send a GET request to the server and then responds to the original result data through http-nothing is embedded, just the data you can use directly.

  • It is easy to see why Web services usually use libraries to create soap/HTTP, send requests, and process soap
  • With rest, you need a simple network connection. You can even use your browser to directly test the API
  • In addition, there are currently rest libraries (to simplify usage), which will be discussed later.

Note that the "method" part of the URL is not "getuserdetails", but a simple "userdetails ". By convention, nouns rather than verbs are used in rest design to refer to simpleResources.

Analogy through letters
The relationship between rest and SOPA can be seen as: soap is a letter with an envelope, while rest is a postcard. For recipients, postcards are easier to process and save on paper (that is, using less bandwidth) and short content (of course, there is no limit on the length of rest requests, especially when using post instead of get)

However, do not make further comparisons. What is different from letters and postcards is that every bit of rest is as secure as soap. Specifically, rest can be encrypted over Secure Sockets (using HTTP protocol) using an encryption algorithm that you think is appropriate. If there is no encryption, rest and soap are equally insecure and adopt appropriate encryption. Both are equally secure.

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.