Friday, October 9, 2020

ODI and Web Services (REST API)

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

In the ODI toolbar, click Save, then click OK in the Information dialog. Click Test Connection, then OK in the Information dialog.

 

We might get as an error also

But No need to worry save and proceed..

Note: Incase of test connection fails ( throws some null errors ) , then  change internet connection, refresh ODI and try it..

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

Save it..

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

Enter name and assign physical schema with context and save it..

Topology set up has been completed ..

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

Create a folder as RestToolDemo

In the Designer tab, under Projects, expand Demo and Rest Tool demo, then right-click Packages and select New Package.

Create a new package, enter name and description..

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: LS_googleFinance (select your Logical schema)

·      Main Operation: getQuote

·      Response File: <vm_file_path>/getQuoteORCL.json ( create your own file path,

Eg my path: C:\Users\SSS2019084\Desktop\ODI Practice\ODI_12c_Docs\getQuoteORCL.Json

·      Append to Response File: No

·      Trace File: <vm_file_path>/getQuoteTraceORCL.txt ( create your own file path,

·      Eg my path: C:\Users\SSS2019084\Desktop\ODI Practice\ODI_12c_Docs\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.

 

From Toolbox, add another OdiInvokeRESTfulService step into the Package map area, then enter the following parameter values:

·      Context: Global

·      Logical Schema: LS_googleFinance (select your Logical schema)

·      Main Operation: getQuote

·      Response File: <vm_file_path>/getQuoteAAPL.xml ( create your own file path,

Eg my path: C:\Users\SSS2019084\Desktop\ODI Practice\ODI_12c_Docs\getQuoteAPL.xml

·      Append to Response File: No

·      Trace File: <vm_file_path>/getQuoteTraceAAPL.txt( create your own file path,

·      Eg my path: C:\Users\SSS2019084\Desktop\ODI Practice\ODI_12c_Docs\getQuoteTraceAPL.txt

·      Append to Trace File: No

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.

Click on TestRestful service..

 A window will open like below

Click on send request

You will get an content like below ( if you get response content only then the webservices connected properly in Topology)

Click on save and run

The package executed successfully..

Files are Generated on my path successfully..!!



No comments:

Post a Comment