In WSO2 ESB, I have created an rest API. This API needs to connect to two different services, and combine the results.
For this, I use an API, with in de insequence a clone mediator that sends out the appropriate messages. This works fine.
In the outsequence, I use a logger to see the incoming messages. Both are json and come back ok. I then want to use an aggregate mediator to combine the two. With this, I have two issues:
- when using a rootElementProperty to place the two items under one parent, a NPE happens,
- when using enrich mediators or whatever else to make a correct message, and ending with send, the resulting message is never sent back.
What can be the cause of this?
This is the actual API:
<?xml version="1.0" encoding="UTF-8"?>
<api xmlns="http://ws.apache.org/ns/synapse" name="Cale-StreetsAPI" context="/Cale-StreetsAPI">
<resource methods="GET" uri-template="/getStreets?lat={lat}&lon={lon}&radius={radius}">
<inSequence>
<property name="aggRoot" scope="default">
<red:jsonObject xmlns:red="redora"/>
</property>
<log description="">
<property name="lat" expression="get-property('uri.var.lat')"/>
<property name="lon" expression="get-property('uri.var.lon')"/>
<property name="radius" expression="get-property('uri.var.radius')"/>
</log>
<clone continueParent="true" id="deCartaStreets">
<target>
<sequence>
<sequence key="DeCartaDDS"/>
</sequence>
</target>
<target>
<sequence>
<sequence key="DeCartaReverseGeo"/>
</sequence>
</target>
</clone>
</inSequence>
<outSequence>
<property name="messageType" value="application/xml" scope="axis2" type="STRING" description="messageType"/>
<log level="full" description="">
<property name="WSANSWER" value="true"/>
</log>
<aggregate>
<completeCondition>
<messageCount min="2" max="-1"/>
</completeCondition>
<onComplete expression="$body/jsonObject">
<enrich>
<source clone="true" xpath="$body//jsonObject"/>
<target type="property" property="ResultItems"/>
</enrich>
<log level="custom">
<property name="ResultItems" expression="get-property('ResultItems')"/>
</log>
<enrich>
<source type="inline" clone="true">
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<JsonResponse xmlns="dummy"/>
</soapenv:Body>
</soapenv:Envelope>
</source>
<target type="envelope"/>
</enrich>
<enrich>
<source type="property" clone="true" property="ResultItems"/>
<target xmlns:red="dummy" action="child" xpath="//red:JsonResponse"/>
</enrich>
<log level="full" description="">
<property name="AGGREGATE_END" value="true"/>
</log>
<property name="messageType" value="application/json" scope="axis2" type="STRING" description="messageType"/>
<send/>
</onComplete>
</aggregate>
</outSequence>
<faultSequence>
<log level="full" category="WARN"/>
</faultSequence>
</resource>
</api>