简体   繁体   中英

using enriching response payload from call mediator

I am calling a micro-service through my WSO2 ESB Config Language Call Mediator, I then pass the request to an enrich mediator to and then I log and use a respond mediator.

The issue I have is that the I can not even see the payload returned by the micro-service though my micro-service indicates that it was called and returned a response payload without any errors. Secondly my sequence throws an error when I run it. My error is below.

JsonUtil #writeAsJson. Payload could not be written as JSON. MessageID: urn:uuid:fe8d8ec5-473e-43c0-bc98-22a7211e2d86 [2018-06-08 12:30:26,209] [] ERROR - JsonStreamFormatter Error occurred while writing to application/json java.lang.reflect.InvocationTargetException

Below is my sequence.

<?xml version="1.0" encoding="UTF-8"?>
<sequence name="balanceEnquirySeq" trace="disable"
 xmlns="http://ws.apache.org/ns/synapse">
 <property expression="json-eval($.)" name="data_request"
  scope="default" type="STRING" />
 <log level="custom">
  <property expression="json-eval($.)" name="in_request" />
 </log>
 <switch source="json-eval($.agentInstitutionCode)">
  <case regex="001">
   <payloadFactory media-type="json">
     <format>{


 "channel": "",
 "type": "",
 "customerId": $1,
 "customerIdType": "",
 "submissionTime": "",
 "reqTranId": $2,
 "passcode": ""

 }
</format>
<args>
 <arg evaluator="json" expression="$.agentAccountNumber" />
 <arg evaluator="json" expression="$.requestID" />
</args>
   </payloadFactory>
   <log level="custom">
    <property expression="json-eval($.)" name="CHANGED_REQUEST" />
   </log>
   <property name="messageType" scope="default" type="STRING"
    value="application/json" />
     <call >
     <endpoint>
       <http method="post" uri-template="http://127.0.0.1:8080/stanbic/dobalenquiry" />
    </endpoint>
   </call>
  <enrich>
  <source type="body" clone="true" />
  <target type="property" action="child" property="org_type" />

   </enrich>
   <log level="full"/>
   <respond />
 </case>
</switch>
</sequence>

如果我将有效负载放入JSON验证程序中,则会出现错误

If I use a json validator and just put the content of your payloadFactory there then I get an error on line 3 and 7 if the property is empty. Try:

 "channel": "",
 "type": "",
 "customerId": "$1",
 "customerIdType": "",
 "submissionTime": "",
 "reqTranId": "$2",
 "passcode": ""

To see if that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM