什么是RESTful Web Services?

RESTful web services are built to work best on the Web. Representational State Transfer (REST) is an architectural style that specifies constraints, such as the uniform interface, that if applied to a web service induce desirable properties, such as performance, scalability, and modifiability, that enable services to work best on the Web. In the REST architectural style, data and functionality are considered resources and are accessed using Uniform Resource Identifiers (URIs), typically links on the Web. The resources are acted upon by using a set of simple, well-defined operations. The REST architectural style constrains an architecture to a client/server architecture and is designed to use a stateless communication protocol, typically HTTP. In the REST architecture style, clients and servers exchange representations of resources by using a standardized interface and protocol.

Restful web services 为的是在Web上工作的最好而创建的工具。Representational State Transfer (REST)是一种指定约束的设计风格,例如统一接口,它如果应用到webservice上将带来一些合适的特性,例如性能,可扩展性和可修改性,这些属性能够使services在Web上工作的最好。使用Rest设计风格,数据和功能都是被慎重考虑过的资源并且是通过Uniform Resource Identifiers (URIs) 来访问的。就像在Web上的链接。这些资源是按照一些简单并很好定义的的操作来采取行动的。Rest设计风格约束客户端/服务端统一用一种样式并且被设计成用一种无状态的通信协议,例如HTTP。在Rest的风格中,客户和服务端的交换代表资源用都在用标准的接口和协议。

The following principles encourage RESTful applications to be simple,lightweight, and fast:

如下规则鼓励Restful应用变的简单,轻重量,和迅速:


Resource identification through URI: A RESTful web service exposes a set of resources that identify the targets of the interaction with its clients. Resources are identified by URIs, which provide a global addressing space for resource and service discovery. SeeThe@PathAnnotation and URI Path Templatesfor more information.

资源通过URI定义:一个RESTful的 web service暴露一组资源用来鉴定和客户端交互的范围。资源通过URI来定义,这就提供了一个全球的地址空间来发现资源和服务。想要获得更多信息请查看The@PathAnnotation and URI Path Templates

Uniform interface: Resources are manipulated using a fixed set of four create, read, update, delete operations:PUT,GET,POST, andDELETE.PUTcreates a new resource, which can be then deleted by usingDELETE.GET retrieves the current state of a resource in some representation.POST transfers a new state onto a resource. See Responding to HTTP Methods and  Requestsfor more information.

统一接口:资源被一组4个已经被定义好的操作来操纵,create,read,update,delete:PUT,GET,POST,和DELETE。PUT创建一个新资源,可以通过DELETE删除。GET 用来获取一些表达式中的当前状态。POST 传递新的状态到一个资源。想要获得更多信息请查看 Responding to HTTP Methods and


Self-descriptive messages: Resources are decoupled from their representation so that their content can be accessed in a variety of formats, such as HTML, XML, plain text, PDF, JPEG, JSON, and others. Metadata about the resource is available and used, for example, to control caching, detect transmission errors, negotiate the appropriate representation format, and perform authentication or access control. SeeResponding to HTTP Methods and RequestsandUsing Entity Providers to Map HTTP Response and Request

Entity Bodiesfor more information.


自我描述消息:资源和他们的表达式并不挂钩因此它们内容的存取可以通过各种形式,例如 HTML,XML 纯文本,PDF,JPEG,JSON或者其它的形式。关于资源的元数据是有效并使用过的,例如,对于控制缓存,探测查询错误,协商适当的数据格式,执行验证或是控制权限。想要获得更多信息请查看Responding to HTTP Methods and RequestsandUsing Entity Providers to Map HTTP Response and Request


Stateful interactions through hyperlinks: Every interaction with a resource is stateless; that is, request messages are self-contained. Stateful interactions are based on the concept of explicit state transfer. Several techniques exist to exchange state, such as URI rewriting, cookies, and hidden form fields. State can be embedded in response messages to point to valid future states of the interaction. SeeUsing Entity Providers to Map HTTP Response and Request Entity Bodies and “Building URIs” in the JAX-RS Overview document for more information.

通过超链接实现状态交互:每次用资源进行交互都是无状态的,也就是,请求消息是独立的。状态交互是基于显式状态传输的概念。有一些技术是专门用来传输状态的,例如 URI 获取,cookies和隐藏表单,状态可以嵌套在返回消息中去指出有效的未来状态。想要获得更多信息请查看Using Entity Providers 去了解 HTTP返回和请求实体和“Building URIs” 在 JAX-RS 预览文件中获得更多的信息。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,084评论 19 139
  • 一说到REST,我想大家的第一反应就是“啊,就是那种前后台通信方式。”但是在要求详细讲述它所提出的各个约束,以及如...
    时待吾阅读 8,806评论 0 19
  • **2014真题Directions:Read the following text. Choose the be...
    又是夜半惊坐起阅读 13,501评论 0 23
  • 017年第4期百人工程 47号 Susie 2017年6月23号打卡 1.【音频】清华幼儿英语 1a Unit1-...
    029108296e5b阅读 1,544评论 0 0
  • 过简简单单的日子,和喜欢的人走遍世界。 表哥结婚的日子,远着远着就到了。早晨天刚亮的时候,被一个特别的电话叫醒,于...
    先生笔记阅读 3,607评论 0 2

友情链接更多精彩内容