Hi
On 24/01/13 10:17, Esteban Wagner wrote:
Hi,
I am implementing a jax-rs filter, and I need to read the associated
content of the message.
So I am doing this:
message.getContent(InputStream.class);
The problem is that then in the pipeline the JacksonJsonProvider gets
called in order to deserialize the content and as the input stream has
already been read it generates an Exception:
*No content to map to Object due to end of input.*
Which would be the most effective way to handle this?
1) Copy the inputStream into another input stream and replace the Message
input stream with this one so its available to read on Deserialization?
If you need to pre-process it before JacksonJsonProvider reads it then
yes, CXF CachedOutputStream can be useful for this;
global/pre-match or post-match ContainerRequestFilter (JAX-RS 2.0,
starting from CXF 2.7.0) can also be used for this or ReaderInterceptors
- note I've just spotted I may be not calling post-match
ContainerRequestFilter at the right time, so if you were to work with
ContainerRequestFilter - don't use post-match one for now
2) Move the jax-rs filter into a CXF filter to the READ phase so it would
already have the deserialized object on the message?
If it is acceptable to work with the deserialized object than yes, also
you can register a custom invoker which will see this object.
thanks, Sergey
3) ???
Many Thanks,
Esteban.