简体   繁体   中英

Separate cxf interceptor configuration for clients vs. services?

I have some Web Services running using Apache CXF, with a particular custom outbound interceptor registered using cxf:outInterceptors. This interceptor is intended to be executed as the response goes back to the Web Service client.

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

However, if one of my Web Services ends up calling a separate remote Web Service, I don't want that outbound interceptor to be invoked in that case.

Is there a way to specify different interceptor configuration for a jaxws:client (or JaxWsProxyFactoryBean), ie to tell to "not use" the interceptor registered via cxf:bus? Or do I need to remove the interceptor from cxf:bus and register it individually on each jaxws:endpoint?

Add interceptors individually per client / server. For example

<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>

and share some interceptors by declaring them as beans.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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