WebServiceContext is not injected using @Resource

风格不统一 提交于 2020-01-06 14:12:25

问题


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:


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.



来源:https://stackoverflow.com/questions/18525723/webservicecontext-is-not-injected-using-resource

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