仅限客户端使用配置的CXF拦截器

时间:2016-06-11 09:32:16

标签: web-services cxf cxf-client java-ws

我只在cxf_client.xml中添加了拦截器,但同样的拦截器也在调用传入的apis(即cxf_server)。以下是我的更改。 有人可以告诉我为什么这个拦截器正在调用传入的API? 是因为服务器和客户端使用相同的总线吗?

cxf_client.xml

  <bean id="XCustomInterceptor" class="com.test.XCustomInterceptor"/>
<cxf:bus>
        <cxf:inInterceptors>
            <ref bean="XCustomInterceptor"/>
        </cxf:inInterceptors>
        <cxf:outInterceptors>
            <ref bean="XCustomInterceptor"/>
       </cxf:outInterceptors>
    </cxf:bus>*

1 个答案:

答案 0 :(得分:1)

因为您正在使用

<cxf:inInterceptors>
     <ref bean="XCustomInterceptor"/>
</cxf:inInterceptors>

检查文档http://cxf.apache.org/docs/bus-configuration.html

  

inInterceptors   拦截器有助于入站消息拦截器链。 s或s的列表

您可以在服务器和客户端使用特定拦截器进行入站连接和出站连接

例如,这里是jax-ws端点和带有in和out拦截器的客户端的配置

<!-- The SOAP endpoint --> 
<jaxws:endpoint
   id="helloWorld"
   implementor="demo.spring.HelloWorldImpl"
   address="http://localhost/HelloWorld">
   <jaxws:inInterceptors>
      <ref bean="customInInterceptor"/>
    </jaxws:inInterceptors>
   <jaxws:outInterceptors>
      <ref bean="customOutInterceptor"/>
   </jaxws:outInterceptors>

</jaxws:endpoint>

<!-- The SOAP client bean -->
<jaxws:client id="helloClient"
            serviceClass="demo.spring.HelloWorld"
            address="http://localhost/HelloWorld">
    <jaxws:inInterceptors>
        <ref bean="customClientInInterceptor"/>
    </jaxws:inInterceptors>
    <jaxws:outInterceptors>
        <ref bean="customClientOutInterceptor"/>
    </jaxws:outInterceptors>
 </jaxws:client>
相关问题