问题
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.
回答1:
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");
来源:https://stackoverflow.com/questions/26184781/sharing-data-between-cxf-interceptor-and-webservice