Cxf SOAP日志记录。不同文件中的不同服务

时间:2012-09-06 16:14:01

标签: logging soap cxf

我的问题是我必须使用不同的服务并且: 1.在我的beans.xml中有这个

<cxf:bus >
        <cxf:features>
            <cxf:logging/>
        </cxf:features>

    </cxf:bus>

,这在log4.xml中:

 <logger name="org.apache.cxf" additivity="false">
    <level value="info" />
    <appender-ref ref="sessionSoapFile" />
    <appender-ref ref="console" />
</logger>

我可以从我所有的服务客户端看到我的控制台中只有肥皂。我不明白为什么。可以添加正确编写日志的服务,如下所示:

<jaxws:client id="sessionService" address="${session-storage.url}/services/SessionService?wsdl" serviceClass="ru.vtsft.exchange.session.service.SessionService">
    <jaxws:dataBinding>
        <bean class="org.apache.cxf.aegis.databinding.AegisDatabinding" />
    </jaxws:dataBinding>
</jaxws:client>

不喜欢这样的服务:

<bean id="agencyClient" class="comtech.swc.service.AgencyService"
        factory-bean="agencyFactory" factory-method="create" />

    <bean id="agencyFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
        <property name="serviceClass" value="comtech.swc.service.AgencyService" />
        <property name="address" value="${swc.url}/agency" />
        <property name="outInterceptors">
            <list>
                <bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor" />
                <ref bean="authorizationOutInterceptor" />
                <bean class="ru.vtsft.exchange.cxfinterceptors.DynamicIdOutInterceptor" />
            </list>
        </property>
    </bean>

结果我想在不同文件中编写来自不同服务的soap日志。 感谢您的建议,对不起我的英语=)

1 个答案:

答案 0 :(得分:1)

Oookay,昨晚我明白了! 由于我覆盖了自己的拦截器,cxf不会为第二类客户端写日志。解决方案是:

<bean id="exchangeFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
        <property name="serviceClass" value="comtech.swc.service.ExchangeService" />
        <property name="address" value="${swc.url}/exchange" />
        <property name="inInterceptors">
            <list>
                <ref bean="loggingInInterceptor" /> <!---- Here -->
            </list>
        </property>
        <property name="outInterceptors">
            <list>
                <ref bean="loggingOutInterceptor" /> <!---- And here -->
                <bean class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor" />
                <ref bean="authorizationOutInterceptor" />
                <bean class="ru.vtsft.exchange.cxfinterceptors.DynamicIdOutInterceptor" />
            </list>
        </property>
    </bean>

 <!-- Logging interceptors -->
 <bean id="loggingInInterceptor" class="org.apache.cxf.interceptor.LoggingInInterceptor" />
 <bean id="loggingOutInterceptor" class="org.apache.cxf.interceptor.LoggingOutInterceptor" />

感谢您的关注=)