Hi Sergey,
On Thu, Jan 8, 2015 at 7:51 PM, Sergey Beryozkin <[email protected]> wrote:
> Hi
>
> The response content type is determined early now when a resource method is
> selected and it is the intersection between Accept and @Produces
Thanks for the pointer, my services were missing the @Produces
annotation, adding them fixes the issue.
Still, since the default value of the @Produces annotation is */* and
the specification explicitly states that "In the absence of
either of these annotations [@Consumes, @Produces], support for any
media type (“*/*”) is assumed" shouldn't that match an Accept header
of text/html,application/xhtml+xml,application/xml? To be clear,
explicitly adding an empty @Produces annotation, or @Produces({*/*})
help neither, only exact matches work: @Produces({"application/xml",
"application/json"}. The star simply seems to be interpreted as a
string literal instead of a wild card.
--
Unico
>
> Perhaps you need to introduce some qs qualifiers to make the intersection
> more deterministic ?
>
> Can you provide more info please ? The method signature, the actual Accept
> value (with all the 'q' qualifiers) ?
>
> Thanks, Sergey
>
>
> On 08/01/15 18:06, Unico Hommes wrote:
>>
>> I have been upgrading my application from CXF 2.6 to 3.0 and
>> encountered a difference to the way JAXRSOutInterceptor selects a
>> WriterInterceptor to serialize a message based on the Accept header.
>> It used to be that if you sent a request with an Accept header of
>> text/html,application/xhtml+xml,application/xml (like a regular
>> browser does), a WriterInterceptor would be selected based on that [1]
>> if no Content-Type header was sent along. But in 3.0 this is no longer
>> the case, only the Content-Type header is used [2]. The problem is
>> that when I now want to browse my REST service I get a server error
>> instead of the xml output I was expecting. This is because my browser
>> does not send a Content-Type header but only an Accept header. Was
>> this a change required by the spec or is this a bug?
>>
>> Regards,
>> Unico
>>
>> 1.
>> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.cxf/cxf-bundle/2.6.16/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java#JAXRSOutInterceptor.computeAvailableContentTypes%28org.apache.cxf.message.Message%2Cjavax.ws.rs.core.Response%29
>>
>> 2.
>> http://grepcode.com/file/repo1.maven.org/maven2/org.apache.cxf/cxf-rt-frontend-jaxrs/3.0.2/org/apache/cxf/jaxrs/interceptor/JAXRSOutInterceptor.java#213
>>
>