Share this blog!

Exposing data as REST using WSO2 DSS

In a previous post, we discussed how to use a MySQL database in a data service using WSO2. The sample in this post will be updating the same data service, by adding a new query with a parameter and invoking it in REST style.


At a glance, the final output of the sample will be:


Add a new query

Let's add a new query to the last data service we created. In the Services list, when you click on a service, you will be directed to the service dashboard. The edit options are available under Specific Configuration. Let's edit using the wizard.


Click Next until the Queries are reached and add a new query with a parameter as follows. Note the ":fname" parameter in the SQL. After entering the SQL, click on Generate Input Mappings, which will automatically add input mappings.


Let's define an XML output as follows:


Click Save and Next. Let's skip the Operations and instead, add a Resource in the next page. 

Add a resource

This is where you will be mapping the path and parameters to the query we defined. In the Add resource dialog, define the desired path pattern and select the query, and the selection will automatically bind the parameter names.


Click Save and deploy the service. Try out the results using paths such as https://172.17.0.1:9448/services/PersonDataService/person/Sheldon. 




Next PostNewer Post Previous PostOlder Post Home

0 comments:

Post a Comment