Enterprise Java

Consuming JSON based REST Web Service in ADF 12.2.1.3

Previously I have posted about consuming ADF BC based REST Web Service in ADF. Now, this post talks about consuming JSON based REST Web Service using generic data control.

You can also look at previous posts on Web Service for more information.

Create SOAP Web Service with Application Module quickly in ADF 12.2.1

Create REST Web Service with Application Module declaratively in ADF 12.2.1

Consuming a SOAP Web Service quickly using Web Service Data Control (WSDL) in ADF

Create POJO based JAX-WS WebService easily with JDeveloper 12.1.3

Populate data in ADF Table using Web Service Data Control

Populate select one choice using Web Service Data Control in ADF Application

Access JAX-WS web service from Java Class using Web Service Proxy in JDeveloper

In this post, I am using a free REST API Web Service to get all countries name. Check below link for detail of Web Service methods.

RESTful web-services to get and search Countries

Let’s see how to implement this in JDeveloper 12.2.1.3

Create a Fusion Web Application with default Model and View Controller projects.

Consuming JSON

Right click on the View Controller project and Select New–> From Gallery–> Business Tier–> Web Services and select Web Service Data Control SOAP/REST 

Consuming JSON

It opens Web Service Data Control creation wizard, Select REST as Web Service type and provide a meaningful name, Generic Data Control with manually described resources as the type of data control.

Consuming JSON

Click on the green plus icon to create new ADF Rest Connection, Enter connection name and URL of the web service.

Here URL of web service is http://services.groupkt.com/country/get/all and I am using http://services.groupkt.com/country/get, /all is left here as it’ll be used later. Select authentication type none and test connection.

Consuming JSON

Click on OK and you can see that REST connection is created. Click on the next button and skip OWSM policies and come to the Resources tab.

Now click on green plus icon and add /all as the resource path, select GET method checkbox and put a name for the method and set JSON as Data Format.

Consuming JSON

Click on Next button and set method payload, Select Parse from Sample Code and access web service from the browser and paste the code in Response Sample.

For this post click on this link to copy the sample response – http://services.groupkt.com/country/get/all

Consuming JSON

Click on Next and Test Rest Connection.

Consuming JSON

On the click of the finish button, a file DataControls.dcx is generated. This is a data control definition file and contains information about data collection nodes and built-in data collection operations.

Consuming JSON

Now consuming web service part is done and next is to create a page and use WSDL to show a table on that page.

Right click on the view controller and select New–> From Gallery–> Web Tier–> JSF/Facelets and create a new page

Consuming JSON

Expand Data Controls section of Fusion Web Application and you can see there a get() method and under it the message and result data collection.

Drop get() method as a button and both collections as the table on the page and run application.

Consuming JSON

Published on Java Code Geeks with permission by Ashish Awasthi, partner at our JCG program. See the original article here: Consuming JSON based REST Web Service in ADF 12.2.1.3

Opinions expressed by Java Code Geeks contributors are their own.

Ashish Awasthi

An Oracle ACE, Blogger, Reviewer, Technical Lead working on Oracle ADF
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button