rvillablanca
rvillablanca

Reputation: 1646

Sharing data between CXF interceptor and webservice

I'm using security interceptors with Apache CXF WSS4JInInterceptor.

Is there any way to pass data from interceptor to webservice?

I've been searching for that in WebServiceContext but I can't find it.

Upvotes: 1

Views: 2260

Answers (1)

Patrick
Patrick

Reputation: 2122

You can use the CXF Exchange Map to store arbitrary key/value pairs. The Exchange is available to both input and output messages. In your interceptor, add the object to the Exchange, e.g.

Object value = ...;
message.getExchange().put("key", value);

Within your service, you can use PhaseInterceptorChain.getCurrentMessage() to access the exchange and retrieve the object, e.g.

Object value = PhaseInterceptorChain.getCurrentMessage().getExchange().get("key");

Upvotes: 4

Related Questions