title: Get reference to spring bean from @WebService
body: <p>I'm using CXF to generate a web service from wsdl.
  The generated web service has the annotation @WebService
  How do i get a reference to spring bean from the web service?
  All my spring beans are annotated with @Service, and I can access them
  in my web application. How do I access them also from my web service? </p>
  
  <p>I've tried the following:</p>
  
  <pre><code>public class TestWSImpl implements TestWSSoap{
  
      @Resource
      public WebServiceContext wsContext;
  
      @Override
      public String getTest() {
  
          ServletContext servletContext= (ServletContext) wsContext.getMessageContext().get(MessageContext.SERVLET_CONTEXT);
  
          ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(servletContext);
  
          return "Test";
      }
  }
  </code></pre>
  
  <p>But the getWebApplicationContext method returns null</p>
  
  <p>When I replace getWebApplicationContext with getRequiredWebApplicationContext
  I get an error message: No WebApplicationContext found: no ContextLoaderListener registered?</p>
  
  <p>Anyone has an idea?</p>
  
  <p>Thanks
  Alon</p>