首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >从bean服务访问spring bean?

从bean服务访问spring bean?
EN

Stack Overflow用户
提问于 2009-12-01 23:49:08
回答 1查看 1.2K关注 0票数 1

我已经在我的cxf.xml文件中创建了一个cxf tag服务,我有以下标记。class="com.company.auth.dataobjects.VideoStatsTable“id="videoStatsTable”bean

据我所知,Spring应该为我创建这个对象。问题是我不确定如何访问它。看起来我好像需要servletContext,但是我不在servlet中,我在WS中,我不知道该怎么做?

W

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-12-02 04:47:56

Spring有一种声明web服务的简化方式(使用cxf)。

applicationContext.xml中,将xmlns:jaxws="http://cxf.apache.org/jaxws"添加到根标记(<beans>)中,然后

代码语言:javascript
运行
复制
http://cxf.apache.org/core
        http://cxf.apache.org/schemas/core.xsd
        http://cxf.apache.org/jaxws
        http://cxf.apache.org/schemas/jaxws.xsd

发送到您的schemaLocation

然后添加:

代码语言:javascript
运行
复制
<!-- Loading CXF modules -->
<import resource="classpath:META-INF/cxf/cxf.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

最后声明你的WebService实现:

代码语言:javascript
运行
复制
<jaxws:endpoint id="MyWebService" implementor="#MyWebServiceImpl"
    address="/myWebServiceAddress" />

其中#MyWebServiceImpl是bean的ID。您可以自由地将任何其他spring依赖项注入到该bean中。

然后就可以通过http://yourhost/cxfuri/myWebServiceAddress访问web服务(其中cxfuri是您的CXF Servlet的映射)

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1827051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档