[ 
https://issues.apache.org/jira/browse/SYNAPSE-1041?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15319377#comment-15319377
 ] 

Vanjikumaran Sivajothy commented on SYNAPSE-1041:
-------------------------------------------------

[~veithen]
Correct setting the text is violating the SPEC, However currently it is 
possible use the property mediator or script mediator 
and inject a text into SOAP Fault details. Therefore, I  did not change that 
current functionality.

Example

*Synapse config*
{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>this is text error</detail>
        </soapenv:Fault>
</soapenv:Body> 
{code}

However What i am trying here is creating the xml in script mediator and trying 
to use that in the Fault mediator.
In the fault mediator, the data in the property set in the script mediator is 
string and it encodes the text as setting < character with &lt. 

To avoid, we should do a fix. Isn't this a valid use case?

[~hiranya]

Correct AXIOMUtil.#stringToOM will convert the string and in failure it throw 
exception, However before get into that position, i was checking the basic xml 
validation.
Yes, i can avoid the extra validation. 

> 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, 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: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to