users@jersey.java.net

[Jersey] Re: Migrating RPC to REST

From: algermissen1971 <algermissen1971_at_me.com>
Date: Tue, 05 Apr 2011 12:10:30 +0000 (GMT)

HI Markus,


On 05 Apr, 2011,at 02:02 PM, Markus Karg <karg_at_quipsy.de> wrote:

> Hello Jersey Community,
>
>
>
> we're in the process of migrating some functionality from RPC to REST and stuck with an issue we'd like to discuss with you. :-)
>
>
>
> One of the business procedures we're migrating was implemented as a stored procedure. It actually did nothing special but just provided a copy of a rather big amount of records in a single transaction. You can think of it in terms of SQL as "INSERT FROM SELECT". In JAX-WS's RPC style it was just wrapped with a method of a @WebService that called the stored procedure But how to convert this to a RESTful style in JAX-RS? Our initial idea was to do a http GET to load the source, then forward that same XML body to a http POST. Obviously that is RESTful and simple to do, but it means moving a really, really big bunch of information twice over the web, just for the sake of RESTfulness (and it would be two transactions, obviously). Has anybody an idea how to RESTfully model this use case, so that the data is not transferred at all but we still can just call the existing stored procedure? The only idea we had would be doing RPC style, like http post with a Location-header pointing to the source. But obviously that is not very RESTful.
 
>
>
>
> Any ideas? :-)
 
Is there any reason why the data has to be moved to the client first?

Isn't the get-data->store-data activity purely a result of the client triggering a server-side state change?

Usually the thing to do is to find the domain concept behind this operation (e.g. order something) and then map that to a request (e.g POST an order representation). Just make sure you do not use an empty POST to tunnel the call - find the appropriate POST body by way of domain analysis.

HTH,

Jan 





>
>
> Regards
>
> Markus