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"
Just make an http request to the required URL with correct query string, or request body. For example you could use java. net. HttpURLConnection and then consume via connection.
You can definitely interact with RESTful web services by using URLConnection or HTTPClient to code HTTP requests. However, it's generally more desirable to use a library or framework which provides a simpler and more semantic API specifically designed for this purpose.
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...
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With