synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vanjikumaran Sivajothy (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (SYNAPSE-1041) xml string set in the Script mediator is not honored as OM in Fault mediator
Date Wed, 08 Jun 2016 00:08:20 GMT

     [ https://issues.apache.org/jira/browse/SYNAPSE-1041?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Vanjikumaran Sivajothy updated SYNAPSE-1041:
--------------------------------------------
    Attachment: SYNAPSE-1041_NoMoreText.diff

Based on the recent discussion with [~hiranya] and [~veithen]. I have created a patch that
does not allow text anymore in the SOAP fault detail. If the value of the expression is a
string, it will be parsed it into an OMElement. 

property mediator with OM
{code}
<sequence name="myFaultHandler">
    <property name="foo" scope="default" type="OM">
        <hello xmlns="">World</hello>
    </property>
    <makefault response="true">
        <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
        <reason expression="get-property('ERROR_MESSAGE')"/>
        <detail expression="get-property('foo')"/>
    </makefault>
    <send/>
</sequence>
{code}    

Response
{code}
<soapenv:Fault>
    <faultcode xmlns:tns="http://www.w3.org/2003/05/soap-envelope">tns:Receiver</faultcode>
    <faultstring>Currently , Address endpoint : [ Name : endpoint_87559fe848714da5194ee676669d16c107e8a00eb79a36cb
] [ State : SUSPENDED ]</faultstring>
    <detail>
        <hello>World</hello>
    </detail>
</soapenv:Fault>
{code}  

property with text
{code}
 <property name="foo" value="this is text error"/>
 <makefault response="true">
    <code xmlns:tns="http://www.w3.org/2003/05/soap-envelope" value="tns:Receiver"/>
    <reason expression="get-property('ERROR_MESSAGE')"/>
    <detail expression="get-property('foo')"/>
</makefault>
 {code}

Response
{code}
<soapenv:Body>
        <soapenv:Fault>
            <faultcode xmlns:tns="http://www.w3.org/2003/05/soap-envelope">tns:Receiver</faultcode>
            <faultstring>Error while connecting to the endpoint (Connection Failed)</faultstring>
            <detail/>
        </soapenv:Fault>
</soapenv:Body> 
{code}  
        
        
        

> 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
>         Attachments: SYNAPSE-1041.diff, SYNAPSE-1041_NoMoreText.diff, detailTransform.js,
synapse_sample_2000.xml
>
>
> 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: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


Mime
View raw message