WSO2代理:捕获运行时抛出的异常?

时间:2015-12-22 03:34:10

标签: proxy wso2 wso2esb

是否有可能捕获WSO2代理期间在运行时抛出的异常?我的代理服务会抛出大量异常(在每次迭代中),并且它们往往会为内存不足的ESB带来很多开销。我想捕获/禁止这些异常,并在为每个异常显示单个错误消息后让代理运行到最后。

1 个答案:

答案 0 :(得分:0)

您可以按照here

的说明尝试使用makefault

在目标下的代理中,您可以将faultsequence设置为指向单独定义的序列

现在,nameoffaultseq将拥有这样的代码,这应该可以捕获运行时异常并为我做。

<makefault xmlns="http://ws.apache.org/ns/synapse" version="soap11"> <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch" /> <reason value="test message " /> <role></role> </makefault>

这是针对soap11的回复

对于非肥皂般的休息,你可以使用像

这样的东西
<makefault version="pox">
    <reason expression="get-property('ERROR_MESSAGE')"/>

</makefault>
<payloadFactory media-type="xml">
    <format>
       <Error>
          <ErrorCode>$1</ErrorCode>
                                <ErrorDesc>$2</ErrorDesc>
                                <ErrorSource>$3</ErrorSource>
                                <ErrorType>SE</ErrorType>
      </Error>
    </format>
    <args>
        <arg evaluator="xml" expression="get-property('ERROR_CODE')"/>
        <arg evaluator="xml" expression="get-property('ERROR_MESSAGE')"/>
        <arg evaluator="xml" expression="get-property('ERROR_EXCEPTION')"/>
    </args>
</payloadFactory>
<property name="HTTP_SC" value="500" scope="axis2" type="STRING"/>
<property name="messageType" expression="get-property('AcceptFromConsumer')" scope="axis2" type="STRING"/>`

如果参数是wso2esb提供的标准错误属性,那么通常对于运行时异常,这应该足够了。有关错误处理的更多详细信息为here