tags:

views:

72

answers:

2

Hi, everyone,

I want to ask some questions about the REST call. I am the green for the REST call and I would like to like what is REST call and how to use the URL to send a REST call to the server. Can anyone give me some basic tutorial or link for my to reference?

Besides, if I want to send a REST call to the server, what should I do? Do I need to set something in the URL? or set something in the server? Thank you.

+2  A: 

REST is just a software architecture style for exposing resources.

  • Use HTTP methods explicitly.
  • Be stateless.
  • Expose directory structure-like URIs.
  • Transfer XML, JavaScript Object Notation (JSON), or both.

A typical REST call to return information about customer 34456 could look like:

http://example.com/customer/34456

Have a look at the IBM tutorial for REST web services

willcodejavaforfood
REST is not limited to any particular media types. Use test/plain, image/jpeg, text/html, application/xhtml, create your own.
Darrel Miller
+2  A: 

REST is somewhat of a revival of old-school HTTP, where the actual HTTP verbs (commands) have semantic meaning. Til recently, apps that wanted to update stuff on the server would supply a form containing an 'action' variable and a bunch of data. The HTTP command would almost always be GET or POST, and would be almost irrelevant. (Though there's almost always been a proscription against using GET for operations that have side effects, in reality a lot of apps don't care about the command used.)

With REST, you might instead PUT /profiles/cHao and send an XML or JSON representation of the profile info. (Or rather, I would -- you would have to update your own profile. :) That'd involve logging in, usually through HTTP's built-in authentication mechanisms.) In the latter case, what you want to do is specified by the URL, and the request body is just the guts of the resource involved.

http://en.wikipedia.org/wiki/Representational_State_Transfer has some details.

cHao
@cHao, thank you for your reply. But I still not completely understand. Do you mean that I have to set something in the .xml, or just add the para in the URL like GET.
Questions
@Questions: there usually aren't "params" the same way you'd use them in a GET request. `PUT /profiles/cHao` says what to do, since a RESTful service would expose `/profiles/cHao` as a resource (ie: i might also `GET /profiles/cHao` and get back an XML or JSON version of my profile), and the `PUT` part says i want to replace it. The only things that'd need setting are the request body (ie: the profile itself, which will usually be in XML or JSON) and either a username and password or a client certificate (since most services won't let strangers modify someone else's stuff).
cHao