Monday, October 10, 2016

Oracle Process Cloud Service Connectors (Part 2 of 2): REST Service Connector

In the previous post we saw how you can use the Web Service Connector in Oracle Process Cloud Service to exchange data with an external application using the SOAP protocol.

Oracle Process Cloud Service also supports the REST architecture to retrieve, create, update and delete data using REST services and this is what we will look into in detail.

To create a REST service connection in Oracle Process Cloud Service, you need the following information:
  • REST Service definition (for example, WADL, RAML, YAML, etc.)
  • Resource URLs
  • Access to the resource URLs to retrieve JSON sample
  • List of operations to use on each resource
  • List of parameters for each operation
  • In case of a secured REST service, the credentials (username and password) to access the service
Without losing any time, let's see how you can create a REST Service Connector in Oracle Process Cloud Service using a very simple scenario.

I will be using one of the many publicly available web services to retrieve the states and territories of a country. The service url is "http://services.groupkt.com/state/get/{countryCode}/all" and the service requires you to supply a country code in the form of a 3 character ISO code and will return a list of states in JSON format.

In a nutshell, what we will develop is a process that will invoke the REST service described above. The process will start with a form pattern, where the user will type in the 3 character ISO country code. The process will then invoke the REST service, passing it the country code entered by the user and using a second human task, we will display the first state of that country.

First thing that we will do is to create a new application in Oracle Process Cloud Service (I've named it "Rest Service Connector Demo App" under a new space called "aantoniou").

Next we will create a process to hold the two human tasks and the service call. So from the "Create a Process" screen, select the "Start with a form" pattern, give your process a name and click on "Create".

Edit the "Start" component and open it's implementation details and enter a title for the start component (for example, "Retrieve Country States").

Under the "Web Form" section click on the blue add button to create a new web form and give your web form a name. Ensure you selected "Open Immediately" to open the web form for editing.

In the web form designer, drag and drop on the form canvas a dropdown and a text field. Name the dropdown component "Country Code" and the text field "State" and ensure the "State" text field is disabled (by unchecking the "Enabled" property).

Go to the "Country Code" dropdown properties and add a few options in the form of a "display=key" value-pair. Your "Country Code" dropdown should like as below.

We can now move on and create the Rest Service Connector. From the "Application Home" tab, go to "Connectors", click on the plus icon and select "New Rest Connector" to create a new connection. Give your rest connector a name and supply the base URL of your REST service.

In the "Rest Connector Editor"  click on the "Add" button to create a new resource. Give your resource a name and update the base url path to reflect your resource location.

Once we have defined a resource we can now go on and create an operation (or more if we want) on that specific resource. We will create a "Get" operation, so from the "Add" button select the "Get operation" and click on the newly created operation to open its properties. In the path property we will enter the full path of the operation. This is "get/{countryCode}/all". Please notice how Oracle Process Cloud Service automatically identified the parameter in the operation path and created it for you under the parameters section.

Because of the "semi-structured" nature of REST servicesN (and their JSON response), we need to instruct our REST service connector what the response will look like. Therefore from the "Response" tab click on the plus icon to create a business object to store the REST service response. Supply a name for your business object and enter the JSON response of your service (Oracle Process Cloud Service will inspect the JSON response and construct appropriate XML elements).

Click "Apply" to apply your changes and dismiss the operation window and save your work.

Our REST Service Connector is ready for use. Go back to your process and drag and drop from the component palette a "Service" component between the "Start" and "End" components.

Rename the "Service" component to "States Service" and go to its implementation details to define its implementation type. From the "Type" drop down select "Service Call" and click on the pencil icon to configure the "Service Call".

From the "Configure" window select the "Rest" service type and using the connector browser select the REST Service Connector you above (if you followed my exact steps this will be "DemoRestConnector"). The "Resource" and "Operation" drop down lists should be automatically populated with the appropriate resource and operation you created on the REST service.

Next we need to pass to the service call the Country Code that will be entered by the user in the process start form and pass back to the process response from the REST service (the first state).

So with the service component selected, click on the "Data Association" button and assign your form's Country Code element to the countryCode. You should get an exception saying that you cannot assign CountryCodeType to a string. That's because country code is an enumeration of elements. To fix this error just surround your assignment with string() function to convert it to a string.

Next we need to assign the response of the service to the form's state element. So from the "Output" tab, click on the function button (fx) to open the expression editor. Expand the "body" element, "restResponse" and "result" and select the "name" element and click on "Insert Into Expression".

Please note that the response is an array of states, therefore we need to instruct PCS to retrieve a specific array element. We will be displaying just the first state, so update your expression as follows:
"body.restResponse.result[1].name"

Click "OK" to dismiss the "Expression Builder" window and "Apply" to apply your configurations.
Drag a "Submit" component (Human Task) next to your service component, rename the "Submit" component to "View Service Result" and from its implementation details ensure you selected the same web form you created for the "Start" component.
We are now ready to test our application. And for testing we will be using the Application Player feature of Oracle PCS which basically deploys a version of your application to runtime using a special runtime partition and allows you to inspect inline execution of your process.
Click on the "Play Process" button just above your process and then click on the play button that is shown just above the "Start" button. This will bring up the "Play" window which allows you to select the user to perform this task. I will use the default one and click on the "Run" button.
This will bring up your web form. From the "Country Code" select a country and click on the submit button.
You should see your process execution path with the token being now at the "View Service Result" human task. Click on the "Play"button which now appears just above the "Submit" task and from the "Play" window click on the "Run" button and select "Launch Form" to open your web form.
You should now see the "State" field being populated with the REST Service's result. 

Friday, July 15, 2016

Oracle Process Cloud Service Connectors (Part 1 of 2): Web Service Connector

Oracle Process Cloud Service applications can communicate and exchange data with external applications that are exposed as either REST or Web Services.

In this first part of a two part series on connectors we will explore the Web Service Connector in Oracle Process Cloud Service to exchange data with an external application using the SOAP protocol.

To create a Web Service (SOAP) connection in Oracle Process Cloud Service, you need the following information:
  • WSDL file (upload from file or remove via URL)
  • The WSDL file should include a port type and a callback port type 
  • If the service you are trying to invoke is secure, then you will need the username and password required to access the service
So let's see how you can create a Web Service Connector in Oracle Process Cloud Service. The scenario will be quite simple. 

We will have a process that will invoke a publicly available web service, GeoIPService to lookup countries by IP address. The process will start with a form pattern, where the user will type in the IP address. The process will then invoke the GeoIPService, passing it the IP address typed in by the user and using a second human task, it will display the country where that IP address is.

First thing that we will do is to create a new application in Oracle Process Cloud Service. I've named it "Web Service Connector Demo App" and created a new space (aantoniou) to file this new application under.
Next we will create a process to hold the two human tasks and the service call. So from the "Create a Process" screen, select the "Start with a form" pattern, give your process a name and click on "Create".
Edit the "Start" component and open it's implementation details and enter a title for the start component (for example, "Resolve IP Address"). 
Under the "Web Form" section click on the blue add button to create a new web form and give your web form a name. Ensure you selected "Open Immediately" to open the web form for editing.
In the web form designer, drag and drop on the form canvas two text fields. Name the first one "IP Address" and the second one "Country" and ensure the "Country" text field is disabled (by unchecking the "Enabled" property).
Now its time to go and create the Web Service Connector. From the "Application Home" tab, go to "Connectors" and click on the "New Web Service" plus icon to create a new connection. 
In the first train stop, you need to select the source for the WSDL. You can use an existing WSDL file (that was uploaded before), you can upload your WSDL from a file or use a URL to point it to an external WSDL.
I will use the latter option to point it to the GeoIPService WSDL URL (which is http://www.webservicex.net/geoipservice.asmx?WSDL)
In the second wizard train stop, give your service a name and select the appropriate "Port Type" and "Callback Port Type" and click "Next".
In the third wizard screen you can configure some advanced properties like the "Read Time Out", "Connection Time Out" and "Security". I will leave the default and click "Create".
Our Web Service Connector is ready for use. So go back to your process and drag and drop from the component palette a "Service" component between the "Start" and "End" components.
Rename the "Service" component to "GeoIPService" and go to its implementation details to define its implementation type. From the "Type" drop down select "Service Call" and click on the pencil icon to configure the "Service Call".
From the "Configure" window select the Web Service Connector name you created in the previous step and the appropriate operation and click on "OK".
Next we need to associate all required data for the service call, both for the request as well as the response. So with the service component selected, click on the "Associate the data" button and assign your form's IP Address element to the ipAddress request element and assign your service's response countryName element to your form's country element and click "Apply".
Drag a "Submit" component (Human Task) next to your service component, rename the "Submit" component to "View Service Result" and from its implementation details ensure you selected the same web form you created for the "Start" component.
We are now ready to test our application. Instead of deploying to test our application, we will be the Application Player, a very nice feature of Oracle Process Cloud Service where PCS deploys a version of your application to runtime using a special runtime partition.
Click on the "Play Process" button just above your process. Click on the play button that is shown just above the "Start" button. This will bring up the "Play" window which allows you to select the user to perform this task. I will use the default one and click on the "Run" button.
This will bring up your web form. Enter your IP address and click on the submit button.
You should see your process execution path with the token being now at the "View Service Result" human task. Click on the "Play"button which now appears just above the "Submit" task and from the "Play" window click on the "Run" button and select "Launch Form" to open your web form.
You should now see the "Country" field being populated with the Web Service's result. 


Friday, June 17, 2016

Oracle Process Cloud Service - Web Form Design Approaches

Oracle Process Cloud Service uses a standards-based technology called "Web Forms" for defining the user interface in business processes. It's based on standards such as XHTML, CSS and JavaScript and allows business analysts and developers to create an end-user interface by just using the browser.

There are three approaches that can be employed when designing web forms:

Form-First: You can follow a "Form-First" approach where you create the form first before any data elements are defined and you let PCS by just drag and dropping components from the component palette to the page.

Oracle PCS will automatically generate the schema that defines the data required by the web form.

The schema that is automatically generated by Oracle PCS is based on the web form controls added to the web form and can be located under "Business Types" section.

When you assign the web form to a human task activity, the schema generated by Oracle PCS will automatically be used to define the human task data structure.

Data-First: A data-first approach implies a bottom-up approach where you create a web form based on data sources or business objects by just drag and dropping the objects on the form to create controls.

In the "Business Types" section you can import your XML schema definition files (XSDs) which you can then use in your web form. 
During the import process Oracle PCS will validate your XML schema and will only allow you to import your XSD if it's valid.

Select the element on which you want to create a business object, give your business object name and optionally create a new parent module (used for grouping business objects).

You will see your new business object  created under "Business Types".
Your new business object is ready for use. You can either use it on an existing web form or create a new one.

However, to make your new business object available for use to a web form, you need to open the  "Form Business Objects" and assign it to your web form (by shuffling it from the selected pane to the selected pane).
You business object should be available now under the "Data Sources" section of your web form.

You can either add individual business object attributes or add the entire business object by clicking on the green plus button. Oracle PCS will automatically translate the business object attributes to Web Form components (which of course you can customize).

Hybrid (Data-First and Form-First): The third and last approach that you can follow uses a combination of the above two approaches, that is a hybrid data-first and form-first approach.
    You can create soma parts of a web form from scratch while other sections can be based on existing data sources and data objects.

    Thursday, June 2, 2016

    Live demo of Oracle PCS at AMIS 25 - Beyond the Horizon

    AMIS is celebrating 25 years in business and I've been invited to present at the conference.

    Join my session to see how you can create a basic travel request application, from scratch, in Oracle Process Cloud Service in 25 minutes. Using different "hats", this session will demonstrate the use of the composer and its artifacts to develop and test applications and the workspace, the end-user environment for performing process tasks but at the same time the administrator environment for monitoring process performance.

    Session Link: http://www.amis-conference.com/Session-Catalog#session2689

    Speaker Bio: http://www.amis-conference.com/Speaker-Bios#AntonisAntoniou

    Thursday, May 19, 2016

    Peer-to-Peer Interview for Oracle Magazine

    I was recently interviewed by Oracle Magazine with my life journey featuring under the Peer-to-Peer section. If you would like to see how technology has changed my life and what I would like to see Oracle as a company do more then read my story!

    Oracle Magazine also published a video on YouTube on "What I would like to see Oracle, as a company, do more of?"

    Thursday, May 12, 2016

    How Digital Platforms are enabling Digital transformation transforming existing Business models

    Join my session at the 6th ICT Summit in Nicosia to learn how companies are leveraging Middleware & Big Data to support their Digital Transformation initiative.

    AbstractLeveraging Middleware & Big Data in your transformation journey. The Interactive keynote will provide an exploratory overview of how Companies are leveraging Digital technologies creating Digital business platform to support their Digital transformation initiatives.The keynote will feature examples of companies who have undertaken their Digital transformation journey successfully, and will showcase the importance and opportunities of leveraging Middleware and Big Data in building a Digital business platform.

    Event Link: ICT Summit 2016

    Monday, March 28, 2016

    Oracle BPM/SOA Human Task: Java code in jsp source files is not allowed in ojsp.next mode

    Today I came across an exception while trying to load one of my task details (v12.2.1).

    Error: OracleJSP error: oracle.jsp.parse.JavaCodeException: Line # 14, oracle.jsp.parse.JspParseTagScriptlet@66e50889
    Error: Java code in jsp source files is not allowed in ojsp.next mode

    What was really strange to me was that I did not do anything different from what I used to do with previous versions.

    After some research I found out that this was a known issue for 12.2.1. There are two possible causes for getting this error.

    a) Either you are not using the fully qualified host name  (including domain name) for the forms to render properly. See Configuring the SOA Human Task Hostname

    b) If you indeed using the fully qualified host name for your forms then you should open the default generated login.jsp page and remove the line containing <% ... %> and redeploy the form project.