【问题标题】:WebServiceContext: Is it there a way to inject it any where appart from my WebService?WebServiceContext:除了我的 WebService 之外,有没有办法将它注入到任何地方?
【发布时间】:2018-05-27 03:25:57
【问题描述】:

我正在尝试获取 jax-ws javax.xml.ws.WebServiceContext。我可以通过这种方式在我的 Web 服务中做到这一点:

@WebService
public class Service extends BaseService {

    @Resource
    WebServiceContext wsContext;

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

}

我想在我的代码中的任何其他地方获取这个 bean。如果我使用弹簧,它会工作吗?

【问题讨论】:

标签: java spring jakarta-ee jax-ws


【解决方案1】:

经过很长时间尝试不同的方式,我是这样设法做到的:

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

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-13
    • 2014-08-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多