2012-04-17 112 views
2

我最近從騾2.2.1切換到騾子3.X騾子3 web服務不會返回堆棧跟蹤

這樣做的主旨是騾子3不返回堆棧跟蹤,但騾子2呢,我怎麼複製騾2的行爲?

更多細節:

一些Web服務被包裹在一個try-catch,我們拋出ServiceException

@WebFault(name = "ServiceException") 
    public class ServiceException extends Exception { 
    private static final long serialVersionUID = 1L; 
    private Integer errorNumber; 

public ServiceException(Exception e, User user) { 
    super(makeMessage(e)); 
    LoggingDao.logException(this.getMessage(), e.toString()); 
    this.setStackTrace(e.getStackTrace()); 
    this.errorNumber = LoggingDao.getLogId(); 
} ... etc 

當我們捕捉到了異常與堆棧跟蹤返回給Web的目標服務調用者,通過LoggingDao記錄堆棧跟蹤的方式,但Web服務不會返回它。

沿拋出一個MuleException將覆蓋堆棧跟蹤並返回

<soap:Fault> 
    <faultcode>soap:Server</faultcode> 
    <faultstring>Component that caused exception is: org.mule.component.DefaultJavaComponent component for: SedaService{...}. Message payload is of type: Object[]</faultstring> 
    </soap:Fault> 

我將如何去在騾子3.X

附註:返回堆棧跟蹤我們跳進DefaultComponentLifecycleAdapter.java路上某處 我使用的是Mule 3.0.1,它似乎與我上面提供的鏈接不兼容。

也從:http://www.mulesoft.org/documentation/display/MULE3USER/Error+Handling

如果流動交換模式是請求 - 響應,不同的消息被返回到已經被執行之後調用者。該消息具有org.mule.transport.NullPayload作爲其有效內容,並且exceptionPayload屬性設置爲以下內容:org.mule.api.ExceptionPayload。 < 前面提到的是什麼給我帶來麻煩?

從騾子2騾子-config.xml文件是在問候的交換模式不是「請求 - 響應」

回答

2

有人告訴我,這是騾子3一個已知的問題不同。 X < 3.2 的解決方案是通過
托馬斯布洛赫姆

public class CustomSoapFaultOutInterceptor extends AbstractSoapInterceptor { 
    private static final Log logger = LogFactory.getLog(CustomSoapFaultOutInterceptor.class); 

public CustomSoapFaultOutInterceptor() { 
     super(Phase.MARSHAL); 
     getAfter().add(Soap11FaultOutInterceptor.class.getName()); 
    } 
    @Override 
    public void handleMessage(SoapMessage message) throws Fault { 
     Fault fault = (Fault) message.getContent(Exception.class); 
     logger.error(fault.getMessage(), fault); 
    //delete the Mule Exception to have the one throw by the component in the SoapMessage 
     Throwable t = getOriginalCause(fault.getCause()); 
     fault.setMessage(t.getMessage()); 
    } 
    private Throwable getOriginalCause(Throwable t) { 
     if (t.getCause() == null || t.getCause().equals(t)) 
      return t; 
     else 
      return getOriginalCause(t.getCause()); 
    } 
} 

//And then this into mule-config. 
<cxf:jaxws-service> 
    <cxf:outFaultInterceptors> 
     <spring:bean class="is.tr.mule.interceptor.CustomSoapFaultOutInterceptor"/> 
    </cxf:outFaultInterceptors> 
</cxf:jaxws-service> 
寫一個OutFault攔截 代碼