WebServiceContext is not injected using @Resource

2019-09-13 18:22发布

I know that has been asked before, but none of the solutions worked for me. Probably because they were mostly using EE compliant application servers, which is NOT my case.

I'm running my web service on jetty (through Eclipse) for development only. But even for deployment, I'll use Tomcat 7. So for either development or production, I won't be using a JavaEE compliant server.

  • So is it still possible to inject WebServiceContext into my web services ?

I've tried the following but it didn't work

@WebService
@BindingType(SOAPBinding.SOAP12HTTP_BINDING)
public class IxProIntegration {
    // Tried this, didn't work
    @Resource
    private WebServiceContext wsContext;

    // After commenting the @Resource annotation on the wsContext field
    // And adding the annotation here, this still didn't work.
    @Resource
    @WebMethod(exclude = true)
    public void setContext(WebServiceContext context) {
        this.wsContext = context;
    }
  • When someone kindly gives an answer, I would LOVE to know from where did he get that answer ?

1条回答
劳资没心,怎么记你
2楼-- · 2019-09-13 18:49

I'm using a dependency injection framework called Tapestry. Tapestry is managing the service instantiatiion. But the web service isn't managed by JAX-WS. That's why the context is always null. I asked a new question related to the subject, in case someone needs an answer.

查看更多
登录 后发表回答