This documentation is for WSO2 Enterprise Integrator version 6.0.0 . View documentation for the latest release in the 6.x.x family and the latest release in the 7.x.x family.

All docs This doc
Skip to end of metadata
Go to start of metadata

In this tutorial, we will run through the process of exposing and RDBMS as an OData service. When OData is enabled for an datasource, you do not need to manually define CRUD operations. These will be automatically created.


Note that the OData feature can only be used for RDBMS and Cassandra datasources.

Setting up an RDBMS

Follow the steps given below to set up a MySQL database for this tutorial.

  1. Install the MySQL server.
  2. Download the JDBC driver for MySQL from here and copy it to your <EI_HOME>/lib directory.
  3. Create a MySQL database with the following table:

    CREATE TABLE ACCOUNT(AccountID int NOT NULL,Branch varchar(255) NOT NULL, AccountNumber varchar(255),AccountType ENUM('CURRENT', 'SAVINGS') NOT NULL,
    Balance FLOAT,ModifiedDate DATE,PRIMARY KEY (AccountID)); 
  4. Enter the following data into the table:

    INSERT INTO ACCOUNT VALUES (1,"AOB","A00012","CURRENT",231221,'2014-12-02');

Expose the RDBMS as an OData service

Follow the steps given below.

  1. When you connect the datasource, select the OData check box as shown below.

Access the data service using CRUD operations

Open a command prompt execute the following CURL commands using CRUD operations:

  • To get the service document:

    curl -X GET -H 'Accept: application/json' https://localhost:8243/odata/{data_service_name}/{data_source_id}
  • To get the metadata of the service:

    curl -X GET -H 'Accept: application/xml' https://localhost:8243/odata/{data_service_name}/{data_source_id}/$metadata
  • To read details from the ACCOUNT table:

    curl -X GET -H 'Accept: application/xml' https://localhost:8243/odata/{data_service_name}/{data_source_id}/ACCOUNT
  • No labels