RE: Using GWT extension takes over the content negotiation!
Hello, I've made several tests, I send you a sample GWT application (with the gwt and xstream server extensions) based on the restlet 2.0.3 gwt and jee editions. The server resource is defined as follow: public class ContactServerResource extends ServerResource { @Get public Contact represent() { Contact result = new Contact(); result.setId((String) getRequestAttributes().get("contact")); result.setName("Peter Frampton"); result.setAddress("3 guitarhero road"); return result; } } When requested with curl, I get correct entities: $> curl -H "Accept: application/json" http://localhost:/rest/contacts/123 {"org.restlet.test.gwt.shared.Contact":{"address":"3 guitarhero road","id":123,"name":"Peter Frampton"}} $> curl -H "Accept: application/xml" http://localhost:/rest/contacts/123 3 guitarhero road 123 Peter Frampton $> curl -H "Accept: application/x-java-serialized-object+gwt" http://localhost:/rest/contacts/123 //OK[4,3,2,1,["org.restlet.test.gwt.shared.Contact/2215204171","3 guitarhero road","123","Peter Frampton"],0,5] I hope this will help you. Best regards, Thierry Boileau -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2686261
RE: Using GWT extension takes over the content negotiation!
Thanks Thierry for your prompt reply. The issue still persists in release 2.0.3; without the @Get("xml|gwt") annotation, the target Variant is always null resulting in the GwtConverter and XStreamConverter score() methods both returning 0.5. Because GwtConverter comes first in my build, it is always selected over the XStreamConverter. Now it seems that it is *after* the converter is selected that the Accept header is processed (for the "preferredVariant"?). So in this case, the GwtConverter is asked to provide either "application/xml" or "application/x-java-serialized-object+gwt", for which it will always provide the latter representation. I'm not highly experienced with Restlet so please forgive me if my understanding isn't entirely correct. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2681769
RE: Using GWT extension takes over the content negotiation!
Hello, you can do a little bit shorter getMetadataService().addExtension("gwt", MediaType.APPLICATION_JAVA_OBJECT_GWT); and @Get("xml|gwt") However, this sounds like a bug. When requesting the "xml" variant you should be returned an XML representation. Could you make a try with the 2.0.3 release? Best regards, Thierry Boileau -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2681273
RE: Using GWT extension takes over the content negotiation!
Ok, I don't know if this is idiomatic Restlet, but I solved the issue by doing this: @Override public Restlet createInboundRoot() { getMetadataService().addExtension("x-java-serialized-object+gwt", MediaType.APPLICATION_JAVA_OBJECT_GWT); ... And annotating the ServerResource method with: @Get("xml|x-java-serialized-object+gwt") ... Tracing org.restlet shows the right converter is selected, XStreamConverter or GwtConverter respectively. -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2681183
Using GWT extension takes over the content negotiation!
Hi Restlet team, I'm using Restlet 2.0.1 JEE edition, with both the GWT and XStream extensions. The idea is to have a web service that ordinarily returns XML representations of POJOs except when called from Restlet GWT. However despite setting the "Accept" header of the request, e.g. "Accept: application/xml", Restlet will always negotiate to return the GWT serialized object. What could I be doing wrong? Is there a way to see how Restlet comes to choose the GwtConverter, or perhaps lower its priority? Regards Lukito (ltruong at itree dot com dot au) -- http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2680916