获取Spring MessageContext [英] Get Spring MessageContext

查看:104
本文介绍了获取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屋!

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