Vanjikumaran Sivajothy created SYNAPSE-1041:
-----------------------------------------------

             Summary: xml string set in the Script mediator is not honored as 
OM in Fault mediator 
                 Key: SYNAPSE-1041
                 URL: https://issues.apache.org/jira/browse/SYNAPSE-1041
             Project: Synapse
          Issue Type: Bug
            Reporter: Vanjikumaran Sivajothy
            Assignee: Hiranya Jayathilaka


Sample 5 with with custom error message generated via Script mediator does not 
produce the proper xml as the fault response in fault mediator.


*Synapse Configuration*
{code}
<definitions xmlns="http://ws.apache.org/ns/synapse";>

<localEntry key="FaultMessageScript"
                
src="file:repository/conf/sample/resources/script/CustomErrorMessageScript.js"/>
    <sequence name="myFaultHandler">
        <property name="customErrorCode" value="2016" scope="default" 
type="STRING"/>
        <property name="customErrorText" value="This is Bug" scope="default" 
type="STRING"/>
        <property name="customTime" expression="get-property('SYSTEM_DATE')" 
scope="default" type="STRING"/>   
       <script language="js" key="FaultMessageScript" 
function="transformFault"/>
       <log level="custom">
            <property name="**************Custom Detail*****************" 
expression="get-property('customErrorDetail')" />
       </log>
       <makefault version="soap11">
            <code xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/"; 
value="tns:Receiver" />
            <reason expression="get-property('ERROR_MESSAGE')"/>
            <detail expression="get-property('customErrorDetail')" type="OM"/>
        </makefault>
        <send/>
    </sequence>
    <sequence name="fault">
        <log level="full">
            <property name="MESSAGE" value="Executing default fault sequence"/>
            <property name="ERROR_CODE" 
expression="get-property('ERROR_CODE')"/>
            <property name="ERROR_MESSAGE" 
expression="get-property('ERROR_MESSAGE')"/>
        </log>
        <drop/>
    </sequence>
    <sequence name="main" onError="myFaultHandler">
        <in>
            <log level="full"/>
            <switch xmlns:m0="http://services.samples"; 
source="//m0:getQuote/m0:request/m0:symbol">
                <case regex="MSFT">
                    <send>
                        <endpoint name="testEndpoint1">
                            <address 
uri="http://bogus:9000/services/NonExistentStockQuoteService"/>
                        </endpoint>
                    </send>
                </case>
                <case regex="SUN">
                    <send>
                        <endpoint name="testEndpoint2">
                            <address 
uri="http://localhost:9009/services/NonExistentStockQuoteService"/>
                        </endpoint>
                    </send>
                </case>
            </switch>
            <drop/>
        </in>
        <out>
            <send/>
        </out>
    </sequence>
</definitions>
{code}

*Script*
{code}
function transformFault(mc) {
     var symbol = mc.getPayloadXML()..*::Code.toString();
     var errorCode = mc.getProperty("customErrorCode");
     var errorText = mc.getProperty("customErrorText");
     var time = mc.getProperty('customTime');
     mc.setProperty("customErrorDetail", 
"<CustomErrorDetails><TimeStamp>"+time+"</TimeStamp><ErrorCode>"+errorCode+"</ErrorCode><ErrorText>"+errorText+"</ErrorText></CustomErrorDetails>");
  }
{code}


*Client Request* 
Same request as in sample 5
{{ant stockquote 
-Daddurl=http://localhost:9000/services/SimpleStockQuoteService 
-Dtrpurl=http://localhost:8281/ -Dsymbol=SUN}}


*Response resiveed and monitored via tcpmon*

{code}
 <soapenv:Fault>
            <faultcode 
xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/";>tns:Receiver</faultcode>
            <faultstring>Error while connecting to the endpoint (Connection 
Failed)</faultstring>
            <detail>&lt;CustomErrorDetails&gt;&lt;TimeStamp&gt;6/7/16 12:36 
AM&lt;/TimeStamp&gt;&lt;ErrorCode&gt;2016&lt;/ErrorCode&gt;&lt;ErrorText&gt;This
 is Bug &lt;/ErrorText&gt;&lt;/CustomErrorDetails&gt;</detail>
 </soapenv:Fault>
{code}


However,expected results is 

{code}
  <soapenv:Fault>
            <faultcode 
xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/";>tns:Receiver</faultcode>
            <faultstring>Error while connecting to the endpoint (Connection 
Failed)</faultstring>
            <detail>
                <CustomErrorDetails>
                    <TimeStamp>6/7/16 12:09 AM</TimeStamp>
                    <ErrorCode>2016</ErrorCode>
                    <ErrorText>This is Bug</ErrorText>
                </CustomErrorDetails>
            </detail>
        </soapenv:Fault>
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to