« Return to Thread: Our REST implementation

Re: Our REST implementation

by Shahar Evron :: Rate this Message:

Reply to Author | View in Thread

One note about my example, which might be confusing: I mention SOAP as
one example of an RPC-style protocol. AFAIK REST does not define
specific protocols - REST is just the approach or service architecture,
while specific protocols are defined "ad hoc".

A REST response might be based on HTTP alone (just a 201 or 500 response
with no body), or send some data, which can be encoded in any way, and
the "Content-type" header is used to define how. I know JSON and XML are
popular data encapsulation methods, but since REST is not really a
protocol like SOAP is, it does not specify which data encapsulation
method should be used in REST services.

Shahar.

On Tue, 2007-05-29 at 18:26 +0300, Shahar Evorn wrote:

> I am not an expert on the subject, but I think the key difference
> between REST and RPC based web services is more philosophical:
>
> RPC (Remote Procedure Call), as the name suggests, is procedure focused,
> as SOAP and XMLRPC are. In practice, an RPC web serivce will usually
> present numerous procedures (or methods) than can be executed on a
> single resource (URL).
>
> REST (Representational State Transfer) on the other hand focuses on
> resources ("nouns") and allows several methods (usually CRUD like
> methods) to be executed on each resource. In the web services world,
> that would usually mean you have numerous resources (URLs, "nouns"), and
> you can execute a limited number of "methods" ("verbs") on each one
> (HTTP GET, PUT, POST, DELETE == CRUD).
>
> A service which, for example, allows a user to retrieve, add, update and
> delete articles in a blog, would be designed this way:
>
> RPC:
> POST http://example.com/blog/soap/articleManager.php
> (Call the same URL, while the SOAP request body defines the method and
> parameters)
>
> REST:
> GET    http://example.com/blog/rest/articles - get list of all articles
> PUT    http://example.com/blog/rest/articles - create a new article
> GET    http://example.com/blog/rest/articles/1 - retrieve article #1
> POST   http://example.com/blog/rest/articles/1 - update article #1
> DELETE http://example.com/blog/rest/articles/1 - delete article #1
>
> and so on. One might simply say that REST takes a different approach to
> mapping URLs to objects / methods / parameters, but I guess that under
> some circumstances there is more than that.
>
> There is something very appealing for HTTP freaks in REST I think
> because of the proper use of request methods (GET is never state
> changing while POST is, etc.).
>
> As I mentioned briefly earlier, I think it would be quite easy to
> implement a Rest_Server component (even if we name it differently) as
> some kind of subclass of some Zend_Controller modules - it looks like
> the REST URL to object / method / parameter mapping can be done quite
> easily with some smart Zend_Controller routing / dispatching rules or
> plug-ins.
>
> Shahar.
>
>
> On Tue, 2007-05-29 at 15:55 +0200, till wrote:
> > Shahar,
> >
> > On 5/28/07, Shahar Evorn <shahar.e@...> wrote:
> > > I did some more reading on this and it really does seem that our
> > > Rest_Server is more RPC oriented (eg. method focused and not resource
> > > focused) web service implementation.
> >
> > I had this discussion with a friend a while ago. I am not sure where
> > we left of - so can you provide an example where REST is less RPC and
> > more like ... whatever it is supposed to be? ;-))
> >
> >
> > Cheers,
> > Till


signature.asc (196 bytes) Download Attachment

 « Return to Thread: Our REST implementation