Hi John,
The proper/standard way in HTTP to do this is to correctly set the preferences of your clients (via the Accept header typically) Otherwise, the order of the annotated methods declaration might be taken into account by Restlet when deciding how to dispatch the method call, but I wouldnt say it is a safe bet to solely rely on this default behavior. You could customize the ConnegService attached to your parent application to force the variant when client preferences are not explicitly given (MediaType.ALL), or plug a custom filter in the routing chain to enforce your policy. Best regards, Jerome -- <http://www.restlet.org/> http://www.restlet.org <http://twitter.com/#!/jlouvel> http://twitter.com/#!/jlouvel De : John Wismar [mailto:[email protected]] Envoyé : mercredi 18 janvier 2012 19:11 À : [email protected] Objet : Using MetadataService to specify the default media type Hi, all- (Using Restlet JEE 2.1 RC, Java 7, Tomcat7.) I am writing a new service, and want to serve both a JSON and an XML version of my representations. I therefore have a @Get(json) handler and a @Get(xml) handler for each Resource. I have also enabled the extensions tunnel in my TunnelService, and this seems to be working without any difficulty. URLs that end with .json are retrieving the JSON representation, and URLs that end with .xml are retrieving the XML representation. Heres the problem Im having: If a URL is specified without a file extension, I want the service to default to sending the JSON representation. When the service is starting up, I used the MetadataService and specified that the default Media Type should be MediaType.APPLICATION_JSON. Despite this, the XML representation is being returned, and I cant figure out why. I used the MetadataService in a prior project to do exactly the same thing, and it worked without a problem. (That older project used Restlet JEE 2.0, Java6 and Tomcat 6, if thats relevant.) What could I be overlooking? Thanks for your help! -------------------------- John Wismar Alldata Technology 916-478-3296 ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2909926

