Oracle Application Builder Cloud Service (ABCS) has been renamed to Visual Builder Cloud Service (VBCS), so this blog series about ABCS continues as a blog series about VBCS. In this blog I will explain how to call a REST endpoint and create a Business Object based on this REST Service. There are several ways to do this, but I will start with the most basic one. The data that we get from the REST service will only be presented (read-only), we will not send updates/posts to the REST endpoint.
To give a speaker overview in our application, we have a REST service that returns a list of speakers speaking at the Tech17 Conference. Once again, this is just a demo service and a demo application. For the real Tech17 information (the Conference was held on June 15 & 16), visit www.tech17.nl. The REST endpoint we are using looks like this:
Now in the left hand side menu within VBCS we have to go to the Extensions, this is a submenu under Application Settings.
This will bring up the Extensions page, where we will create a new Business Object Provider (BOP).
We name this extension speakers and put it in the package nl.ogh.eventapp.
The template generates an overview and some example code. Within the Sources tab, we need to open the REST Operation Provider. We need to configure the correct endpoint, this happens within the code. I adjusted the baseURL variable to point to the speakers REST endpoint.
After this we need to configure the RESTEntityProvider to enter the details about the data that gets returned by the REST service. As you can see, we need to enter a singular and plural name as well as a description of the service, after which we get an array of properties. These properties are the fields we are going to use on the page within VBCS.
I identified the ID fields as the KEY field and the other fields (Name, Country, Biography) as Text field.
Now that we have specified the BOP with the endpoint and the properties, we can go to the Data Designer to specify the Service based on this BOP.
After going to the Services page, we see there is no resource yet and create a new Service by clicking on the green ‘Add Service’ button.
We choose to define a service based on the Catalog, since we have the extension/BOP predefined.
Now a wizard will be opened. In the first step we can see the speakers BOP we provided, so we select it.
In the ‘Business Objects’ step, we need to select Speaker, after which we enter a Name and Description.
In the Fields step, we can decide which Available Fields we want to drag & drop to the Selected column, in this case all of them.
In the final Test step, you can select the resource on the left and it will call the REST Service. If correctly configured you will see the data displayed as below.
When done, you can see the result in the Data selection of your Data Object. It will display the data retrieved from the REST Service.
Now that we have our Data Object in place that communicates with the REST Service through the BOP, we can start using this data on our page. When going back to the page designer, I select the Speakers page in Edit mode, after which I drag & drop a Listview from the component palette on the left hand side into the main area of the Speakers Page.
As you can see a wizard is being started. In the first step I can select the Business Object for the Listview, which I want to be the Speakers Object we just created. In the next step we can select the layout, in this case a one column layout will be sufficient.
In the mapping selection we can drag and drop the Fields on the Page.
We only need to drag and drop the Fields in the first row. The Design mode of VBCS already shows you the result of this action within the several rows.
Now our Speakers page is created. To see the changes in the live version, we need to change the security of the speakers page to anonymous access and redeploy the application as version 1.4.
When checking the live page after redeployment, we can see the Speakers page within the application.