WebServiceContext: Is it there a way to inject it any where appart from my WebService?

别来无恙 提交于 2019-12-24 09:58:23

问题


I'm trying get the jax-ws javax.xml.ws.WebServiceContext. I'm able to do it in my Web service this way:

@WebService
public class Service extends BaseService {

    @Resource
    WebServiceContext wsContext;

    @WebMethod
    public responseExample example(....) {...}

}

I want to get this bean any where else in my code. Would it work if I use spring?


回答1:


After a long time trying different ways, this is how I managed to do it like this:

WebServiceContext wscontext = null;
try {
    Context ctx = new InitialContext();
    wscontext = (WebServiceContext) ctx.lookup("java:comp/WebServiceContext");
} catch (NamingException e) {

}


来源:https://stackoverflow.com/questions/47789637/webservicecontext-is-it-there-a-way-to-inject-it-any-where-appart-from-my-webse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!