1

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
    You can check this https://stackoverflow.com/questions/30123148/use-webservicecontext-outside-webservice – ddarellis Dec 15 '17 at 08:21

1 Answers1

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) {

}