Wednesday, August 14, 2019

Oracle REST Data Services (ORDS)


Oracle REST Data Services (ORDS)


What is ORDS?


In this blog I will be introducing you to Oracle REST Data Services, a technology by oracle commonly referred to as ORDS. In most simple words, ORDS can be defined as ‘a java application which enables us to expose oracle database as a RESTful web service’. As its name implies, it uses REST architecture. Now the question is why specifically REST when we have many more web based protocols like SOAP? The answer is - REST is easy.


  • It comes with small and uniform set of operations : GET, PUT, POST, DELETE
  • Small and uniform set of status codes : 200(Success), 401(Unauthorized), 500(Server error) etc. There are few more, but I can only think of these at the time.
  • It exposes a resource rather than behaviour/action. For example, let say if I have two numbers a and b. What SOAP offers is – addition web service, web service for subtraction, division, multiplication and so on. But what REST will say is – hey, I have a calculator to offer with set of operation including add, subtract, divide, multiply. Tell me what operation you want to perform on these two numbers.
  • REST has become a de-facto standard on which most of the web/internet is built on. (There is no written rule, but it is commonly accepted architecture for building web applications.)

ORDS Architecture
As I said above, ORDS comes as a java application which is installed on top of oracle database. ORDS always runs within an application server which traverses requests/response to and from database. We can use ORDS either in standalone mode or with an application server like Apache tomcat, WebLogic or Glassfish server. When ran in standalone mode, it runs within its own embedded application server called Jetty.

NOTE : Standalone mode is recommended to be used only on Non-Prod/Dev/Test environments.

ORDS comes with .war configuration file and not as an executable (.exe). We need to place it somewhere on application server and install using command line interface. Alternately, we can also install ORDS through SQL Developer. Recent versions of SQL Developer like 4.1 and onwards, give us flexibility to install and use ORDS through wizards or in other words it provides us GUI so that we can enable our database objects as RESTFul web service with minimal or almost zero coding.





More on ORDS architecture –

Below picture depicts how ORDS works. Here client can be any application having some means to call HTTP protocol or it can be simply an end user accessing ORDS web service through a web browser.



Client requests an access to particular resource using URI i.e Universal Resource Identifier assigned to each REST enabled object in database by ORDS. URI is made up of –

  • HTTP : It tells ORDS that it has to use http protocol to transfer information over the network.
  • Hostname + Port : Hostname identifies a particular database server and a port at which it is listening for incoming requests/connections.
  • Basepath : HTTP://hostname:9090/ords/ this becomes our base path to which ORDS decrypts as – use http messaging protocol and connect to the database server identified by ‘hostname’ and the DB is running at port 9090.


Since ORDS is a java-based application, it uses JDBC connection pool to connect to a particular database. When a request comes to ORDS, it decomposes the URI as explained above to identify a database it is supposed to connect to. It then borrows one connection from its internal JDBC connection pool and connects to the database.

It then does mapping and binding of URI to database object and transforms the request into sql/plsql query. Database runs the query and sends result back to ORDS.

ORDS again transforms the result into JSON format before sending it to the client. 



Uses

a. Exposing data restfully
The primary use case is to expose existing data as REST services. One area where I have seen this used extensively is exposing Oracle e-Business suite data as REST services. For ex. we can make our customer/master items data easily available for other applications like SFDC.

 b. Data capture
ORDS is a fast and light weight method of allowing you to capture data. Think IOT (Internet of Things). There is a vast amount of data coming at us and we need a way to easily capture it and store it using fast industry standard protocols.

 c. Integration middleware
Having provided the ability to capture and expose data, oracle database along with ORDS can function as low-cost integration middleware. (Purpose of integration middleware is to send the data back and forth between applications - exactly what ORDS enabled us to do with oracle DB)

That was all the theory about ORDS. We will see ORDS implementation with some practical examples in next blog à Link is here.



1 comment:

  1. I feel SQL and other parts of REST API are actually very necessary which needs to be explored more to solve complex IT problems.

    SQL Server Load Soap API

    ReplyDelete