Oracle by Example brandingODI 12.2.1: Integrating RESTful Services

section 0Before 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?


section 1Starting ODI 12.2.1

  1. On your desktop, double-click ODI 12c Beta.

    ODI shortcut on Desktop
    Description of this image
  2. In ODI, click Connect to Repository.

    Connect to Repository
    Description of this image
  3. 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
    Log in to repository
    Description of this image

    The user and password is prepopulated from the wallet. If you're asked for the wallet password, enter welcome1.


section 2Creating Topology Configurations

Defining the RESTful Service

  1. In the Topology tab, expand Physical Architecture and Technologies, then right-click Restful Services and select New Data Server.

    New Data Server
    Description of this image
  2. In the New Object form, complete the following fields:

    • Name: GoogleFinanceRestService
    • REST Service Endpoint URL: http://finance.google.com
    GoogleFinanceRestService
    Description of this image
  3. In the ODI toolbar, click Save, then click OK in the Information dialog. Click Test Connection, then OK in the Information dialog.

    Test Rest Connection
    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.

  4. In the Topology tab, under Physical Architecture and Technologies, expand RESTful Service, right-click GoogleFinanceRestService and select New Physical Schema from the menu.

    New Physical Schema
    Description of this image
  5. In the GoogleFinanceRest Service Resource URI form, enter /finance in the Resource URI field. Note that the URI gets appended to the Name.

    Enter Resource URI
    Description of this image
  6. 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
    • Add Operations and Query Parameters
      Description of this image

      Click OK to dismiss the Edit Query Parameters dialog box.

  7. In the ODI toolbar, click Save. Click OK to dismiss the Information dialog box.

  8. Switch to the Context tab. Click Add to add a Context. Enter the following:

    • Context: Global
    • Logical Schema: google-finance-get-quote
    Enter Context
    Description of this image
  9. In the ODI toolbar, click Save, then close GoogleFinanceRest Service Resource URI.

Using the REST Tool Invocation to get json response

  1. In the Designer tab, expand Projects, right-click Beta and select New Folder.

    New Folder
    Description of this image
  2. 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.

    Name the folder
    Description of this image
  3. In the Designer tab, under Projects, expand Beta and Rest Tool Invocation, then right-click Packages and select New Package.

    New Package
    Description of this image
  4. In the New dialog box, enter PkgGetQuote in the Name field, a suitable description in the Description field, then click OK.

    Enter Resource URI
    Description of this image
  5. 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.

    First Package Step
    Description of this image
  6. 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.

    OdiInvokeRESTfulService Parameters
    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:

    REST Server Operation Error
    Description of this image
  7. 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.

    Second Package Step
    Description of this image
  8. 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.

    Third Package Step
    Description of this image
  9. 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.

    Session Successful
    Description of this image
  10. Close PkgGetQuote.


section 3Using Template Parameters

The following sections illustrate how to use parameters with the REST tool.

Creating an Operation With Parameters

  1. In the Topology tab, expand Technologies, RESTful Service and GoogleFinanceRestService, then double-click GoogleFinanceRestService./finance.

    Edit GoogleFinanceRestService./webservice/v1/symbols/
    Description of this image
  2. 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:
    • Name Value
      client q
      q #[symbol#}
    • Template Parameter: Click ... and enter ORCL in the Value field for symbol.
    Add operations values
    Description of this image
  3. In the ODI toolbar, click Save, then close GoogleFinanceRestService./webservice/v1/symbols/.

Using the REST Tool Invocation to get json/xml Response

  1. Switch to the Designer tab and expand Projects, Beta, right-click Variables and select New Variable.

    Create a new variable
    Description of this image
  2. In the New Object form, enter var_symbol in the Name field and select Text for Datatype.

    Create a new variable
    Description of this image
  3. In the ODI toolbar, click Save, then close var_symbol.

  4. In the Designer tab, under Projects and Beta, expand Rest Tool Invocation, right-click Packages and then select New Packages.

    Create a New Package
    Description of this image
  5. In the New dialog window, enter PkgGetQuoteUsingVariables in the Name field, enter a suitable description in the Description field, and then click OK.

    New Package
    Description of this image
  6. In the Toolbox pane, select OdiInvokeRESTfulService, then click in the Package mapping area to add it as the first step.

  7. 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.

    Set package parameter values
    Description of this image
  8. 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
    Add var_symbol to package map
    Description of this image
  9. 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.

    Create var_symbol step
    Description of this image
  10. 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.

    OdiInvokeRESTfulService2 Parameters
    Description of this image
  11. 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.

    Set third step parameter values
    Description of this image
  12. 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.


more informationWant 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.