Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:
repository/samples/directory that includes all Data Integration samples is changed to
repository/samples/resources/directory that includes all artifacts related to the Data Integration samples is changed to
Exposing a database as an OData service eliminates the need to define queries, operation etc. to access the information in the database. OData (Open Data Protocol) is an OASIS standard that defines the best practice for building and consuming RESTful APIs. You can easily expose databases as an OData service using WSO2 Enterprise Integrator (WSO2 EI).
About the sample
This OData sample was generated to work with the default h2 database (
DATA_SERV_SAMP.h2.db), which is used for samples in WSO2 EI product. This database is stored in the
<EI_HOME>/samples/data-services/dbs/odata directory. The details of this database are as follows:
Driver class: org.h2.Driver
JDBC URL: jdbc:h2:file:./samples/database/DATA_SERV_SAMP
Tables in the DB:
Views in the DB:
You can find the DDL of these sql tables in
Building the sample
The sample data service named
ODataSampleService should be deployed and the server should be started using the instructions in Samples Setup.
Executing the sample
You can easily invoke the service using HTTP requests. See the following examples.
If you want to invoke the OData services using the HTTPS protocol, use the 8243 port. For an example:
To get the service document:
To get the metadata of the service:
To read customer details:
To read customer details from the 'USACUSTOMERS' view in the database, send the request as shown below. Note that database views can only be used with GET requests.
To add accounts details, send the HTTP request as shown below. In this example, we will be creating an account ID named "1".
To delete account details, send the HTTP request as shown below. In this example, we will be deleting the account ID "1".
To update account details:
To invoke a particular query, send the HTTP request as shown below. In this example, we will receive the city and phone numbers of customers.
To filter information based on a query, send the HTTP request as shown below. In this example, we will receive the employee details connected to the 'Nantes' city.