简体   繁体   中英

camel cxf client soap fault handling

I'm using camel and cxf component to get some data from web-service. In some case web-service returns standard soap:fault. I have the next steps:

<camel:route id="someId">
    <camel:onException useOriginalMessage="false">
            <camel:exception>java.lang.Exception</camel:exception>
            <camel:handled>
                <camel:constant>false</camel:constant>
            </camel:handled>
            <camel:process ref="defaultNaoIntegrationErrorHandler" />
            <camel:to uri="ref:naointegration.checkAvailability.jms.error.queue" />
    </camel:onException>
    <camel:from uri="direct:naoCheckAvailabilityOut" />
    <camel:marshal ref="soapjaxbSAP" />
    <camel:to id="naoCheckAvailabilityEndpoint" uri="cxf:bean:naoCheckAvailabilityEndpoint" />
    <camel:unmarshal ref="soapjaxbSAP" />
</camel:route>

where naoCheckAvailabilityEndpoint is:

<cxf:cxfEndpoint id="naoCheckAvailabilityEndpoint"
        address="${naointegration.I011.CheckAvailability.soap.address}"
        endpointName="s:checkAvailabilityEndpoint" serviceName="s:SOAPService"
        xmlns:s="http://www.example.com/test">
        <cxf:properties>
            <entry key="dataFormat" value="MESSAGE" />
            <entry key="setDefaultBus" value="true" />
        </cxf:properties>
        <cxf:outInterceptors>
            <ref bean="logOutbound" />
        </cxf:outInterceptors>

        <cxf:inFaultInterceptors>
            <ref bean="logOutbound" />
        </cxf:inFaultInterceptors>
    </cxf:cxfEndpoint>

If I'm getting normal soap message everything is ok. And when I'm getting soap foalt/http 500 I have just string message which contains soap message (xml) with soap fault.

Reading cxf and camel mail lists on like problems I understood cxf endpoint should throw exception if there soap foalt, exception of type org.apache.cxf.binding.soap.SoapFault, but I can not get it. The goal is onException clause do handling of soap fault exception.

Any suggestions?

You are using the MESSAGE data format, which means the camel-cxf endpoint just pass the stream from the transport, it will not read the under layer message, so the camel-cxf endpoint cannot tell which message is normal soap message or soap fault message.

If you want to let the camel route deal with the soap fault, you need to use the PAYLOAD or POJO data format.

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