CBrunain
CBrunain

Reputation: 377

WSO2 ESB - Access original message from fault

My goal is to put messages that return a soap error on a queue, in order to retry them later.

I have nearly all working, but the most important part : I can't access the original message from the fault sequence of my proxy :(

I first made a proxy service that returns an error for a given value, or OK for the other values :

<?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>

And it works fine

I then made another proxy, that uses the first one as an endpoint to test the queuing on error :

<?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>

The message that is stored is the one made by the makefault in the TestProxy

I tried to save the original message in a property (in the inSequence) with

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

but in the faultSequence, when i do this :

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

I got null as a result :(

Does anyone have an idea ?

Thanks !

Upvotes: 0

Views: 486

Answers (1)

Jean-Michel
Jean-Michel

Reputation: 5946

remove scope "axis2" when defining property "OriginalBody" or explicitely specify scope="default" :

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

Upvotes: 2

Related Questions