RESTful 笔记

2017/02/12 iteye

REST(Representational State Transfer)是 Roy Fielding 提出的一个描述互联系统架构风格的名词。  

Another way to say REST is in HTTP, any request a client can make involves a URL and an HTTP method. With REST, the URL is designed to represent a noun and the HTTP method always maps to one of several standard verbs, which will be performed against that noun.In summary, each HTTP method will cause a well-defined action on the resource represented by the URL it operates on. The methods can be compared to SQL commands: GET is like "SELECT," DELETE is like "DELETE," POST is like "INSERT" with an auto-generated ID, and PUT is like "INSERT OR UPDATE IF EXISTS" with an ID specified.  

REST 指的是一组架构约束条件和原则。满足这些约束条件和原则的应用程序或设计就是 RESTful.

  1. stateless 有利于scalabilty,cluster 客户端可用cache提高性能  
  2. 分层 这表示组件无法了解它与之交互的中间层以外的组件,这是博士论文中提到的,不是很理解  
  3. Get/Put/Delete方法的幂等性    
  4. Security

与SOAP架构相比,REST架构的优点是:

  • SOAP接口隐藏在SOAP Envelope中了,对外暴露的是相同的URL(对于同一个web service), 不利于代理服务器根据HTTP method做安全控制, 除非解析SOAP Envelope 内容。  
  • SOAP 采用HTTP Post也不利于浏览器做cache

Search

    Table of Contents