On Mon, Sep 14, 2009 at 04:20:11PM +0100, Dário Abdulrehman wrote:
> Hi,
> I would like to add make my web services available using the usual
> http:/<host>/service.<format>
> Where format is one of json, xml or rdf.
> I am aware that I can use the @Produces annotation and use the accept header
> parameter but I also want to provide a more convenient alternative, as it is
> common practice.
>
> I tried the following @Path("service{returntype: [\\.json|\\.xml|\\.rdf]}")
> and then in the request method I check the returntype to see how do I return
> the response.
> But this doesn't work. What is the correct way to accomplish this?
Please see [1]. You should be able to add your mappings to the resource config
like follows:
rc.getMediaTypeMappings().put("xml", MediaType.valueOf("application/xml"));
~Jakub
[1]
https://jersey.dev.java.net/nonav/apidocs/1.1.2-ea/jersey/com/sun/jersey/api/core/ResourceConfig.html#getMediaTypeMappings()
>
> Thanks
--
Jakub Podlešák, Software Engineer
Web Services and Technologies, SUN Microsystems
http://blogs.sun.com/japod