Monday, March 5, 2012

REST enabling DB operations via Oracle Service Bus (OSB)

Scenario - I have a DB table - Patient - and I want to provide a REST interface via OSB to CRUD operations.

A very big thanks to Jeff Davies and his post here -
https://blogs.oracle.com/jeffdavies/entry/restful_services_with_oracle_s_1

The table is defined as follows -

CREATE TABLE PATIENT
(
PAT_ID NUMBER NOT NULL
, PAT_NAME VARCHAR2(20) NOT NULL
, PAT_SURNAME VARCHAR2(20) NOT NULL
, PAT_AGE NUMBER(3) NOT NULL
, PAT_SEX VARCHAR2(1) NOT NULL
, PAT_NATIONALITY VARCHAR2(20)
, PAT_COMMENTS VARCHAR2(255)
, CONSTRAINT PATIENT_PK PRIMARY KEY
(
PAT_ID
)
ENABLE
);

Essentially I create 4 services in JDeveloper using the DB adapter to expose SELECT, INSERT, UPDATE and DELETE functionality.



I then import the JCA artifacts into OSB



and generate Business Services from them.

I then create a Proxy that branches on the HTTP Methods - GET (Select), POST(Insert), PUT (Update) and DELETE.



Full lab doc is available
HERE!

No comments: