user1135720
user1135720

Reputation: 96

Mule JDBC Rest servce

I have requirement for to fetch data from Database and expose the content as Restful service, I am unable to find any useful documents.

Can any one please share the documents or links.

Upvotes: 0

Views: 223

Answers (2)

Anirban Sen Chowdhary
Anirban Sen Chowdhary

Reputation: 8311

A simple example will be :-

<flow name="testFlow">
        <http:listener config-ref="HTTP_InboundRequest"  path="/test" doc:name="HTTP"/>
        <set-variable doc:name="Variable" value="23" variableName="eventId"/>
        <db:select config-ref="Oracle_Configuration" doc:name="Database">
            <db:parameterized-query><![CDATA[select ID, NAME where EVENT_ID=#[flowVars['eventId']]]]></db:parameterized-query>
        </db:select>
        <set-payload value="{&quot;status&quot;:&quot;Success&quot;}" doc:name="Set Payload"/>
    </flow>

Where you can modify the code as per your requirement and display the Database values as JSON response. So, if you deploy a service similar to this , it will be exposed as a Rest api

Upvotes: 0

Seba
Seba

Reputation: 2319

Take a look at http://www.mulesoft.org/extensions/rest-module

You can combine it with JDBC endpoints to fetch data from the DB.

Upvotes: 2

Related Questions