【发布时间】:2009-12-02 16:31:24
【问题描述】:
我正在使用 CXF 从 wsdl 生成 Web 服务。 生成的 Web 服务有注解 @WebService 如何从 Web 服务中获取对 Spring Bean 的引用? 我所有的spring bean都用@Service注释,我可以访问它们 在我的网络应用程序中。我如何也从我的 Web 服务访问它们?
我尝试了以下方法:
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";
}
}
但是getWebApplicationContext方法返回null
当我用 getRequiredWebApplicationContext 替换 getWebApplicationContext 我收到一条错误消息:未找到 WebApplicationContext:未注册 ContextLoaderListener?
有人有想法吗?
谢谢 阿隆
【问题讨论】:
标签: java web-services spring cxf