REST系统和基于REST的系统之间的区别是什么?

从我读到的一些东西来看,所谓的REST服务实际上就是RESTful服务。那么两者之间的区别是什么呢?


当前回答

REST stands for representational state transfer. That means that state itself is not transferred but a mere representation of it is. The most common example is a pure HTML server based app (no javascript). The browser knows nothing about the application itself but through links and resources, the server is able transfer the state of the application to the browser. Where a button would normally change a state variable (e.g. page open) in a regular windows application, in the browser you have a link that represents such a state change.

这个想法就是使用超媒体。也许还能创造出新的超媒体类型。我们可以用javascript/AJAX扩展浏览器,并创建新的自定义超媒体类型。这样我们就有了一个真正的REST应用程序。

This is my short version of what REST stands for, the problem is that it is hard to implement. I personally say RESTful, when I want to make reference to the REST principles but I know I am not really implementing the whole concept of REST. We don't really say SOAPful, because you either use SOAP or not. I think most people don't do REST the way it was envisioned by it's creator Roy Fielding, we actually implement RESTful or RESTlike architectures. You can see his dissertation, and you will find the REST acronym but not the word RESTful.

其他回答

REST是一种用于分布式软件的软件体系结构

遵循REST约束被称为“RESTful”。

如今,它被广泛用于构建web服务,作为SOAP的替代方案。

这里有一些链接需要检查

http://en.wikipedia.org/wiki/Representational_State_Transfer http://www.computerworld.com/s/article/297424/Representational_State_Transfer_REST_ http://www.ibm.com/developerworks/webservices/library/ws-restful/

REST stands for representational state transfer. That means that state itself is not transferred but a mere representation of it is. The most common example is a pure HTML server based app (no javascript). The browser knows nothing about the application itself but through links and resources, the server is able transfer the state of the application to the browser. Where a button would normally change a state variable (e.g. page open) in a regular windows application, in the browser you have a link that represents such a state change.

这个想法就是使用超媒体。也许还能创造出新的超媒体类型。我们可以用javascript/AJAX扩展浏览器,并创建新的自定义超媒体类型。这样我们就有了一个真正的REST应用程序。

This is my short version of what REST stands for, the problem is that it is hard to implement. I personally say RESTful, when I want to make reference to the REST principles but I know I am not really implementing the whole concept of REST. We don't really say SOAPful, because you either use SOAP or not. I think most people don't do REST the way it was envisioned by it's creator Roy Fielding, we actually implement RESTful or RESTlike architectures. You can see his dissertation, and you will find the REST acronym but not the word RESTful.

在Richardson成熟度模型中定义了4个级别的API。这些被定义为:

level 0: any system that has a single endpoint for all its apis(SOAP or RPC fall in this category). Level 0 apis can also resemble "commands". level 1: a ResourceUri described system. This is a system that defines multiple entity-based URIs (instead of having a single endpoint like a level 0 systems would). These URIs can use different http actions (POST, GET, PUT, etc) to implement different actions against that resource. level 2: aka level 1 w/ a compliant use of Standard HTTP methods/verbs and multi status code responses level 3: aka level 2 plus HATEOAS (hypermedia included in the response which describes additional calls you can make)

虽然级别1、级别2和级别3可以被认为是REST系统,但只有更严格的级别(即级别2和级别3)才被认为是RESTful的。

所以本质上所有的RESTful api都是REST api,但并不是所有的REST api都是RESTful的

理查德森成熟度模型的定义

基于REST的服务/架构vs.基于REST的服务/架构

为了区分或比较这两者,您应该了解REST是什么。

REST(具象状态传输)基本上是一种具有以下原则的开发架构风格:

它应该是无状态的 它应该只使用URI访问来自服务器的所有资源 它没有内置加密 它没有会话 它使用一个且只有一个协议——HTTP 为了执行CRUD操作,它应该使用HTTP动词,如get、post、put和delete 它应该只以JSON或XML、atom、OData等形式返回结果(轻量级数据)。

基于REST的服务遵循上面的一些原则,但不是全部

RESTFUL服务意味着它遵循上述所有原则。

它类似于:

面向对象语言支持所有面向对象的概念,例如:c++, c#

基于对象的语言支持一些面向对象的特性,例如:JavaScript, VB


例子:

asp.net MVC 4是基于rest的,而Microsoft WEB API是基于rest的。

MVC只支持上述REST原则中的一部分,而WEB API则支持上述所有REST原则。

MVC只支持REST API中的以下内容

我们可以使用URI访问资源 它支持HTTP谓词从服务器访问资源 它可以以JSON、XML的形式返回结果,也就是HTTPResponse。

然而,同时在MVC中

我们可以使用会话 我们可以让它有状态 我们可以从控制器动作方法返回视频或图像,这基本上违反了REST原则

这就是为什么MVC是基于rest的,而WEB API支持上述所有原则并且是RESTFul的。

REST(表示状态传输)是一种用于创建WebServices的体系结构。

and

RESTful是一种使用REST体系结构编写服务的方式。RESTful服务公开资源,以识别与客户机交互的目标。