wso2 / product-ei

An open source, a high-performance hybrid integration platform that allows developers quick integration with any application, data, or system.
https://wso2.com/integration/
Apache License 2.0
367 stars 276 forks source link

Illegal character issue evaluating a JSON expression #5519

Open madushadhanushka opened 2 years ago

madushadhanushka commented 2 years ago

Description: The EI throw the following error log on the console

[2021-11-23 15:50:13,813] ERROR {org.apache.synapse.commons.json.JsonUtil} - #toXml. Could not convert JSON Stream to XML. Cannot handle JSON input. Error>>> java.io.IOException: Illegal character: <&>
[2021-11-23 15:50:13,816] ERROR {org.apache.synapse.mediators.transform.PayloadFactoryMediator} - Error converting JSON to XML, please check your JSON Path expressions return valid JSON: 

Steps to reproduce: Add the following proxy service

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="test"
       transports="http https"
       startOnLoad="true">
   <description/>
   <target>
      <inSequence>
         <property name="callerRef" expression="json-eval($.request.callerRef)" type="STRING" scope="default" />
         <property name="personalNumbers"
                   expression="json-eval($.request.personalNumbers)" type="STRING" scope="default" />
         <property name="notifyServices"
                   expression="json-eval($.request.notifyServices)" type="STRING" scope="default" />
         <payloadFactory media-type="xml">
            <format>
               <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
                  <soapenv:Body>
                     <soapenv:Envelope>
                        <soapenv:Body>
                           <hcmDataRequest xmlns="http://www.w3.org/2005/Atom">
                              <event>$1</event>
                              <personNumber>$2</personNumber>
                              <notifyServices>$3</notifyServices>
                           </hcmDataRequest>
                        </soapenv:Body>
                     </soapenv:Envelope>
                  </soapenv:Body>
               </soapenv:Envelope>
            </format>
            <args>
               <arg evaluator="xml" expression="$ctx:callerRef"/>
               <arg evaluator="xml" expression="$ctx:personalNumbers"/>
               <arg evaluator="xml" expression="$ctx:notifyServices"/>
            </args>
         </payloadFactory>
         <respond/>
      </inSequence>
   </target>
</proxy>

Invoke the service with the following JSON payload:

{
    "request": {
        "caller": "Venkata",
        "callerRef": "Test",
        "personNumbers": [
            "860"
        ],
        "notifyServices":["Worktribe"],
        "uuns": []

    }
}
yasirjanjua commented 1 month ago

@madushadhanushka do we have a fix for it? or any workaround

saiflayouni commented 1 month ago

Have you managed to resolve this error?