users@jersey.java.net

Re: [Jersey] Serving another MIME than requested

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Mon, 22 Mar 2010 07:59:12 +0100

On Mar 20, 2010, at 8:39 AM, Markus Karg wrote:

>>> I have the need that my JAX-RS resource shall produce application/
>>> foobar+xml when a client actually request test/xml. How can I do
>>> that? When I just specify @Produces("application/foobar+xml") then a
>>> request for test/xml is rejected with 406. :-(
>>>
>>> Any ideas (besides manually setting the response header)?
>>>
>>
>> Other than manually doing:
>>
>> @Produces("application/foobar+xml, text/xml")
>> public Response x(...) {
>> return Response.ok(..., "application/foobar+xml").build();
>> }
>>
>> you would need to write a resource-specific filter and use an
>> annotation to declare media type mappings, such that the filter would
>> modify the accept header accordingly.
>
> Paul, thank you once more for sharing your ideas. As once more it's
> microsoft that's requesting the wrong MIME (they love doing false
> things as
> it seems), this shouts for another addition to the Microsoft Interop
> filter... ;-)
>
> If you're asking yourself what strange thing I'm doing: I'm trying
> to set up
> a OpenSearch provider on JAX-RS, which actually works well,

Cool! is this an open source thing?

Paul.