I want to send a query to the database and return the result to the client using WSO2 rest api. Here is the synapse config:
<api xmlns="http://ws.apache.org/ns/synapse" name="RestDBLookup" context="/dblookup">
<resource methods="POST GET" uri-template="/channel/{name}" protocol="http">
<inSequence>
<dblookup>
<connection>
<pool>
<password>pass</password>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>jdbc:oracle:thin:@localhost:1521:ORCL</url>
<user>user</user>
</pool>
</connection>
<statement>
<sql>SELECT ID, CHANNEL_NAME FROM CHANNEL where CHANNEL_NAME = ?</sql>
<parameter expression="get-property('uri.var.name')" type="VARCHAR"/>
<result name="channel_id" column="ID"/>
</statement>
</dblookup>
<log level="custom">
<property name="ID" expression="get-property('channel_id')"/>
<property name="State" value="after db"/>
</log>
</inSequence>
<outSequence>
<property name="messageType" value="application/json" scope="axis2" type="STRING"/>
<log level="full"/>
<send/>
</outSequence>
<faultSequence/>
</resource>
</api>
When I call the url http://localhost:8280/dblookup/channel/someChannel
with rest client I get the log after the dblookup
LogMediator ID = 40810162, State = after db
but the outSequence
is not executed and I only get Status 202 Accepted on the rest client with no body.
So the question is how can I construct some response (in JSON format for example) and send it to the client?