exposing custom plsql package as oracle rest …...suryakanth gunti page 1 exposing custom plsql...
TRANSCRIPT
Suryakanth Gunti Page 1
Exposing Custom PLSQL Package as Oracle REST WEB SERVICE
What is Rest Web Service?
The acronym REST stands for Representational State Transfer, this basically means that each unique URL
is a representation of some object. REST describes a set of architectural principles by which data can be
transmitted over a standardized interface (such as HTTP). You can get the contents of that object using
an HTTP GET, to delete it, you then might use a POST, PUT, or DELETE to modify the object (in practice
most of the services use a POST for this).
Now to get started with implementing the Service on your application we first need to perform some
pre-requisites like application of adviced PATCH on the Application.
To get started please connect with the DBA and follow the Metalink Doc Id: 1311068.1
Please find the doc that would be handy for the DBA to perform the setup’s
Once all the setup is done just confirm if the below roles are added else add the roles to the desired user
say sgunti
Login using the details as below: Say as SYSADMIN or ASADMIN User
Navigate User Management Users
Suryakanth Gunti Page 2
Click on UPDATE Pencil
Click on Assign Roles and Responsibility “Integrated SOA Gateway” and “Integration Administrator”
Now login using your desired user say sgunti and then
Navigate to Integrated SOA Gateway Integration Repository
Suryakanth Gunti Page 3
Here above you would see all the list of standard interfaces that can be used to expose the data using
the Rest Service. One can expose any of the standard interface available or once can design once own
Custom Package and use that to expose the data by deploying it.
Now lets design our own Package and expose the data, the idea is when Customer TRX ID is passed as a
Input the data that would be exposed to the calling application is the Customer Name.
Custom Package Specification and Body
Here above the highlighted section is the Annotation part which is an important section as part of Rest
Service deployment.
Categories is where exactly your package would be placed under which module of standard interface
section as in Integration Respository screen as above.
Query to fetch the list of Categories
SELECT * FROM fnd_lookups WHERE lookup_type = 'BUSINESS_ENTITY'
and LOOKUP_CODE like 'AR%'
Suryakanth Gunti Page 4
In our case we used AR_INVOICE
Now here is the Package Body that would except a Customer TRX ID and return the Customer Name.
CREATE OR REPLACE PACKAGE BODY xx_custname_validate_pkg AS
FUNCTION get_validate_cust (p_customer_trx_id IN VARCHAR2)
RETURN VARCHAR2 IS
x_return_status VARCHAR2 (1000); x_error_msg VARCHAR2 (2000);
l_return_msg VARCHAR2 (2000); l_customer_trx_id VARCHAR2 (1000);
BEGIN
l_customer_trx_id := p_customer_trx_id; check_valid_cust (l_customer_trx_id, x_return_status , x_error_msg);
-- l_return_msg := x_return_status;
RETURN l_return_msg; -- EXCEPTION WHEN OTHERS
THEN l_return_msg := SQLCODE || SQLERRM;
RETURN l_return_msg;
-- END get_validate_cust;
-- PROCEDURE check_valid_cust (p_customer_trx_id IN VARCHAR2,
x_return_status OUT VARCHAR2,
x_return_message OUT VARCHAR2) IS
l_customer_name VARCHAR2 (1000); BEGIN
BEGIN
SELECT hp.party_name CUSTOMER_NAME INTO l_customer_name
FROM ra_customer_trx_all rcta, hz_cust_accounts_all hca,
hz_parties hp
Suryakanth Gunti Page 5
WHERE customer_trx_id = p_customer_trx_id AND rcta.bill_to_customer_id = hca.cust_Account_id
AND hp.party_id = hca.party_id; EXCEPTION
WHEN OTHERS THEN
x_return_status := 'Error during fetching the Customer Name';
x_return_message := SQLCODE || SQLERRM; END;
IF l_customer_name IS NOT NULL
THEN
x_return_status := l_customer_name; END IF;
EXCEPTION
WHEN OTHERS THEN
x_return_status := fnd_api.g_ret_sts_error;
x_return_message := SQLCODE || SQLERRM; END check_valid_cust;
-- END xx_custname_validate_pkg;
/
Compile the Package Specification and Package Body using the tools like Toad or SQL Developer.
Now place only the Spec File to /tmp directory to create the .ildt File
Use the below commands to create the .ildt file
Generating the .pls file to .iltd file using the below command
$IAS_ORACLE_HOME/perl/bin/perl $FND_TOP/bin/irep_parser.pl -g -v -username=sysadmin
pa:patch/115/sql:xx_custname_validate_pkg.pls:12.0=/tmp/xx_custname_validate_pkg.pls
Load the ildt to Database
$FND_TOP/bin/FNDLOAD apps/<APPS_PWD> 0 Y UPLOAD $FND_TOP/patch/115/import/wfirep.lct
xx_custname_validate_pkg_pls.ildt
Suryakanth Gunti Page 6
Now navigate to the application using the Navigation Integrated SOA Gateway Integration
Repository
Click on SEARCH button to search for your custom designed Package Specification
Open the Package by clicking the link
Navigate to REST Web Service Tab
Suryakanth Gunti Page 7
Feed a Service Alias Name and Click on DEPLOY this will create WADL file which is a XML File with a
custom link which is used to invoke the service for the response.
WADL File
Now give the GRANT by navigating to GRANTS Tab, Click on Create Grant
Suryakanth Gunti Page 8
Click on Grant to ensure your grant is given to the Package.
Suryakanth Gunti Page 9
Invoking the Rest Service from another application (Calling Application) can be done using a JAVA Code
or Using the Browser or Using Oracle PLSQL(Using utl_http API)
Let us first invoke it using the JAVA Code.
Here is the Java Code that is used to Invoke
Suryakanth Gunti Page 10
Suryakanth Gunti Page 11
Code Pack
Move the above code under $JAVA_TOP
Then execute the below command
javac RestClient_19JUNE.java
This will create a RestClient_19JUNE.class file
Now to invoke the service use the below command
java RestClient_19JUNE
Suryakanth Gunti Page 12
Invoking the Rest Service from Chrome Brouser
Add the below plugin
Add the APP
Open the app ARC
Add the below details
Suryakanth Gunti Page 13
Authorization is the Username and the Password that is used to connect the application
Once the SEND is click here is the response that we get
The above response is based on the Input that we have passed that is the Customer Trx Id and would
return the Customer Name.
The same can be viewed when we query on the DB as below.
Thank You!!!! Please do share your feedbacks for the knowledge on REST Web Service..