繁体   English   中英

客户端与服务的单独cxf拦截器配置?

[英]Separate cxf interceptor configuration for clients vs. services?

我有一些使用Apache CXF运行的Web服务,并使用cxf:outInterceptors注册了特定的自定义出站拦截器。 该拦截器旨在在响应返回到Web Service客户端时执行。

<cxf:bus>
    <cxf:outInterceptors>
        <ref bean="myCustomInterceptorOutbound" />
    </cxf:outInterceptors>
    <cxf:inInterceptors>
    </cxf:inInterceptors>
    <cxf:features>
        <cxf:logging />
    </cxf:features>
</cxf:bus>

但是,如果我的Web服务之一最终调用了单独的远程Web服务,那么我不希望在这种情况下调用该出站拦截器。

有没有办法为jaxws:client(或JaxWsProxyFactoryBean)指定不同的拦截器配置,即告诉“不使用”通过cxf:bus注册的拦截器? 还是我需要从cxf:bus中删除拦截器并在每个jaxws:endpoint上分别注册?

每个客户端/服务器分别添加拦截器。 例如

<jaxws:client 
    serviceClass="no.bring.booking.Booking" 
    address="${bring.booking.webservice}" id="booking">
    <jaxws:inFaultInterceptors>
         <ref bean="loggingInInterceptor" />
    </jaxws:inFaultInterceptors>
    <jaxws:inInterceptors>
        <bean class="com.greenbird.xmlformatter.cxf.LoggingInInterceptor">
            <property name="prettyLogging" value="true" />
            <property name="prettyPrinter" ref="prettyPrinter" />
        </bean>
    </jaxws:inInterceptors>
    <jaxws:outInterceptors>
        <bean class="com.greenbird.xmlformatter.cxf.LoggingOutInterceptor">
            <property name="prettyLogging" value="true" />
            <property name="prettyPrinter" ref="prettyPrinter" />
        </bean>
    </jaxws:outInterceptors>
    <jaxws:outFaultInterceptors>
        <ref bean="loggingOutInterceptor" />
    </jaxws:outFaultInterceptors>       
</jaxws:client>

并通过将它们声明为bean来共享一些拦截器。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM