Before You Begin
This 40-minute tutorial provides information about the RESTful service support available in Oracle Data Integrator (ODI) 12.2.1.2.6.
Background
ODI 12.2.1.2.6 supports RESTful services invocation for reading or writing data. The RESTful endpoints can be configured like any other data server in topology and can be easily invoked through an ODI tool in the integration flow.
In this example, you will query Google's financial services website from ODI to return the stock prices of various companies to json files.
What Do You Need?
- Completion of Oracle Data Integrator 12c: Integration and Administration training or equivalent experience
- Oracle Data Integrator Getting Started Virtual Machine (contains all preinstalled software and artifacts)
- A minimum of 6 GB RAM
Starting ODI 12.2.1
-
On your desktop, double-click ODI 12c Beta.
Description of this image -
In ODI, click Connect to Repository.
Description of this image -
In the Oracle Data Integrator Login dialog box, enter the following values and then click OK..
- Login Name: Cubes Dimensions Lab
- User:
SUPERVISOR - Password:
welcome1
Description of this image The user and password is prepopulated from the wallet. If you're asked for the wallet password, enter
welcome1.
Creating Topology Configurations
Defining the RESTful Service
-
In the Topology tab, expand Physical Architecture and Technologies, then right-click Restful Services and select New Data Server.
Description of this image -
In the New Object form, complete the following fields:
- Name:
GoogleFinanceRestService - REST Service Endpoint URL:
http://finance.google.com
Description of this image - Name:
-
In the ODI toolbar, click Save, then click OK in the Information dialog. Click Test Connection, then OK in the Information dialog.
Description of this image If the test is successful, you can close the GoogleFinanceRestService tab. If it was unsuccessful, you need to modify ODI's connection to the Internet. Click Tools/Preferences menu item, then in the Preference dialog box, click Web Browser and Proxy, select Proxy Settings tab and alter your settings.
-
In the Topology tab, under Physical Architecture and Technologies, expand RESTful Service, right-click GoogleFinanceRestService and select New Physical Schema from the menu.
Description of this image -
In the GoogleFinanceRest Service Resource URI form, enter
/financein the Resource URI field. Note that the URI gets appended to the Name.
Description of this image -
Switch to the Operations tab. Click Add Operation and set the following parameter values:
- Name:
getQuote - Method: GET
- Operation URI:
info - Query Parameter: Click ..., then click Add Parameter in the Edit Query Parameters dialog window, and add the following parameters:
Name Value clientqqNASDAQ:ORCL
Description of this image Click OK to dismiss the Edit Query Parameters dialog box.
- Name:
-
In the ODI toolbar, click Save. Click OK to dismiss the Information dialog box.
-
Switch to the Context tab. Click Add to add a Context. Enter the following:
- Context: Global
- Logical Schema:
google-finance-get-quote
Description of this image -
In the ODI toolbar, click Save, then close GoogleFinanceRest Service Resource URI.
Using the REST Tool Invocation to get json response
-
In the Designer tab, expand Projects, right-click Beta and select New Folder.
Description of this image -
In the New Object form, enter
Rest Tool Invocationin the Name field, then click Save in the ODI toolbar. Close the Rest Tool Invocation tab.
Description of this image -
In the Designer tab, under Projects, expand Beta and Rest Tool Invocation, then right-click Packages and select New Package.
Description of this image -
In the New dialog box, enter
PkgGetQuotein the Name field, a suitable description in the Description field, then click OK.
Description of this image -
From Toolbox pane, select OdiInvokeRESTfulService, then click a space in the Package map area to add it as a step to the package. Make sure it is defined as the first step in the package. Right click it and in the resulting menu, see that First Step is selected. If not, select it.
Description of this image -
Enter the following parameter values in the Properties pane.
- Context: Global
- Logical Schema: google-finance-get-quote
- Main Operation: getQuote
- Response File:
<vm_file_path>/getQuoteORCL.json - Append to Response File: No
- Trace File:
<vm_file_path>/getQuoteTraceORCL.txt - Append to Trace File: No
For
<vm_file_path>,enter a location on your machine where the response files will be saved.You can always test the service by clicking Test Restful Service button.
Description of this image Note that clicking the Test Restful Service button in the above scenario will result in the following error due to changes in the finance.google api:
Description of this image -
From Toolbox, add another OdiInvokeRESTfulService step into the Package map area, then enter the following parameter values:
- Context: Global
- Logical Schema: google-finance-get-quote
- Main Operation: getQuote
- Response File:
<vm_file_path>/getQuoteAAPL.xml - Append to Response File: No
- Trace File:
<vm_file_path>/getQuoteTraceAAPL.txt - Append to Trace File: No
- Click Request Query tool parameter, and set q: NASDAQ:AAPL
For
<vm_file_path>,enter a location on your machine where the response files will be saved.
Description of this image -
Click Next step on success. Click on the first OdiInvokeRESTfulService and drag the cursor to the second one. This create a link between the two.
Description of this image -
In the ODI toolbar, click Save, then click Run. Click OK in the Run dialog window, and again in the Information dialog window. Package execution will fail due to changes in the finance.google api.
Description of this image -
Close PkgGetQuote.
Using Template Parameters
The following sections illustrate how to use parameters with the REST tool.
Creating an Operation With Parameters
-
In the Topology tab, expand Technologies, RESTful Service and GoogleFinanceRestService, then double-click GoogleFinanceRestService./finance.
Description of this image -
In the GoogleFinanceRestService./finance page, switch to the Operations tab, then click Add Operation and add the following:
- Name:
getQuoteUsingTemplateParams - Method: GET
- Query Parameter: Click ..., then click Add Parameter in the Edit Query Parameters dialog window, and add the following parameters:
- Template Parameter: Click ... and enter
ORCLin the Value field for symbol.
Name Value client qq#[symbol#}
Description of this image - Name:
-
In the ODI toolbar, click Save, then close GoogleFinanceRestService./webservice/v1/symbols/.
Using the REST Tool Invocation to get json/xml Response
-
Switch to the Designer tab and expand Projects, Beta, right-click Variables and select New Variable.
Description of this image -
In the New Object form, enter
var_symbolin the Name field and select Text for Datatype.
Description of this image -
In the ODI toolbar, click Save, then close var_symbol.
-
In the Designer tab, under Projects and Beta, expand Rest Tool Invocation, right-click Packages and then select New Packages.
Description of this image -
In the New dialog window, enter
PkgGetQuoteUsingVariablesin the Name field, enter a suitable description in the Description field, and then click OK.
Description of this image -
In the Toolbox pane, select OdiInvokeRESTfulService, then click in the Package mapping area to add it as the first step.
-
Set the following parameter values in the Properties pane below for OdiInvokeRESTfulService1:
- Context: Global
- Logical Schema: google-finance-get-quote
- Main Operation: getQuoteUsingTemplateParams
- Request Template: Click ... then set the value for symbol
AAPL, then click OK. - Response File:
<vm_file_path>/getQuote_AAPL.json - Append to Response File: No
- Trace File:
<vm_file_path>/getQuote-TRACE_AAPL.txt - Append to Trace File: No
For
<vm_file_path>,enter a location on your machine where the response files will be saved.
Description of this image -
From the Designer tab, under Projects, Beta, Variables, drag and drop var_symbol into the PkgGetQuoteUsingVariables package map, then set the following parameter values:
- Type: Set Variable
- Value:
GOOG
Description of this image -
In the Package toolbar, click Next step on Success, then click odiInvokeRESTfulService1 and drag your cursor to var_symbol, creating a link between the two steps.
Description of this image -
From the Toolbox pane, select OdiInvokeRESTfulService, then click in the package map area to add it as the third step. Set the following parameter values:
- Context: Global
- Logical Schema: google-finance-get-quote
- Main Operation: getQuoteUsingTemplateparams
- Response File:
<vm_file_path>/getQuote_GOOG.json - Append to Response File: No
- Trace File:
<vm_file_path>/getQuoteTraceGOOG.txt - Append to Trace File: No
- Click RequestTemplate tool parameter and set Symbol:
#var_symbol
For
<vm_file_path>,enter a location on your machine where the response files will be saved.
Description of this image -
In the Package toolbar, click Next Step on Success, then click var_symbol step and drag the cursor to the OdiInvokeRESTfulSerive2 step, creating a link between the two steps.
Description of this image -
In the ODI toolbar, click Save, then click Run. Click OK in the Run dialog window, and again in the Information dialog window. Package execution will fail due to changes in the finance.google api.
Want to Learn More?
Credits
User Assistance Developers: Ian Bristow, Jenny Chan, Minu Nair
Other Contributors: Julien Testut, Ayush Ganeriwal
Resources
You can read more about Oracle Data Integrator 12.2.1.2.6 with our documentation.
Download ODI from Oracle Technology Network to evaluate it. There are also links to white papers, videos and webcast recordings.
More OBEs for ODI are available from the Oracle Learning Library.
ODI 12.2.1: Integrating RESTful Services