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.
Right click on the View Controller project and Select New–> From Gallery–> Business Tier–> Web Services and select Web Service Data Control SOAP/REST
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.
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.
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.
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
Click on Next and Test Rest Connection.
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.
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
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.
All done 🙂
Sample ADF Application (Jdev 12.2.1.3) – Download
Cheers 🙂 Happy Learning
hi
thank you for the post
But the download sample application is corrupted.
Hi Tarek
Are you not able to download the app?
Or downloaded app is corrupted?
Hi Ashish, do you have any blog post which corresponds how to consume a post method? I need to call a POST method in a REST web service and pass it a sample body which upon calling the service should return me the sample response. Kindly let me know if you have any such post. Thanks.
Hi Mahesh
You can check Timo’s post JDeveloper 12.2.1.3: REST POST Sample
Ashish