资源

在Rest的架构之内,讲一切内容都是为资源。每一个资源都被定义为一个URI。

格式: <protocol>://<service-name>/<ResourceType>/<ResourceID>

除此之外,URI的另一个关键部分为“VERB“, 相应的我们也称他们为“方法”。他们通常有四种形式 -- GET/POST/PUT/UPDATE

关于资源的表述,Rest有多种形式的表述方式,其中以XML和JSON最为常用。

消息

Rest 采用HTTP协议作为client和server之间的传输媒介。 client 通过发送 HTTP Request 到 Server;Server 发送 HTTP Response 到 client。

为了方便理解,通过图文并茂的方式来解释一下 HTTP Request/Response.

以下部分摘自: https://www.tutorialspoint.com/restful/restful_messages.htm

HTTP Request

A HTTP Request has five major parts:

  • Verb- Indicate HTTP methods such as GET, POST, DELETE, PUT etc.

  • URI- Uniform Resource Identifier (URI) to identify the resource on server

  • HTTP Version- Indicate HTTP version, for example HTTP v1.1 .

  • Request Header- Contains metadata for the HTTP Request message as key-value pairs. For example, client ( or browser) type, format supported by client, format of message body, cache settings etc.

  • Request Body- Message content or Resource representation.

HTTP Response

A HTTP Response has four major parts:

  • Status/Response Code- Indicate Server status for the requested resource. For example 404 means resource not found and 200 means response is ok.

  • HTTP Version- Indicate HTTP version, for example HTTP v1.1 .

  • Response Header- Contains metadata for the HTTP Response message as key-value pairs. For example, content length, content type, response date, server type etc.

  • Response Body- Response message content or Resource representation.

Example

As we have explained in RESTful Web Services - First Application tutorial, Let's put http://localhost:8080/UserManagement/rest/UserService/users in POSTMAN with GET request. If you click on Preview button residing near send button of Postman and then click on Send button, you may see the following output.

Here you can see, the browser sent a GET request and received a response body as XML.

Rest之路 - Rest架构中的重要概念的更多相关文章

  1. Rest之路 - Rest架构中的重要概念(二)

    状态无关性 Rest 架构中不维持client,resource and request 的状态,我们通常称 Rest 服务是状态无关的.基于此的优势是为设计Rest架构提供了简便:每一个请求可以被完 ...

  2. 分享一个CQRS/ES架构中基于写文件的EventStore的设计思路

    最近打算用C#实现一个基于文件的EventStore. 什么是EventStore 关于什么是EventStore,如果还不清楚的朋友可以去了解下CQRS/Event Sourcing这种架构,我博客 ...

  3. [译]Google官方关于Android架构中MVP模式的示例

    概述 该示例(TODO-MVP)是后续各种示例演变的基础,它主要演示了在不带架构性框架的情况下实现M-V-P模式.其采用手动依赖注入的方式来提供本地数据源和远程数据源仓库.异步任务通过回调处理. 注意 ...

  4. 大型 JavaScript 应用架构中的模式

    原文:Patterns For Large-Scale JavaScript Application Architecture by @Addy Osmani 今天我们要讨论大型 JavaScript ...

  5. [转]大型 JavaScript 应用架构中的模式

    目录 1.我是谁,以及我为什么写这个主题 2.可以用140个字概述这篇文章吗? 3.究竟什么是“大型”JavaScript应用程序? 4.让我们回顾一下当前的架构 5.想得长远一些 6.头脑风暴 7. ...

  6. 三层架构中bll层把datatable转换为实体model的理解

    看了很多人的项目,很多都是用到三层架构,其中BLL层中有一种将DataTable转换为实体的方法.一直没有明白为啥要这样做,今天特意去搜索了一下,如果没有答案我是准备提问,寻求解答了.还好找到一个相关 ...

  7. 谈谈三层架构中Model的作用

    Model又叫实体类,这个东西,大家可能觉得不好分层.包括我以前在内,是这样理解的:UI<-->Model<-->BLL<-->Model<-->DAL ...

  8. linux驱动程序之电源管理之新版linux系统设备架构中关于电源管理方式的变更

    新版linux系统设备架构中关于电源管理方式的变更 based on linux-2.6.32 一.设备模型各数据结构中电源管理的部分 linux的设备模型通过诸多结构体来联合描述,如struct d ...

  9. 微服务架构中API网关的角色

    [上海尚学堂的话]:本文主要讲述了Mashape的首席技术执行官Palladino对API网关的详细介绍,以及API网关在微服务中所起的作用,同时介绍了Mashape的一款开源API网关Kong. A ...

随机推荐

  1. js 深拷贝和浅拷贝理解

    作者:进击的袋鼠链接:https://www.zhihu.com/question/23031215/answer/124017500来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载 ...

  2. 【C#基本功 控件的用法】 委托

    接触C#这段时间,很多内容容易理解,但也也有很多内容总是无法踏过门槛,就像Delegate 委托,这种新的机制是Labview不具备的,他的一个用法,也让我们这些从labview跨越过来的coder, ...

  3. 地图Legend控件的使用

    http://support.esrichina-bj.cn/2011/0318/1150.html

  4. 解决:pipenv shell报错:AttributeError: 'module' object has no attribute 'run'

    利用pipenv shell切换到虚拟环境时,显示报错:AttributeError: 'module' object has no attribute 'run' 可以看到是d:\program\p ...

  5. 在Hive中使用Avro

    作者:过往记忆 | 新浪微博:左手牵右手TEL | 可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明博客地址:http://www.iteblog.com/文章标题:<在Hiv ...

  6. 017对象——对象 get_object_vars get_parent_class is_subclass_of interface_exists

    <?php /** */ //get_object_vars($obj) 获得对象的属性,以关联数据形式返回. /*class study{ public $name; public $age; ...

  7. 【2018年全国多校算法寒假训练营练习比赛(第四场)- E】通知小弟(强连通缩点)

    题目链接:https://www.nowcoder.com/acm/contest/76/E 题目描述         在战争时期,A国派出了许多间谍到其他国家去收集情报.因为间谍需要隐秘自己的身份, ...

  8. keras&tensorflow+分布式训练︱实现简易视频内容问答框架

    内容来源:Keras 之父讲解 Keras:几行代码就能在分布式环境训练模型 把 Keras API 直接整合入 TensorFlow 项目中,这样能与你的已有工作流无缝结合.至此,Keras 成为了 ...

  9. js类 的小例子

    class Flyer { constructor(fname, speed) { this.fname = fname; this.speed = speed; } fly(){ console.l ...

  10. C高级第一次作业附加

    之前的作业链接:http://www.cnblogs.com/1204113692yang/p/8625650.html 过去两周学习了指针的概念.指针变量的定义.指针的基本运算.指针操作改变主调函数 ...