2017-05-24 118 views
0

我有一個使用Apache CXF來使用外部Web服務的Mule應用程序。未啓用Apache CXF故障攔截器

我想按如下方式註冊故障攔截器。

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

哪裏faultOutInterceptor是...

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); 
    } 
} 

當一個SOAP故障被拋出此攔截器不被調用。當然還有其他的攔截器被調用,但不幸的是不是我的。看到下面的日誌...

DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Chain [email protected] 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 [email protected] 
DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor org.apache.cxf.bindi[email protected]4a09a8da 
DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor [email protected] 
DEBUG org.apache.cxf.phase.PhaseInterceptorChain - Invoking handleMessage on interceptor org.apache.cxf.inte[email protected]18c65fc3 

有人可以幫助我,我可能會做錯嗎?

感謝

回答

0

我認爲你需要在截擊,而不是出來截擊像註冊一個低於

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