不使用@Resource注入WebServiceContext

时间:2013-08-30 05:39:27

标签: java java-ee tomcat jetty jax-ws

我知道以前曾经问过,但没有一个解决方案适合我。可能是因为他们大多使用符合EE标准的应用服务器,我的情况

我正在使用jetty(通过Eclipse)运行我的Web服务以进行开发。但即使是部署,我也会使用Tomcat 7.因此无论是开发还是生产,我都不会使用符合JavaEE标准的服务器。

  • 所以仍然可以将WebServiceContext注入我的网站 服务?

我尝试了以下但是没有用

@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;
    }
  • 当有人给出答案时,我很乐意知道从哪里来 他得到了那个答案吗?

1 个答案:

答案 0 :(得分:0)

我正在使用名为Tapestry的依赖注入框架。 Tapestry正在管理服务实例化。但是Web服务不是由JAX-WS管理的。这就是上下文总是null的原因。我asked a new question related to the subject,万一有人需要回答。