Skip to content

Create a Data Service

Follow the instructions given below to create a new data service artifact.

Tip

You can also use a sample template to create your data service.

  1. Open the Explore Samples view of WSO2 Micro Integrator VS Code extension.
  2. 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.

Instructions

Create the data service artifact

Follow the steps given below to create the data service file:

  1. Create a new integration project or select an existing one.

  2. In the Micro Integrator: Project Explorer sidebar, hover over Data Services and click the + icon that appears to create a new data service.

    This will open a form where you can configure the data service.

  3. Enter a name for the data service and click Create.

    A data service file (DBS file) will now be created in your data service project as shown below.

Add a datasource

You can configure the datasource connection details using this section.

  1. Open the Service Designer page of the created data service and click on Edit to reopen the Data Service Form.

  2. Click on the + Add Datasource to open the Create Datasource form.

  3. Enter the datasource connection details.

  4. Click Add to save the datasource configurations to the data service.

Advanced properties

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

Use this section to configure an REST resource to invoke the data service.

  1. Select REST and click on + Resource to add a REST resource.

  2. 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.

  3. 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

Use this section to configure a SOAP operation for invoking the data service.

  1. Select SOAP and click on + Operation to add a SOAP operation.

  2. Give a name to the SOAP Operation, then click on Add.

  3. 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.

  1. Click on Query to edit the query configuration.

  2. Enter the following query details.

    Parameter Description
    Query ID Provide a unique name to Identify the Query.
    Datasource All the datasources created for this data service are listed. Select the required datasource 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.

  1. Click on the Input Mapping from the graphical view to edit the section.

  2. 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:

      1. Click + Add Parameter.

      2. 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

      3. 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.

  1. Click Output Mapping from the graphical view to edit the output mapping configurations.

  2. 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:

      1. Click + Add Parameter.

      2. 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:

Examples

Tutorials

  • data integration