Set up your first Data Services with WSO2 Micro Integrator 4.2.0
In nutshell data services is about exposing database tables as services. In this blog post we will see steps need to be followed in order to expose a data service from WSO2 Micro Inetrator 4.2.0.
From the Integration Studio select New Data Service Configs project.
Let’s put the name “AccountHoldersDataService” and click on finish
Once you have created data service configs project, you have to create a MySQL database with database name: mi_dataservice & table name: account_holder
You can find create script / schema /data from below screens.
Now create a new Data Service as per below screen.
Select “Create a New Data Service”
Put the Data Service Name as AccountHolders and click the finish button.
Once you have created a data service project, the first step is to configure the data source.
Please note you have to copy MySQL JDBC driver to “/Applications/IntegrationStudio.app/Contents/Eclipse/runtime/microesb/lib” before test the connection
Once your connection is healthy, Save your data source. Next step is to create queries.
Configure query as below screen
Generate Input Mapping
Generate output mapping
Click on Save at the end. Next step is to configure the operation.
Click Save at the end. Defining the operation exposes SOAP service from the data source. Additionally you can expose a REST API by defining Resources.
Please select Resource Path, Resource Method and Query ID as per below screen. You will get automatically defined Query Parameters as well.
Once you click on Save, data service configurations should look like this.
Now in order to deploy your data service follow below steps.
Create new Integration Project, DataServiceDeployer
Once you click on finish button, right click on AccountHoldersDataService and select Move to Integration Project
Select DataServiceDeployer as the Integration Project you want to move to.
Finally your Project Explorer will look like below.
Now you can select DataServiceDeployerCompositeExporter and deploy .CAR file.
Make sure you select data service artifacts
Finally click the Finish button to deploy the data service within the Integration Studio itself. End of the deployment you should be able to see server logs, SOAP endpoint and URL to open the dashboard.
For SOAP endpoint wsdl is visible from the browser and you can test SOAP endpoint with tools such as SOAP UI.
Let’s explore the dashboard as well.
You will get both SOAP endpoint as well as REST endpoint. For simplicity I will test the data service with REST endpoint. Make sure you attach Resources to the end of Swagger URL.
EX: http://localhost:8290/services/AccountHolders/account_details?account_id=123
Now you can test the data service from the postman.
https://apim.docs.wso2.com/en/latest/reference/synapse-properties/data-services/