5

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"

Martin Magakian
  • 3,746
  • 5
  • 37
  • 53

3 Answers3

4

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
  • 5,773
  • 3
  • 40
  • 49
3

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
  • 83,208
  • 23
  • 172
  • 177
  • With Restlet I can send String, integer... But not Java OBJECT – Martin Magakian Jul 18 '09 at 14:25
  • 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 Jul 18 '09 at 14:39
1

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.

aehlke
  • 15,225
  • 5
  • 36
  • 45