Last active
January 3, 2017 08:51
-
-
Save zhaohangbo/2ef39968595aac2c3b89a3688dfed8b6 to your computer and use it in GitHub Desktop.
RESTful Web Service的教程
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RESTful Web Service的教程 | |
http://www.drdobbs.com/web-development/restful-web-services-a-tutorial/240169069?pgno=1 | |
http://www.drdobbs.com/web-development/restful-web-services-a-tutorial/240169069?pgno=2 | |
http://www.drdobbs.com/web-development/restful-web-services-a-tutorial/240169069?pgno=3 | |
概要: | |
1、Representations:可以用JSON或者XML来代表资源。 | |
2、Messages:Client和Service通过Message来交流。Client发送Http Request,Service回复Http Response。 | |
Http Request:Verb、URI、Version、Header、Body | |
Http Response:Response Code,Version、Header、Body | |
3、URIs | |
The URI should not say anything about the operation or action. | |
Use HTTP verbs to perform different operations. | |
4、Uniform Interface | |
Get | |
Put(幂等性) | |
Post | |
Delete | |
Options | |
Head | |
PUT 和 POST 的区别 | |
Request Operation | |
PUT http://MyService/Persons/ Won't work. PUT requires a complete URI | |
PUT http://MyService/Persons/1 Insert a new person with PersonID=1 if it does not already exist, or else update the existing resource | |
POST http://MyService/Persons/ Insert a new person every time this request is made and generate a new PersonID. | |
POST http://MyService/Persons/1 Update the existing person where PersonID=1 | |
5、Stateless | |
requests are all independently | |
6、Links between resources | |
<Persons> | |
<Person name="p1"> | |
<URI>http://MyService/Persons/1</URI> | |
</Person> | |
<Person name="p2"> | |
<URI>http://MyService/Persons/12</URI> | |
</Person> | |
</Persons> | |
7、Cacheing | |
Caching can be controlled using HTTP headers params | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment