Spring整合CXF之添加拦截器

来源:互联网 发布:软件体系结构模型 编辑:程序博客网 时间:2024/05/02 02:11

这里我们给下官方的参考文档:http://cxf.apache.org/docs/jax-ws-configuration.html


结合官方文档,我们在前面的实例基础上,加代码:


bbb.jpg


首先我们把前面的自定义拦截器 MyInterceptor 贴进来。


然后我们打开spring配置文件,applicationContext.xml


根据官方文档:我们通过jaxws:inInterceptors jaxws:outInterceptors 这两个标签来添加in拦截器和out拦截器


我们修改下jaxws:endpoint 节点:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<!-- 定义服务提供者  -->
<jaxws:endpoint
    implementor="#helloWorld"
    address="/HelloWorld">
    <!-- 添加in拦截器 -->
    <jaxws:inInterceptors>
         <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
         <bean class="com.java1234.interceptor.MyInterceptor"/>
    </jaxws:inInterceptors>
    <!-- 添加out拦截器 -->
    <jaxws:outInterceptors>
         <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
    </jaxws:outInterceptors>
</jaxws:endpoint>


这里 我们添加了两个in拦截器,一个是cxf自带的LogginInInterceptor拦截器,还有一个是我们自己定义的MyInterceptor拦截器,

主要用作权限判断;


out拦截器,我们还是用了一个cxf自带的LogginInInterceptor拦截器;


这样我们就完事了;我们可以看到。用spring我们可以很轻松的完整拦截器的配置;

0 0
原创粉丝点击