I'm still having trouble with this myself.  Trying to serve both JSON and XML 
representations of a resource that is called "world".

Here is what happens for 4 different test cases:

http://localhost:8080/world.xml

Fails!  I get this response:

The resource identified by the request is only capable of generating response 
entities which have content characteristics not acceptable according to the 
accept headers sent in the request

http://localhost:8080/world.xml/

works!  I get an xml representation of the resource.  I didn't mean to try this 
(I added the '/' by mistake) and then was surprised when this worked.  I tried 
removing the '/' and it still fails.

http://localhost:8080/world.json

works as intended

http://localhost:8080/world.json/

gives me the xml representation


So I get that the '/' shouldn't be there at all (as I said, I put it there by 
accident) but it would be nice if it behaved the same as the case with the 
slash - is this easy to do?

More importantly, any idea why '.json' works but '.xml' doesn't?  I've tried 
adding both 'MediaType.APPLICATION_XML' and 'MediaType.APPLICATION_ALL_XML' 
(though not at the same time) and still have no luck.

Any ideas?  

Thanks,
T

P.S.  Here is some code:

        protected void doInit() throws ResourceException {
                
                Map<Method, Object> variants = getVariants();
                
                
                List<Variant> getVariants = new ArrayList<Variant>();
                getVariants.add(new Variant(MediaType.APPLICATION_JSON));
                getVariants.add(new Variant(MediaType.APPLICATION_XML));
                
                variants.put(Method.GET, getVariants);
                setVariants(variants);
        }

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2361679

Reply via email to