Hi Benji
On 27/02/12 19:47, Benji Shults wrote:
Glen,
I'm using CXF 2.5.2. I haven't made any changes to JAXRSOutInterceptor.
The only interceptors I've added are the built-in
LoggingIn/OutInterceptors.
When JAXRSOutInterceptor calls writer.writeTo, that writer writes to the
message's outputStream then throws an exception. Looking at the code in
JAXRSOutInterceptor, I see that it does this:
message.put(Message.RESPONSE_CODE, 500) // line 362
However, my HTTP client sees a response code of 200.
The writer I wrote myself and introduced it using the following:
<jaxrs:providers>
<bean
class="com.ecologic.sdc.webservice.JsonUsageResponseValidatingProvider"
/>
</jaxrs:providers>
If the response payload is not huge then consider buffering the
response, see some information within this section:
http://cxf.apache.org/docs/jax-rs-data-bindings.html#JAX-RSDataBindings-ConfiguringJAXBprovider
that needs to be moved into the dedicated section though.
If the provider is not JAXB-driven then having a getEnablingBuffering()
method returning 'true' on this provider will instruct the runtime to
provide a CachedInputStream to the provider.
Can you try it please ?
Sergey
Benji
-----Original Message-----
From: Glen Mazza [mailto:[email protected]]
Sent: Monday, February 27, 2012 1:39 PM
To: [email protected]
Subject: Re: response_code 500 ignored when set in
JAXRSOutInterceptor.handleWriteException
Can you give a very generic version of that interceptor that would
duplicate/demonstrate the problem?
Glen
On 02/27/2012 02:36 PM, Benji Shults wrote:
I have a scenario where the call to writer.writeTo in
JAXRSOutInterceptor.serializeMessage throws an exception.
Before throwing the exception, the writer writes to the message's
outputStream.
When write.writeTo throws the exception, handleWriteException calls
message.put(Message.RESPONSE_CODE, 500).
However, my HTTP client is seeing the response come back with HTTP
response code 200.
The following is appended to the response that the writer put into the
message's outputStream:
Error serializing the response, please check the server logs, response
class : UsageResponse.
Benji
--
Sergey Beryozkin
Talend Community Coders
http://coders.talend.com/
Blog: http://sberyozkin.blogspot.com