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