Tuesday, June 26, 2012

some key characters about REST

Two important question for classifying web services:
1, The scoping information is kept in the URI. This is the principle of addressability
2, The method information is kept in the HTTP method, CRUD


Restful web service should be stateless, that's every request should contain the required information to make this request. The violation for this is using cookie to maintain the state. E.g. goolge search, i can bookmark the results page 10 of keywords jellyfish as q?search=jellyfish&page=10, server side doesn't need to maintain the page index information for the request, the request contains all the information needed for server to response it.


I'm reading the Restful Web Services' chapter4, and this stateless description makes me double thinking about our Mobile APP's Backend, I'm now using session cookie to authenticate users when he issues a request after logged in, such as updating profile. We are still heavily relying on the cookie based authentication procedure, this is not good to name it as Restful.


One difference between HTTP PUT and POST is that, with PUT the client should know what URI for the new created resource should be, and POST are more likely as operation append. Sometime, we may overload HTTP POST method as a process request to a resource, this method sometimes reduce the complexity(It's RPC style web service, that's  method information creep into other place instead of uniform HTTP Method). 


More words for overload POST, actually, if we stick with PUT to get (Read) information, and POST for modifying, deleting or creating a resource, it's still Restful.


ROA:
for concepts:
1, Resource
2, Their name(URI)
3, Their representation
4, THe links between them


for properties:
1, Addressability
2, statelessness
3, Connectedness
4, A uniform interface



No comments:

Post a Comment