Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
The moose likes Web Services and the fly likes Exposing Methods as RESTFul Services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Exposing Methods as RESTFul Services" Watch "Exposing Methods as RESTFul Services" New topic

Exposing Methods as RESTFul Services

Ali Reza Hosseini
Ranch Hand

Joined: Apr 28, 2005
Posts: 33

I am having a method which has two parameters in its signature like this:

What I want to do is to make this method available via REST like this:

Is it possible to expose this method as a RESTFul service method although it has more than one entity in its signature?

I ask this because in jersey's api I do not see any way to pass more than one entity to the webResource when calling post()-method.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
I am afraid that the subject of your posting - "exposing methods as RESTful services" shows that it would be good to read a little about the concepts behind RESTful web services before trying to implement one.
RESTful web services are not about exposing operations, it is about exposing resources on which you perform a very limited set of operations (usually GET, POST, PUT, DELETE).
Of course you can expose your method as a web service, but it won't be REST. In your case RPC would be a viable option:

If you want to create a RESTful web service that creates orders, then you can POST the representation of an order, consisting of, among other things, a number of items, to, for instance, http://myserver/resources/orders.
Best wishes!

My free books and tutorials:
It is sorta covered in the JavaRanch Style Guide.
subject: Exposing Methods as RESTFul Services