Performing Multiple Operations in a DataService Using Request Box in WSO2

Performing Multiple Operations in a DataService Using Request Box in WSO2

Performing multiple operations in a DataService using the Request Box feature in WSO2 streamlines data processing and enhances efficiency. By leveraging this functionality, users can easily execute various operations within a single request, eliminating the need for multiple interactions and reducing response times. This not only saves valuable time but also optimizes resource utilization, making data service management more seamless and effective.

Performing multiple operations using Boxcarring with the assistance of Integration Studio to integrate with an MS SQL database.

Walkthrough

Install the MYSQL Workbench

Create a Database:

  • Right-click on the “Databases” in the Object Explorer on the left side.
  • Choose “New Database.”
  • Enter a name for your database in the “Database name” field.
  • Click “OK” to create the database.

Create a Table:

  • Expand the newly created database in Object Explorer.
  • Right-click on the “Tables”.
  • Choose “New -> Table.”
  • Define the columns of your table, specifying the data type, length, and any constraints.
  • Save the table by clicking “Save” or using Ctrl + S.

Create project in Integration studio File >>New >>Integration project and give the Project name and finish.

After creating a project, Click on Project:  >> Project >>New >>Data Services Configs and give the data services name.

Later It will create Data Service Config with data services folder. Right-click on data services folder >>data services >>New >>Data Service >>Create Data Services and give the Data services name Click on finish.

Complete the data services configuration like give database credentials & configure operation, query & in advanced enable Boxcarring.

Configure data source and give your database details.

Configure queries here:

Add Operation Here:

In advanced setting mark on Boxcarring option to enable Boxcarring.

The usage of a request box to execute multiple operations consecutively in a WSO2 Data Service. The request box allows individual operations within a single request.

Source Code:

<data disableLegacyBoxcarringMode=“true” enableBoxcarring=“true” name=“request_box_example” transports=“http https local”>

   <config enableOData=“false” id=“Datasource”>

      <property name=“driverClassName”>com.mysql.jdbc.Driver</property>

      <property name=“url”>jdbc:mysql://localhost:3306/Company</property>

      <property name=“username”>root</property>

      <property name=“password”>password</property>

   </config>

   <query id=“addEmployeeQuery” useConfig=“Datasource”>

      <sql>insert into Employees (EmployeeNumber, FirstName, LastName, Email,OfficeCode) values(:EmployeeNumber,:FirstName,:LastName,:Email,:OfficeCode)</sql>

      <param name=“EmployeeNumber” sqlType=“STRING”/>

      <param name=“FirstName” sqlType=“STRING”/>

      <param name=“LastName” sqlType=“STRING”/>

      <param name=“Email” sqlType=“STRING”/>

      <param name=“OfficeCode” sqlType=“STRING”/>

   </query>

   <query id=“selectEmployeebyIDQuery” useConfig=“Datasource”>

      <sql>select EmployeeNumber, FirstName, LastName, Email, OfficeCode from Employees</sql>

      <result element=“Entries” rowName=“Entry”>

         <element column=“EmployeeNumber” name=“EmployeeNumber” xsdType=“string”/>

         <element column=“FirstName” name=“FirstName” xsdType=“string”/>

         <element column=“LastName” name=“LastName” xsdType=“string”/>

         <element column=“Email” name=“Email” xsdType=“string”/>

         <element column=“OfficeCode” name=“OfficeCode” xsdType=“string”/>

      </result>

   </query>

   <operation name=“addEmployeeOp”>

      <call-query href=“addEmployeeQuery”>

         <with-param name=“EmployeeNumber” query-param=“EmployeeNumber”/>

         <with-param name=“FirstName” query-param=“FirstName”/>

         <with-param name=“LastName” query-param=“LastName”/>

         <with-param name=“Email” query-param=“Email”/>

         <with-param name=“OfficeCode” query-param=“OfficeCode”/>

      </call-query>

   </operation>

   <operation name=“selectEmployeeOp”>

      <call-query href=“selectEmployeebyIDQuery”>

      </call-query>

   </operation> </data>

Build and run the artifacts.

  • Right-click multiple-operations-resquest-boxCompositeExporter and click Export Project Artifacts and Run

You will see the following dialog box. Select the multiple-operations-resquest-boxCompositeExporter folder in the artifact list and click Finish.

In the console will get the project deploy successfully logs. In right side runtime services, it will give WSDL URL as below.

Open SoapUI click on SOAP option there give the WSDL URL, what we copied from runtime services in integration studio as below and click ok.

Based on URL it will generate the data service.

Navigate Green button to send a request, after data inserted and also will get 200 status.

To execute Multipleoperations within a single request.

Successfully inserted data.

Open SQL Workbench and execute a SELECT query to verify if the data has been inserted into the database.

select * from Employees;

The article has discussed with screenshots on how to perform Multiple Operations in a DataService Using Request Box in WSO2. For more information or queries in WSO2, please email to[email protected].