Invoking Oracle Fusion Cloud REST services from SOA-CS

In this post I’ll brief about how we can trigger Oracle Fusion ERP Cloud REST services from Oracle SOA-CS.

Let’s take a requirement that to update a fusion cloud database table record. As we aware we won’t have access to cloud database and the only option left to us is making use of REST services provided by oracle.

So let’s go with the specific requirement that to update Expenditure Items table (pjc_exp_items_all). Simply search with the table name in google, you’ll get complete details about the table and columns in it.

This table belongs to Project Portfolio Management, so to search for any REST services available to update tables related to this, go through below Navigation.

Google -> Search for OER (Oracle Enterprise Repository) and open the site -> Select ‘Project Portfolio Management’ tab -> Under ‘Tables & Views’ category, select latest release (Release 13 Update 17b  by the time this post is blogged) -> In the left under REST API click on Project Portfolio Management -> In the page you can see all the available APIs.

Direct link for the same: https://docs.oracle.com/en/cloud/saas/project-portfolio-management/r13-update18a/fapap/api-Expenditure%20Items.html

There select the Expenditure Items API, you’ll be able to see all the methods, select required method (In our case select method ‘PATCH’ which is used to update an expenditure Item) .

Now in the page copy the path to be used for the method to invoke /fscmRestApi/resources/11.13.17.11/projectExpenditureItems/{ExpenditureItemId}

And In the examples, check the sample request and response, which we use to build our schema for input to the REST service.

1.png

Now let’s go into the development.

  • I’ve created a SOA project with BPEL (service defined later).
  • In the BPEL, first let’s create a Schema for the REST service. Make sure the schema attribute names must match with the attribute names given in the sample request, response.

4.PNG

  • In the schema two elements are created one is the primary key of table (ExpenditureItemId) and the other is updatable attribute (ExternalBillRateSourceName) in the cloud table (not all attributes are updatable).
  • Create REST service in the composite file and right click on it and ‘configure SOA WS policy‘ add security policy [oracle/wss_http_token_client_policy] and edit the policy, set csf-key (e.g: CW-key)
  • Put an Invoke activity in BPEL and call the REST service. In the Invoke add properties as given below.

[rest.binding.http.X-HTTP-Method-Override = ‘PATCH’,  rest.binding.http.Accept = ‘application/json’]

  • Create Assign activity and map the required values to the REST input variable.

This slideshow requires JavaScript.

Result: So if you pass ExpenditureItemId, ExternalBillRateSourceName values to REST service, it’ll update the  attribute ‘EXT_OVRD_BILL_RATE_SOURCE_NAME’ with the value coming from ‘ExternalBillRateSourceName’ for the already exist record with given ExpenditureItemId in the ‘pjc_exp_items_all’ table.

Reference (more details about security): http://www.ateam-oracle.com/invoke-fusion-cloud-secured-restful-web-services/

Hope you enjoyed the post!

Advertisements

SOAP and REST

This post covers features of SOAP and REST and basic differences between them.

SOAP

REST

  • SOAP stands for Simple Object Access Protocol
  • It is an XML based web service
  • Adds a layer on top of the application protocols. HTTP is the widely used application protocol.
  • SOAP is considered heavy weight as it provides significant pre-build extensibility in the form of the WS* standards through additional layer.

1

  • Request includes HTTP header, SOAP Envelope (which includes SOAP Header, SOAP Body (which includes XML message))
  • As it has additional layer, it supports attaching files in the request which should be in base64 bit format.
  • It provides more security than REST.
  • REST stands for Representational State Transfer
  • REST typically supports all types of text data formats. Widely used formats are XML and JSON
  • Uses HTTP protocol only. No another layer on top of HTTP protocol.
  • REST is light weight as it leverages HTTP transport and uses all HTTP Action Verbs (POST, GET, PUT, DELETE)

2

 

  • Request includes just HTTP header and XML/JSON message.
  • It doesn’t support attachment of files in the request.
  • REST provides security like token based, but comparatively REST security is less than SOAP.

Sample SOAP Request:

A SOAP Message is encoded as an XML document, consisting of an <Envelope> element, which contains an optional <Header> element, and a mandatory <Body> element. The <Fault> element is sub element of Body is used for reporting errors.

5.png

 

SOAP Envelope with SOAP Header.

3

Sample SOAP Response:

6.PNG

Sample REST Request in XML:

7

Sample REST Response in XML:

8

Sample REST Request in JSON:

9

Testing of SOAP/REST web service Requests can be done using SOAP UI tool.

Invoking REST webservice from JQuery using an AJAX call

Below code helps you to understand how we can Invoke a REST web service on click of a button using JQuery and AJAX.

Note: In Java you can Invoke REST web service using ApacheHTTPClient library.

HTML File:

<!DOCTYPE html>
<html>
<head>
<sscript type=”text/javascript”
src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js”></script&gt;
<sscript type=”text/javascript”>
$(document).ready(function () {
$(“#mybutton”).click(function () {
alert(‘welcome’);

$.ajax( {
type : “GET”, url : “http://services.groupkt.com/country/get/iso2code/IN&#8221;, dataType : “json”, success : function (data) {
alert(“Reading Msg: ” + data.RestResponse.messages);
alert(“Reading Name: ” + data.RestResponse.result.name);
}
});

});

});
</script>
</head>
<body>
<button type=”button” id=”mybutton”>Invoke REST WS</button>
</body>
</html>

Sample REST Services (thanks for making them available to developers for testing purpose):

http://www.groupkt.com/post/c9b0ccb9/country-and-other-related-rest-webservices.htm
http://services.groupkt.com/country/get/iso2code/IN
http://services.groupkt.com/country/get/all
http://rest-service.guides.spring.io/greeting

REST_invoke