从 web 服务访问 spring bean?
我在我的 cxf.xml 文件中创建了一个 cxf web 服务,我有以下标签。 bean id="videoStatsTable" class="com.company.auth.dataobjects.VideoStatsTable"
根据我的理解,Spring 应该为我创建这个对象。问题是我不知道如何访问它。似乎我需要 servletContext,但由于我不在 servlet 中,我在 WS 中,所以不知道该怎么做?
瓦
I have created a cxf webservice within my cxf.xml file I have the following tag.
bean id="videoStatsTable" class="com.company.auth.dataobjects.VideoStatsTable"
From what I understand Spring should create this object for me. The problem is I'm not sure how to get access to it. It seems as if I need the servletContext but as I'm in not in a servlet im in a WS im not sure how to do this?
W
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Spring 有一种声明 Web 服务的简化方法(使用 cxf)。
在您的< /code>) 并
applicationContext.xml
中添加xmlns:jaxws="http://cxf.apache.org/jaxws"
到您的根标记 (添加到您的
schemaLocation
然后添加:
最后声明您的 WebService 实现:
其中
#MyWebServiceImpl
是您的 bean 的 ID。您可以自由地将任何其他 spring 依赖项注入到该 bean 中。然后可以通过 http://yourhost/cxfuri/myWebServiceAddress 访问 Web 服务(其中 cxfuri 是 CXF Servlet 的映射)
Spring has a simplifed way of declaring web services (wiht cxf).
in your
applicationContext.xml
addxmlns:jaxws="http://cxf.apache.org/jaxws"
to your root tag (<beans>
) andto your
schemaLocation
Then add:
And finally declare your WebService implementation:
where
#MyWebServiceImpl
is the ID of your bean. You can freely inject any other spring dependencies into that bean.Then the web service will be accessible through
http://yourhost/cxfuri/myWebServiceAddress
(where cxfuri is the mapping of your CXF Servlet)