Sharing data between CXF interceptor and webservice

谁都会走 提交于 2020-01-06 02:20:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!