Is there a way to access CXF messaging from a JAX-RS REST resource in CXF?

We currently have a RESTful API using CXF 2.4.2. In one of my resource methods, I would like to process some query parameters and store the result in CXF messaging for later use of the output interceptor.

I tried to insert a WebServiceContext, as mentioned here , but it does not seem to work, perhaps because it is part of JAX-WS, and we use JAX-RS.

Any help would be greatly appreciated!

+2
source share
2 answers

The simplest if using CXF is simply:

PhaseInterceptorChain.getCurrentMessage() 

This will work on JAXWS and JAXRS.

+15
source

Injecting org.apache.cxf.jaxrs.ext.MessageContext should do the same, but Dan code suggests leading to a simpler code if JAXWS and JAXRS are combined

0
source

Source: https://habr.com/ru/post/1437442/


All Articles