api - How is data sent in REST web services -


i learning web services. have understanding of soap. have few questions regarding rest web services.

1) get, put & post methods in rest web services work same way work simple website.

2) , put & post methods in rest web services allows send/receive data(say: tweet in twitter) between client & web service. message sent(put & post) & received(get) in body of post/put method in xml/json/other formats or file(in specific format) sent separately.

3) there browser tools available see sent & received in rest web services.

first of all, clarifying few things. rest architectural style, set of constraints guide structural design decisions. rest not coupled particular underlying protocol, it's not dependent on http, although it's common.

second, keep in mind rest became buzzword refer http api isn't soap, , of called rest apis aren't rest @ all. of them simple rpc on http. recommend reading this answer clarification on that.

now, questions:

1) get, put & post methods in rest web services work same way work simple website.

the problem question exact definition of how methods work 1 defined rfcs, , simple website might implement differently. instance, put isn't allowed used partial updates, many websites , http apis that.

as said above, rest protocol independent, respecting uniform interface constraint , applying principle of generality, should stick standard semantics of underlying protocol as possible, means if you're using http 1.1, should stick behavior determined in rfcs 7230 7235.

2) , put & post methods in rest web services allows send/receive data(say: tweet in twitter) between client & web service. message sent(put & post) & received(get) in body of post/put method in xml/json/other formats or file(in specific format) sent separately.

the format established in previous contract between client , server -- in documentation -- , it's handled during request using accept , content-type headers. instance, if client wants json response, sends accept: application/json header. if server can't respond json, should fail 406 not acceptable.

keep in mind in actual rest webservice, don't use generic media-type application/json since says absolutely nothing content other how parse it. should have more specific media-types resources, , focus documentation on those. instance, user resource in json format can have custom media-type application/vnd.mycompany.user.v1+json.

3) there browser tools available see sent & received in rest web services

in google chrome can use developer tools, or client this or this. can use command line client curl.

also, keep in mind should pretty easy drop-in generic html+javascript client real rest api make navigable browser. here example of rest api using hal+json , generic client.

https://api-sandbox.foxycart.com/hal-browser/browser.html#/


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -