简体   繁体   中英

Apache CXF Fault Interceptor not invoked

I have a Mule Application which is using Apache CXF to consume an external web service.

I am trying to register a Fault Interceptor as follows.

        <cxf:proxy-client  payload="body" doc:name="SOAP">           
            <!-- outgoing interceptor chain for the client and an incoming chain for the cxf server -->
            <cxf:outFaultInterceptors>
                <spring:ref bean="faultOutInterceptor" />
            </cxf:outFaultInterceptors>
        </cxf:proxy-client>
        <spring:bean id="faultOutInterceptor" name="faultOutInterceptor" class="mypackage.soap.FaultOutInterceptor"/>

Where faultOutInterceptor is ...

public class FaultOutInterceptor extends AbstractSoapInterceptor {

    private static final Logger log = LoggerFactory.getLogger(FaultOutInterceptor.class);

    public FaultOutInterceptor() {
        super(Phase.USER_LOGICAL);
    }

    @Override
    public void handleMessage(SoapMessage m) throws Fault {
        log.info("Start in Fault Interceptor");
        log.info("SoapMessage Interceptor" + m);
        Fault fault = (Fault) m.getContent(Exception.class);
        log.info("Received fault response from error: " + fault);
    }
}

When a SOAP fault is thrown this interceptor is not being invoked. There are definitely other interceptors being invoked but unfortunately not mine. See the log below...

DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Chain org.apache.cxf.phase.PhaseInterceptorChain@10b0c88f was modified. Current flow:
      setup [PolicyOutInterceptor, CopyAttachmentOutInterceptor]
      pre-logical [OutputPayloadInterceptor, SoapHeaderOutFilterInterceptor]
      post-logical [SoapPreProtocolOutInterceptor]
      prepare-send [MessageSenderInterceptor]
      pre-stream [AttachmentOutInterceptor, MuleProtocolHeadersOutInterceptor, StaxOutInterceptor, org.mule.module.cxf.transport.MuleUniversalConduit$2]
      pre-protocol [MuleHeadersOutInterceptor]
      write [SoapOutInterceptor]
      marshal [BareOutInterceptor]
      write-ending [SoapOutEndingInterceptor]
      pre-stream-ending [StaxOutEndingInterceptor]
      prepare-send-ending [MessageSenderEndingInterceptor]

DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor org.apache.cxf.interceptor.BareOutInterceptor@3a2f22eb
DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor$SoapOutEndingInterceptor@4a09a8da
DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor org.apache.cxf.interceptor.StaxOutEndingInterceptor@5d175938
DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor@18c65fc3

Can someone help me with that I might be doing wrong?

thanks

I think you need to register an in Intercepter instead of out Intercepter something like below

<cxf:jaxws-client serviceClass="com.mulesoft.example.HelloWorld"
    operation="sayHello" port="HelloWorldPort">
    <cxf:inInterceptors>
        <spring:bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
    </cxf:inInterceptors>
</cxf:jaxws-client>

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