Thanks for that Sergey, but I've had a success with my REST outInterceptors.
Instead of using an annotation on the service class I've added it to the
beans.xml and now its burst into life. Now I can see the content-type is
JSON hoorah.

Next problem is how to change the message ?? any clues

Thanks for all the help.



Sergey Beryozkin-3 wrote:
> 
> Hi
> 
>>
>> I'm trying to alter some output in a REST call. I want to wrap the JSON
>> output with a callback name. I've managed to get a filter to work (all my
>> attempts to get the OutInterceptor to work have failed). So now I've got
>> a
>> message object.
>>
>> To alter the message I thought I could use something like JSONStream os =
>> message.getContent(JSONStream.class); but this returns null. Anyone have
>> an
>> idea how I can alter the JSON.
> 
> JAXRS Output filters are invoked immediately after the invocation has
> returned but before a given method response has been 
> serialized into the output message.
> 
> So I think what you need to do in your response handler is to replace the
> actual OutputStream.class with a buffered/filter one, 
> wrapping the original one.
> 
> What will happen next is that a JSONProvider will write into this stream
> and I guess at this moment  you can transfrom the incoming 
> output bytes.
> 
> It's basically doing same thing you can do with Servlet filters.
> 
> Default JSONProvider does not append a JSONStream.class.
> 
> As such another option is actually write a custom JSON MessageVBodyWriter,
> possibly either extending the default one or simple 
> copying its code and updating its wtiteTo() method to do a pre-request
> specific JSON or something like that.
> Providers can have @Contexts like UriInfo, etc, injected so one can get
> some additional info from there.
> 
> Does it make sense or am I missing the point ?
> 
> Cheers, Sergey
> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Altering-JSON-Output-in-a-REST-service-tp20478852p20478852.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
>> 
> 
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Altering-JSON-Output-in-a-REST-service-tp20478852p20480532.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to