как отправить письмо без ошибки 200 WSO2 повторять вызов - PullRequest
0 голосов
/ 09 октября 2018

Я работаю с wso2 ESB 6.3.0. Моя полная функциональность такова: сделать вызов API службы оставшихся, если получен какой-либо ответ на отправку почтового сообщения, но требование не содержит 200 кодов состояния, оставшихся без каких-либо кодов отправки.почта (например: я получаю код ошибки или код успеха для отправки, отправьте письмо с кодом ошибки 200, если есть код ошибки для отправки почты. Если какой-либо из них предложите мне.

<?xml version="1.0" encoding="UTF-8"?>
<api context="/first" name="firston" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET">
        <inSequence>
            <property description="http" name="HTTP_SC" scope="axis2" type="STRING" value="404"/>
            <log level="full"/>
            <send>
                <endpoint key="firstapi"/>
            </send>
        </inSequence>
        <outSequence>
            <switch source="get-property('axis2','HTTP_SC')">
                <case regex="200">
                    <log description="200log" level="custom">
                        <property expression="$ctx:ERROR_CODE" name="200reserrorcode"/>
                        <property expression="$ctx:ERROR_MESSAGE" name="200reserrormessage"/>
                        <property expression="get-property('axis2','HTTP_SC')" name="200reshttpsc"/>
                    </log>
                </case>
                <case regex="400">
                    <log description="400log" level="custom">
                        <property expression="$ctx:ERROR_CODE" name="400reserrorcode"/>
                        <property expression="$ctx:ERROR_MESSAGE" name="400reserrormessage"/>
                        <property expression="get-property('axis2','HTTP_SC')" name="400reshttpsc"/>
                    </log>
                </case>
                <case regex="404">
                    <log description="404log" level="custom">
                        <property expression="$ctx:ERROR_CODE" name="404reserrorcode"/>
                        <property expression="$ctx:ERROR_MESSAGE" name="404reserrormessage"/>
                        <property expression="get-property('axis2','HTTP_SC')" name="404reshttpsc"/>
                    </log>
                </case>
                <case regex="500">
                    <log description="500log" level="custom">
                        <property expression="$ctx:ERROR_CODE" name="500reserrorcode"/>
                        <property expression="$ctx:ERROR_MESSAGE" name="500reserrormessage"/>
                        <property expression="get-property('axis2','HTTP_SC')" name="500reshttpsc"/>
                    </log>
                </case>
                <default>
                    <log description="reslog" level="custom">
                        <property expression="$ctx:ERROR_CODE" name="reserrorcode"/>
                        <property expression="$ctx:ERROR_MESSAGE" name="reserrormessage"/>
                        <property expression="get-property('axis2','HTTP_SC')" name="reshttpsc"/>
                    </log>
                </default>
            </switch>
            <clone continueParent="true">
                <target>
                    <sequence>
                        <sequence key="sendthemail"/>
                    </sequence>
                </target>
            </clone>
            <send/>
        </outSequence>
        <faultSequence>
            <switch source="get-property('axis2','HTTP_SC')">
                <case regex="200">
                    <log description="200log" level="custom">
                        <property expression="$ctx:ERROR_CODE" name="200errorcode"/>
                        <property expression="$ctx:ERROR_MESSAGE" name="200errormessage"/>
                        <property expression="get-property('axis2','HTTP_SC')" name="200httpsc"/>
                    </log>
                </case>
                <case regex="400">
                    <log description="400log" level="custom">
                        <property expression="$ctx:ERROR_CODE" name="400errorcode"/>
                        <property expression="$ctx:ERROR_MESSAGE" name="400errormessage"/>
                        <property expression="get-property('axis2','HTTP_SC')" name="400httpsc"/>
                    </log>
                </case>
                <case regex="404">
                    <log description="404log" level="custom">
                        <property expression="$ctx:ERROR_CODE" name="404errorcode"/>
                        <property expression="$ctx:ERROR_MESSAGE" name="404errormessage"/>
                        <property expression="get-property('axis2','HTTP_SC')" name="404httpsc"/>
                    </log>
                </case>
                <case regex="500">
                    <log description="500log" level="custom">
                        <property expression="$ctx:ERROR_CODE" name="500reserrorcode"/>
                        <property expression="$ctx:ERROR_MESSAGE" name="500reserrormessage"/>
                        <property expression="get-property('axis2','HTTP_SC')" name="500reshttpsc"/>
                    </log>
                </case>
                <default>
                    <log description="faultlog" level="custom">
                        <property expression="$ctx:ERROR_CODE" name="faulterrorcode"/>
                        <property expression="$ctx:ERROR_MESSAGE" name="faulterrormessage"/>
                        <property expression="get-property('axis2','HTTP_SC')" name="faulthttpsc"/>
                    </log>
                </default>
            </switch>
            <clone continueParent="true">
                <target>
                    <sequence>
                        <sequence key="sendthemail"/>
                    </sequence>
                </target>
            </clone>
            <send/>
        </faultSequence>
    </resource>
</api>

ВСЕ КОД РАБОТАЕТЛЮБОЙ КОД СТАТУСА 200 ИЛИ 404 ИЛИ 500 и т. Д. ЛЮБОЙ КОД СТАТУСА ОТПРАВИТЬ ПОЧТУ МОЕ ТРЕБОВАНИЕ - КОД СТАТУСА! = 200 ОСТАЛОСЬ ЛЮБОЙ КОД СТАТУСА ОТПРАВИТЬ ПОЧТУ ПОЖАЛУЙСТА, ЛЮБОЙ ПРЕДЛОЖИТЕЛЬНЫЙ МЕНЯ

1 Ответ

0 голосов
/ 10 октября 2018

Это довольно просто, ниже приведен код.

 <switch source="get-property('axis2','HTTP_SC')">
                    <case regex="200"><!-- Do not do anything here as it's success -->
                        <log description="200log" level="custom">
                            <property expression="$ctx:ERROR_CODE" name="200reserrorcode"/>

                        </log>
                    </case>

                    <default><!-- Put your logic here to send mail -->
                        <log description="reslog" level="custom">
                            <property expression="$ctx:ERROR_CODE" name="reserrorcode"/>
                            <property expression="$ctx:ERROR_MESSAGE" name="reserrormessage"/>
                            <property expression="get-property('axis2','HTTP_SC')" name="reshttpsc"/>
                        </log>
                    </default>
                </switch>
...