WSO2 ESB - 从故障中访问原始消息

WSO2 ESB - Access original message from fault

我的目标是将 return soap 错误的消息放入队列中,以便稍后重试。

我几乎完成了所有工作,但最重要的部分:我无法从代理的故障序列中访问原始消息:(

我首先制作了一个代理服务,return对于给定值是错误的,或者对于其他值是正常的:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="TestProxyService" transports="http https" startOnLoad="true" trace="disable">
    <target>
        <inSequence>
            <log level="custom">
                <property name="TestProxyService" value="InSequence"/>
            </log>
            <switch xmlns:bnc="http://bnc.org/" source="//bnc:id">
                <case regex="1">
                    <log level="custom">
                        <property name="TestProxyService" value="Send Error !"/>
                    </log>
                    <makefault version="soap11">
                        <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch"/>
                        <reason value="ERROR ERROR ERROR"/>
                        <detail>ERROR</detail>
                    </makefault>
                    <respond/>
                </case>
                <default>
                    <log level="custom">
                        <property name="TestProxyService" value="No Error"/>
                    </log>
                    <log level="custom">
                        <property name="id" expression="//bnc:id"/>
                    </log>
                    <payloadFactory media-type="xml">
                        <format>
                            <bnc:response>OK</bnc:response>
                        </format>
                        <args/>
                    </payloadFactory>
                    <respond/>
                </default>
            </switch>
        </inSequence>
        <outSequence/>
        <faultSequence/>
    </target>
</proxy>

而且效果很好

然后我制作了另一个代理,它使用第一个代理作为端点来测试错误排队:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse" name="QueuingProxyService" transports="https http" startOnLoad="true" trace="disable">
    <target>
        <inSequence>
            <property name="FORCE_ERROR_ON_SOAP_FAULT" value="true" scope="default" type="STRING"/>
            <send>
                <endpoint key="TestProxyServiceEndpoint"/>
            </send>
        </inSequence>
        <outSequence>
            <send/>
        </outSequence>
        <faultSequence>
            <store messageStore="No1MessageStore"/>
            <makefault version="soap11">
                <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:VersionMismatch"/>
                <reason value="There has been an error"/>
                <detail>We will retry later</detail>
            </makefault>
            <send/>
        </faultSequence>
    </target>
</proxy>

存储的消息是 TestProxy 中的 makefault 生成的消息

我试图用

将原始消息保存在 属性 中(在顺序中)
<property name="OriginalBody" expression="$body" scope="axis2" type="OM"/>

但是在 faultSequence 中,当我这样做时:

<log level="custom">
    <property name="OriginalBody" expression="get-property('OriginalBody')"/>
</log>

结果我得到了 null :(

有人知道吗?

谢谢!

在定义 属性 "OriginalBody" 时删除范围 "axis2" 或明确指定范围="default" :

<property name="OriginalBody" expression="$body" type="OM"/>