Spring 3 整合Apache CXF WebService
来源:互联网 发布:河北省药品中标数据 编辑:程序博客网 时间:2024/05/10 02:00
在CXF2版本中,整合Spring3发布CXF WebService就更加简单了。因为Spring 3提供了annotation注解,而CXF2发布WebService已经不像之前版本的配置那样(参考老版本发布WebService系列文章:http://www.cnblogs.com/hoojo/archive/2011/03/30/1999563.html),现在发布一个WebService可以直接从Spring的IoC容器中拿到一个对象,发布成WebService服务。当然发布WebService的配置有了些小小的变动,具体请往下看。
在老版本中发布一个WebService,配置applicationContext-server.xml文件中添加如下配置如下:
jaxws:server的发布方式
<bean id="userServiceBean" class="com.hoo.service.ComplexUserService"/>
<bean id="inMessageInterceptor" class="com.hoo.interceptor.MessageInterceptor">
<constructor-arg value="receive"/>
</bean>
<bean id="outLoggingInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
<!-- 注意下面的address,这里的address的名称就是访问的WebService的name -->
<jaxws:server id="userService" serviceClass="com.hoo.service.IComplexUserService" address="/Users">
<jaxws:serviceBean>
<!-- 要暴露的 bean 的引用 -->
<ref bean="userServiceBean"/>
</jaxws:serviceBean>
<jaxws:inInterceptors>
<ref bean="inMessageInterceptor"/>
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<ref bean="outLoggingInterceptor"/>
</jaxws:outInterceptors>
</jaxws:server>
jaxws:endpoint的发布方式
<!-- com.hoo.service.ComplexUserService是com.hoo.service.IComplexUserService接口的实现, 这种方法应该不能从Ioc中引用对象 -->
<jaxws:endpoint id="userService2" implementor="com.hoo.service.ComplexUserService" address="/Users">
<jaxws:inInterceptors>
<ref bean="inMessageInterceptor"/>
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<ref bean="outLoggingInterceptor"/>
</jaxws:outInterceptors>
</jaxws:endpoint>
而在2.x新版本中,发布Ioc容器中的对象为一个WebService的方法
<bean id="userServiceBean" class="com.hoo.service.ComplexUserService"/>
<bean id="inMessageInterceptor" class="com.hoo.interceptor.MessageInterceptor">
<constructor-arg value="receive"/>
</bean>
<bean id="outLoggingInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
<!-- 注意下面的address,这里的address的名称就是访问的WebService的name;#userServiceBean是直接引用Ioc容器中的Bean对象 -->
<jaxws:server id="userService" serviceBean="#userServiceBean" address="/Users">
<jaxws:inInterceptors>
<ref bean="inMessageInterceptor"/>
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<ref bean="outLoggingInterceptor"/>
</jaxws:outInterceptors>
</jaxws:server>
<!-- 或者这种方式,在老版本中这个是不能引用Ioc容器中的对象,但在2.x中可以直接用#id或#name的方式发布服务 -->
<jaxws:endpoint id="userService2" implementor="#userServiceBean" address="/Users">
<jaxws:inInterceptors>
<ref bean="inMessageInterceptor"/>
</jaxws:inInterceptors>
<jaxws:outInterceptors>
<ref bean="outLoggingInterceptor"/>
</jaxws:outInterceptors>
</jaxws:endpoint>
CXF发布WebService官方参考:http://cxf.apache.org/docs/writing-a-service-with-spring.html
<script type="text/javascript"><!--google_ad_client = "ca-pub-1944176156128447";/* cnblogs 首页横幅 */google_ad_slot = "5419468456";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- CXF Webservice 6 - Spring 3 整合Apache CXF WebService
- Spring 3 整合Apache CXF WebService
- Spring 3 整合Apache CXF WebService
- Spring 3 整合Apache CXF WebService
- Spring 3 整合Apache CXF WebService
- Spring 3 整合Apache CXF WebService
- Spring 整合 Apache CXF发布webService
- Apache Cxf WebService整合Spring(1)
- Apache Cxf WebService整合Spring(2)
- Apache Cxf WebService整合Spring(1)
- Apache Cxf WebService整合Spring(2)
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- CXF WebService整合Spring
- 电机扭矩计算公式T=9550*P/n
- Structs+Spring+Hibernate快速入门
- PreviewXXX event and XXX event
- WebKit内核源码分析(一)---dlmu2001
- java基础:集合connection
- Spring 3 整合Apache CXF WebService
- sqlserver 查看进程及杀锁
- spring整合dwr 3.0 聊天功能
- spring如何使用多个xml配置文件
- 实现英文单词按字典序排列的基数排序算法
- spring开发_spring环境搭建
- Spring Batch系列总括
- 何时开始使用IDE工具
- 程序员学习能力提升三要素