有没有办法从CXF中的JAX-RS REST资源访问CXF消息交换? [英] Is there a way to access the CXF message exchange from a JAX-RS REST Resource within CXF?

查看:67
本文介绍了有没有办法从CXF中的JAX-RS REST资源访问CXF消息交换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我们有一个使用CXF 2.4.2的RESTful API.在我的一种资源方法中,我想处理一些查询参数并将结果存储在CXF消息交换中,以供输出拦截器稍后使用.

Currently we have a 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 the CXF message exchange for an output interceptor to use later on.

我已尝试按此处所述注入WebServiceContext,但似乎没有可以工作,可能是因为它是JAX-WS规范的一部分,并且我们正在使用JAX-RS.

I've tried injecting the WebServiceContext as mentioned here, but it does not seem to work, probably because it is part of the JAX-WS specification, and we are using JAX-RS.

任何帮助将不胜感激!

推荐答案

最简单的方法就是使用CXF:

The easiest, if using CXF, is to just do:

PhaseInterceptorChain.getCurrentMessage()

这将在JAXWS和JAXRS服务中工作.

That will work in JAXWS and JAXRS services.

这篇关于有没有办法从CXF中的JAX-RS REST资源访问CXF消息交换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆