Rest之路 - 介绍篇

What is REST ?

REST 是 REpresentational State Transfer 的缩写。是一种基于HTTP协议来进行进行数据交换的web标准框架。她的思想是:视组件为资源。REST可以分成Client与Server。顾名思义,server用来提供资源,client用来呈现资源。在Rest中的每一个资源都可以被URL所描述和定义。在REST有多种表现形式中(text, xml etc...),JSON成为了目前最为流行的一种方式。

 

HTTP Methods

以下是常见的HTTP方法,她们构成REST基础架构的一部分。 

GET - Provides a read only access to a resource.

 

PUT - Used to create a new resource. 

 

DELETE - Used to remove a resource.

 

POST - Used to update a existing resource or create a new resource.

 

OPTIONS - Used to get the supported operations on a resource.

 

RESTFul Web Services

web service 是由许多协议和标准共同构建的,用于在系统与软件之间传递数据的集合。她不受编程语言以及平台(OS)的限制,只需通过网络以及HTTP协议,即可完成数据交换的工作。

 

RESTful web services 是一种基于REST架构的,使用HTTP方法实现 web service 实现。她通常讲service定义为URI (Uniform Resource Identifier),并将资源JSON +一组 HTTP Methods 的方式提供/暴露给调用者。

 

A sample of  RESTFul Web Services

This tutorial will create a web service say user management with following functionalities

Sr. No.HTTP MethodURIOperationOperation Type
1 GET /UserService/users Get list of users Read Only
2 GET /UserService/users/1 Get User with Id 1 Read Only
3 PUT /UserService/users/2 Insert User with Id 2 Idempotent
4 POST /UserService/users/2 Update User with Id 2 N/A
5 DELETE /UserService/users/1 Delete User with Id 1 Idempotent
6 OPTIONS /UserService/users List the supported operations in web service Read Only

posted @ 2017-01-11 22:26  TonyZhang24  阅读(227)  评论(0编辑  收藏  举报