views:

367

answers:

3

Hi, I'm searching a nice way to send a java object to my rest web service.
It's possible or not ?


For sample I wan't to send an "User" Object to my rest :

public Class User{
    private String name;
    private String surname;

    public getName(){
     return name;
    }

    public setName(String name){

      [...]
 }

It's possible to generate AUTOMATICALY this kind of Rest ?
www.foo.com/createUser/name="foo"&surname="foo"

+1  A: 

Have a look at Restlet. The tutorial shows you how to get started.

Restlet allows you to use a number of representation formats, including XML and JSON.

Rich Seller
With Restlet I can send String, integer... But not Java OBJECT
You have to send some representation of the object, restlet provides a mechanism to map the requests to a URL pattern and send serialised representations over http. If you want to send objects you need to look at something like RMI, but then that is not RESTful, and still involves marshalling and unmarshalling
Rich Seller
+1  A: 

I would consider using a JSON representation for this kind of Java objects. I prefer the Jersey implementation of JAX-RS and it has built-in support for JSON serialization over JAXB.

Hope this helps...

Shimi Bandiel
A: 

It's possible to generate AUTOMATICALY this kind of Rest ? www.foo.com/createUser/name="foo"&surname="foo"

That's NOT REST. That's RPC.

Wahnfrieden