Create a Data Service¶ Create the data service artifact¶ Follow the instructions given below to create a new data service artifact in the WSO2 Integrator: MI for Visual Studio Code extension (MI for VS Code). Launch Visual Studio Code with the WSO2 Integrator: MI for VS Code extension (MI for VS Code) installed. Info Follow the Install WSO2 Integrator: MI for VS Code documentation for a complete installation guide. Create an integration project. To add a new data service artifact, navigate to WSO2 Integrator: MI Project Explorer. Click on the + icon to open the Add Artifact pane. Click + View More under Create an Integration. Click Data Service under Other Artifacts to open the Data Service Form where you can configure the data service. Enter a name for the data service. Specify other required properties. Add a data source¶ You can configure the data source connection details in this step. Go to the Service Designer of the created data service and click on Edit to reopen the Data Service Form. Click on the + Add Datasource to open the Create Datasource form. Enter the data source connection details. Click Add to save the data source configurations to the data service. Click Advanced Configurations to expand the section and add the required configurations. The data service should now have the query element added. Add a resource¶ In this step, you can configure a REST resource to invoke the data service. Select REST and click on + Resource to add a REST resource. Give the following details to create the REST resource. Parameter Description Resource Path Give the HTTP REST resource path you need to expose. Resource Method Select the REST API method from the drop-down list. Click Add to add the resource to the data service. Go to the Service Designer view and click on the added resource to open the graphical view. The graphical view will appear as shown below. You can use it to configure the main query details. Add a SOAP operation¶ In this step you can configure a SOAP operation for invoking the data service. Select SOAP and click on + Operation to add a SOAP operation. Give a name to the SOAP Operation, then click on Add. Click on the added operation to open the graphical view. The graphical view will appear as shown below. You can use it to configure the main query details. Create queries for REST resources and SOAP operations¶ You can configure the main query details for both SOAP operations and REST resources using their respective graphical views. Click on Query to edit the query configuration. Enter the following query details. Parameter Description Query ID Provide a unique name to Identify the Query. Datasource All the data sources created for this data service are listed. Select the required data source from the list. Query / Expression You can enter the SQL query in this text box. Provide the required parameter values in the Advanced Properties section. Input mapping¶ You can configure input parameters for the query using this section. Click on the Input Mapping from the graphical view to edit the section. There are two ways to create the mapping: You can use the default configurations to automatically generate the input mappings from the SQL query. If you want to add a new input mapping: Click + Add Parameter. Enter the following input mapping details: Parameter Description Mapping Name Enter a name for the mapping. Query Parameter Enter the query parameter. Parameter Type The parameter type SQL Type The SQL type Save the input mapping. You can add multiple input mappings as required. Shown below is an example query with input mapping: Result (output mappings)¶ You can configure output result parameters for the query using this section. Click Output Mapping from the graphical view to edit the output mapping configurations. There are two ways to create the output mapping: You can use the default configurations to automatically generate the output mappings from the SQL query. Alternatively, you can manually add the mappings: Click + Add Parameter. Enter the following output element details. Property Value Datasource Type column Output Field Name EmployeeNumber Datasource Column Name EmployeeNumber Schema Type String Follow the same steps to create the remaining output elements. Shown below is an example query with output mappings: Tutorials¶ Follow our tutorial on data services: How to Expose a Datasource as a Service Examples¶ Follow our examples on data services: Exposing an RDBMS Datasource Exposing Data in JSON Format Using an OData Service Using Nested Data Queries Batch Requesting Invoking Multiple Operations via Request Box Using Distributed Transactions in Data Services Validating Data Input Samples¶ You can use a sample template to create your data service. Go to Explore Samples in MI for VS Code. In the Samples tab, go to the REST Data Service and click on Download. This will download the project to your chosen directory and open it in a new VS Code window. For more information