Hello, I've just had a look in the code. I'm using @Get("txt") on toPlainText() and @Get("xml") on toXml().
In ServerResource.getAvailableVariants(Method), when it goes through: annoVariants = cs.getVariants(annotationInfo .getJavaReturnType(), new Variant( (MediaType) metadata)); the values are: - annotationInfo.getJavaReturnType() -> Representation - metadata -> MediaType.PLAIN_TEXT Then, in ConverterService.getVariants, helperVariants = ch.getVariants(sourceClass); helperVariants is a list that contains only the octet-stream media type. What I guess from this is that the Representation type is considered to be able to be converted only to an octet-stream and the text/plain media type is never going to be considered in the rest of ServerResource.getAvailableVariants. This seems a bit surprising. ServerResource.java doesn't seem to be formatted properly in revision 5060, by the way. Best wishes, Bruno. Bruno Harbulot wrote: > Hi Jerome, > > Is there a full list of the annotation parameters? > According to these pages, they're not media-types: > - http://wiki.restlet.org/developers/172-restlet/226-restlet.html > - > http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=1596334 > > > I'm using revision 5060. > > > * Case 1: > > public class MyResource extends ServerResource { > @Override > public void doInit() throws ResourceException { > ... > setNegotiated(true); > } > > @Get("xml") > public Representation toXml() { > ... > } > } > > > Using a client with "application/xml, text/xml", I get this: > > GET /1/ HTTP/1.1 > Host: localhost:8182 > User-Agent: Noelios-Restlet/2.0snapshot > Accept: application/xml, text/xml > Connection: close > > HTTP/1.1 406 > ... > > > > * Case 2, same with @Get("text/xml") or @Get("application/xml"), I get this: > > GET /1/ HTTP/1.1 > Host: localhost:8182 > User-Agent: Noelios-Restlet/2.0snapshot > Accept: application/xml, text/xml > Connection: close > > HTTP/1.1 200 The request has succeeded > Content-Type: application/xml > ... > > > > * Case 3, with two @Get methods: > > public class MyResource extends ServerResource { > @Override > public void doInit() throws ResourceException { > ... > setNegotiated(true); > } > > @Get("application/xml") > public Representation toXml() { > ... > } > > @Get("text/plain") > public Representation toPlainText() { > ... > } > } > > > For a "plain/text" request, I get this: > > GET /1/ HTTP/1.1 > Host: localhost:8182 > User-Agent: Noelios-Restlet/2.0snapshot > Accept: text/plain > Connection: close > > HTTP/1.1 200 The request has succeeded > Content-Type: application/xml > Date: Fri, 12 Jun 2009 10:55:18 GMT > Accept-Ranges: bytes > Server: Noelios-Restlet/2.0snapshot > Connection: close > Transfer-Encoding: chunked > > d3 > <?xml version="1.0" encoding="UTF-8"?> > ... > > > > * Case 4, same as case 3, but swapping the order of toXml and > toPlainText in the class: > > GET /1/ HTTP/1.1 > Host: localhost:8182 > User-Agent: Noelios-Restlet/2.0snapshot > Accept: text/plain > Connection: close > > HTTP/1.1 200 The request has succeeded > Content-Type: text/plain; charset=ISO-8859-1 > ... > > > > > I'm not sure I understand the values of the @Get/@Put annotation > parameters. I thought they weren't media-types, but cases 1 and 2 seem > to suggest otherwise. If they're meant to be media-types, cases 3 and 4 > suggest content-type negotiation doesn't work. > > Could you clarify how it's meant to work? > > > Best wishes, > > Bruno. > > ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2361588