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

时间:2015-06-03 11:11:24

标签: wso2 wso2esb

我的目标是在队列中放置返回soap错误的消息,以便稍后重试。

我几乎都在工作,但最重要的部分是:我无法从我的代理的故障序列中访问原始消息:(

我首先创建了一个代理服务,它返回给定值的错误,或者对其他值返回OK:

<?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生成的消息

我尝试使用

将原始邮件保存在属性中(在inSequence中)
<property name="OriginalBody" expression="$body" scope="axis2" type="OM"/>

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

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

结果我得到了null :(

有没有人有想法?

谢谢!

1 个答案:

答案 0 :(得分:2)

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

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