I've been playing around with Restlet(2.1 rc5) in the last week to get an
Android Client to communicate with a Restlet server using Java Objects
After some quirks I can now send and receive POJO objects successfully, but it
only works if I limit the number of parameters to one.
When I try so attatch more than one parameter I get a 415 - Unsupported Media
Type Error.
Restlet Interface:
public interface ParamTestRessource {
@Post
public void sendTwoParams(Long foo, String bla);
}
Client Code:
Engine.getInstance().getRegisteredConverters().clear();
Engine.getInstance().getRegisteredConverters().add(new JacksonConverter());
Engine.getInstance().getRegisteredConverters().add(new XmlConverter());
ClientResource cr = new ClientResource(serverURI+"paramTest");
ParamTestRessource paramTest = cr.wrap(ParamTestRessource.class);
paramTest.sendTwoParams(foo, bar);
+matching ServerRessource and Route on the server side
Exception on the Client:
Unsupported Media Type (415) - Unsupported Media Type
Exception on the Server:
Unable to convert a [application/json,UTF-8] representation into an object of
class java.lang.Long
org.codehaus.jackson.map.JsonMappingException: Can not construct instance of
java.lang.Long from String value 'asdf': not a valid Long value
I also tried using different MIME types(for example @Post("xml"))
Is there a special Converter I should use ? Or is this simply not supported in
Restlet ?
I know I can use ClientResource.getRequest().getAttributes().put(key, value)
but thats not what I want.
Thanks in advance for any help!
------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2972431