在CXF拦截器和Web服务之间共享数据 [英] Sharing data between CXF interceptor and webservice
本文介绍了在CXF拦截器和Web服务之间共享数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用带有Apache CXF WSS4JInInterceptor
的安全拦截器.
I'm using security interceptors with Apache CXF WSS4JInInterceptor
.
有什么方法可以将数据从拦截器传递到Web服务吗?
Is there any way to pass data from interceptor to webservice?
我一直在WebServiceContext
中搜索它,但找不到.
I've been searching for that in WebServiceContext
but I can't find it.
推荐答案
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");
这篇关于在CXF拦截器和Web服务之间共享数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文