如何拦截WSO2 ESB中的500内部服务器错误

时间:2014-11-06 14:26:31

标签: wso2 wso2esb

我有一个端点,其错误响应必须被拦截,记录或转换。我包含了一个故障序列,并且我记录了所有可能的错误。但是我无法拦截500内部服务器错误。有人可以帮帮我吗?

请参阅下文。

<endpoint xmlns="http://ws.apache.org/ns/synapse">
 <address uri="https://<Hostname/WebServiceName>" format="soap11">
  <suspendOnFailure>
     <progressionFactor>1.0</progressionFactor>
  </suspendOnFailure>
  <markForSuspension>
     <errorCodes>500</errorCodes>
     <retriesBeforeSuspension>0</retriesBeforeSuspension>
     <retryDelay>0</retryDelay>
  </markForSuspension>
  <timeout>
     <duration>100</duration>
     <responseAction>fault</responseAction>
  </timeout>
  <enableSec policy="conf:/repository/esb/policies/Sign-UT-Policy.xml"/>
</address>
</endpoint>

错误日志      TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "HTTP/1.1 500 Internal Server Error[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "Set-Cookie: CSQA9IBCOOKIE=R2172309488; path=/[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "Content-Type: application/json[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "X-Powered-By: Servlet/2.5 JSP/2.1[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "Date: Thu, 06 Nov 2014 14:21:08 GMT[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "Server: WSO2-PassThrough-HTTP[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "Transfer-Encoding: chunked[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "Connection: Keep-Alive[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "1f[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "{"getMyClsScheduleResponse":""}[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "0[\r][\n]" {org.apache.synapse.transport.http.wire} TID: [0] [ESB] [2014-11-06 09:21:08,790] DEBUG {org.apache.synapse.transport.http.wire} - << "[\r][\n]" {org.apache.synapse.transport.http.wire}

如上所示,我在日志中看到500 Internal Server错误,但未将其发送到故障序列。

任何想法都会有所帮助......

由于 Kranthi

2 个答案:

答案 0 :(得分:1)

在过去的几个月里,我了解到我们需要在API /代理中使用以下参数将http错误代码发送回故障序列。

<inSequence>
        <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/>
</inSequence>

端点超时设置中的参数<responseAction>不是您的故障序列的名称,它只是提到控件是应该发送到故障序列还是被丢弃。

<timeout>
<duration>100</duration>
<responseAction>fault</responseAction>

代理

中提到了必须路由的故障序列的名称
  <proxy xmlns="http://ws.apache.org/ns/synapse" name="StudentDashboardAcademics" transports="https http" startOnLoad="true" trace="disable">
        <target faultSequence="StudashFault">
<endpoint key="conf:/repository/esb/endpoints/CSIB_Dynamic.xml"/>
        <inSequence>
            <property name="Accept" expression="$trp:Accept" scope="default" type="STRING"/>
            <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/>
        </inSequence>

祝大家编码好运......

祝福 Kranthi

答案 1 :(得分:0)

将您的故障序列添加到代理,看看是否可以捕获错误