Hi On Thu, May 12, 2011 at 2:11 PM, artur.chyzy <[email protected]> wrote: > Hello. > > I have a JAX RS service configured like this > > <jaxrs:server id="someServer" address="/someAddress"> > <jaxrs:serviceBeans> > <ref bean="someEndpoint" /> > </jaxrs:serviceBeans> > <jaxrs:providers> > <ref bean="jsonProvider" /> > </jaxrs:providers> > </jaxrs:server> > > The service correctly handles IN and OUT messages and converts them to > objects. > > But I have problem with accessing JSON content as a String (raw format). I > need this to correctly implement security as content is needed to calculate > MAC for each message (Message Authentication Code). > I tried to do it like this: > > @Context > MessageContext mc; > .... > IOUtils.toString(mc.getContent(InputStream.class), "utf-8"); > > but empty String is returned as input stream has no content (checked on > debug) > On the other hand mc.getContent(String.class) returns null > > It is strange as LogginInIntercetor from CXF is using the same technique. > Is there any way to get JSON message content as String ? > I'm presuming that you are trying to get InputStream after the IN parameter has already been populated ? If yes then you will need to duplicate current InputStream in RequestHandler filter and save it or the calculated MAC as a custom property on the message, and then do mc.get("json.mac") or similar...
Cheers, Sergey > Artur > > -- > View this message in context: > http://cxf.547215.n5.nabble.com/Accessing-JAXRS-JSON-content-directly-tp4390185p4390185.html > Sent from the cxf-user mailing list archive at Nabble.com. >
