I’m trying to learn about restlets more coming from a soap-rpc background. One thing that I can’t seem to figure out how to do (and maybe isn’t possible) is to modify objects on requests or send back a copied version with modifications.
I’m trying to do something like this:
public interface AddressService {
@Get
Address addOnZipCode( Address address );
}
The server would be deployed out with the implementation and the client could make use of dynamic proxies to do its work.
The server starts just fine but when the client makes the call there is no indication on the server that the implementing method is being called. Furthermore, the client doesn’t error until the call to the server returns – the returned object is null?!?
Is what I’m trying to do here possible with restlets? If so, any ideas on what I might be doing wrong?
I can post more code if necessary.
Thanks in advance.
EDIT #1:
I’ve even tried simplifying it to not use custom objects:
@Post
String execute( String message );
I get the following:
INFO: Starting the default HTTP client
Exception in thread "main" Method Not Allowed (405) - Method Not Allowed
at org.restlet.resource.ClientResource$1.invoke(ClientResource.java:1615)
at $Proxy5.execute(Unknown Source)
I’m beginning to think this is not possible, thus, I have a hard time seeing how this is a viable alternative to SOAP+RPC web services.
EDIT #2:
It looks like this is possible based on examples in the book: “Restlets in Action”
public interface AccountsResource {
@Get("txt")
public String represent();
@Post("txt")
public String add(String account);
}
EDIT #3:
It turns out that simply hitting the “stop” button in my Eclipse console was not shutting down the server instance. Opening a browser to the server URL showed some fishy results – there were multiple old server instances running. After shutting them all down I got it to work. Ultimately the answer was to use @Post instead of @Get1.
Have a look at this:
http://wiki.restlet.org/docs_2.0/13-restlet/21-restlet/318-restlet/303-restlet.html
On the server side your implementation must be like so:
On the client side:
Edit: