How to get Spring MessageContext
from Java class?
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
.
What is approach?
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();
...
}
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.