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.
-
In ODI, click Connect to Repository.
-
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
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.
-
In the New Object form, complete the following fields:
- Name:
GoogleFinanceRestService
- REST Service Endpoint URL:
http://finance.google.com
- Name:
-
In the ODI toolbar, click Save, then click OK in the Information dialog. Click Test Connection, then OK in the Information dialog.
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.
-
In the GoogleFinanceRest Service Resource URI form, enter
/finance
in the Resource URI field. Note that the URI gets appended to the Name. -
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 client
q
q
NASDAQ:ORCL
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
-
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.
-
In the New Object form, enter
Rest Tool Invocation
in the Name field, then click Save in the ODI toolbar. Close the Rest Tool Invocation tab. -
In the Designer tab, under Projects, expand Beta and Rest Tool Invocation, then right-click Packages and select New Package.
-
In the New dialog box, enter
PkgGetQuote
in the Name field, a suitable description in the Description field, then click OK. -
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.
-
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.
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:
-
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. -
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.
-
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.
-
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.
-
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
ORCL
in the Value field for symbol.
Name Value client q
q
#[symbol#}
- 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.
-
In the New Object form, enter
var_symbol
in the Name field and select Text for Datatype. -
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.
-
In the New dialog window, enter
PkgGetQuoteUsingVariables
in the Name field, enter a suitable description in the Description field, and then click OK. -
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. -
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
-
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.
-
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. -
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.
-
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.