获取Spring MessageContext [英] Get Spring MessageContext
问题描述
如何从Java类获得Spring MessageContext
?
How to get Spring MessageContext
from Java class?
我应该使用一些 @Resource
或 @Autowire
注入上下文
var到类或者例如使用SpringContext或其他一些全局上下文来获得 MessageContext
。
Should I use some @Resource
or @Autowire
to inject context
var to class or, for instance, to use some global context SpringContext or some other in order to get MessageContext
.
什么是方法?
推荐答案
我会先阅读并尝试:
I'd start by reading what the standard method of doing this is and try that:
@Resource WebServiceContext wsContext;
@WebMethod public String echoHello(String msg) {
MessageContext context = wsContext.getMessageContext();
...
}
这就是怎么做在服务器端。在客户端,请求和响应上下文只是从服务存根中检索的简单映射(它将实现 BindingProvider
,即使您没有明确要求它)。他们不需要范围管理 MessageContext
增加。
That's how to do it on the server side. On the client side, the request and response contexts are just simple maps that you retrieve from the service stub (which will implement BindingProvider
even if you don't explicitly ask for it); they don't need the scope management that MessageContext
adds.
这篇关于获取Spring MessageContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!