Please disable your adblock and script blockers to view this page

Search this blog

Wednesday, 26 December 2018

Consume ADF BC based REST Web Service using ADF REST Data Control

Creating and consuming web service is an important part of the development cycle in any technology. Here in this post, I am going to show that how can we consume ADF BC based REST web service in an ADF application. In ADF 12.2.1 release Oracle provides support for declaratively consuming REST Web Service, Before that it was only possible using java and that was a tedious task for fusion developers.

Suppose I have an ADF BC (Business Components) based REST web service that returns a list of Departments. Now to consume that web service we'll use ADF REST Data control. Here I am going to illustrate this step by step.

I am using JDeveloper 12.2.1.3, Let's start with Creating a Fusion Web Application with model and view controller project.



Right click on the Model 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, Select Describe-Based ADF Data Control 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 you should know that URL of ADF based REST web service typically has a host, port, context root path with version name, resource name. So URL of my web service is this

http://127.0.0.1:7101/RestWebServApp-RESTWebService-context-root/rest/Jdev12.2.1/Department

and to make it REST Describe URI just add describe after resource name and put that URL in URL Endpoint field

http://127.0.0.1:7101/RestWebServApp-RESTWebService-context-root/rest/Jdev12.2.1/Department/describe

Default authentication type is none so leave it and test the connection.



Click on OK and you can see that REST connection is created.



Click on next button and come to Select Resources tab and add resources to the selected side.



On the Finish tab test REST connection once again and you can see It is successful.



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 Departments data collection node. On expanding it you can see the attributes of the Departments table and its operation.



Select Departments from data control and drop it on the page as ADF table, Also dropped Previous and Next operation as a button on the page.



Now run and check application, Data is populated from the web service using ADF REST data control



Click on Next button to navigate between rows



All done 🙂 

This is how you can consume an ADF BC based REST WebService in Fusion Application. 

Friday, 14 December 2018

Top 20 Most Popular Technologies (Programming/Scripting Languages) in 2018

 2018 came to an end and like every year StackOverflow performed a developer community survey asking developers about their favourite technologies, learning process, location, job type, experience etc.

This survey has an opinion of more than 100,000 developers across the world and as per their survey here goes a list of top 20 most popular programming languages across the world.


Here you can see that JavaScript is the winner with 69.8% developers using it and as per StackOverflow's previous year surveys, JavaScript is the most used programming/scripting languages since last 6 years. Java is the 5th most popular programming language with 45.3% developer base.

You can also see that HTML is widely used as it is the second most popular technology. There are more backend developers (57.9%) than front-end developers (37.8%) and you'll be surprised to know that 80% of user are coding as a hobby. There are only 1.7% developers with 30+ years of experience and approx 20% of developers are student. 87% of users taught themselves a new language and framework without taking any course. Python is the fastest growing programming language, for details go through this article - The Incredible Growth of Python

Read complete Stack Overflow Developer Survey 2018

Wednesday, 5 December 2018

Get All URLs From a Website Using Java Code


In this post, I am going to show you a Java class using that we can get all URLs from a website URL like a web crawler.

Here goes the Java Class





  1. package client;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.io.InputStreamReader;
  5. import java.io.Reader;
  6. import java.net.MalformedURLException;
  7. import java.net.URI;
  8. import java.net.URISyntaxException;
  9. import java.net.URL;
  10. import java.util.Enumeration;
  11. import javax.swing.text.MutableAttributeSet;
  12. import javax.swing.text.html.HTML;
  13. import javax.swing.text.html.HTMLEditorKit;
  14. import javax.swing.text.html.parser.ParserDelegator;
  15. public class GetAllUrls {
  16. public GetAllUrls() {
  17. super();
  18. }
  19. public static void main(String[] args) {
  20. final String name = "http://www.awasthiashish.com";
  21. Reader r = null;
  22. try {
  23. URL u = new URL(name);
  24. InputStream in = u.openStream();
  25. r = new InputStreamReader(in);
  26. ParserDelegator hp = new ParserDelegator();
  27. hp.parse(r, new HTMLEditorKit.ParserCallback() {
  28. public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) {
  29. if (t == HTML.Tag.A) {
  30. Enumeration attrNames = a.getAttributeNames();
  31. while (attrNames.hasMoreElements()) {
  32. String exactUrl = "";
  33. Object key = attrNames.nextElement();
  34. if ("href".equals(key.toString())) {
  35. exactUrl = a.getAttribute(key).toString();
  36. if (!a.getAttribute(key).toString().startsWith("http://") &&
  37. !a.getAttribute(key).toString().startsWith("https://")) {
  38. if (a.getAttribute(key).toString().startsWith("/")) {
  39. exactUrl = name + a.getAttribute(key);
  40. } else {
  41. exactUrl = name.concat("/").concat(a.getAttribute(key).toString());
  42. }
  43. URI uri;
  44. try {
  45. uri = new java.net.URI(exactUrl);
  46. System.out.println(uri);
  47. } catch (URISyntaxException e) {
  48. }
  49. } else {
  50. URI uri;
  51. try {
  52. uri = new java.net.URI(exactUrl);
  53. System.out.println(uri);
  54. } catch (URISyntaxException e) {
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }
  61. }, true);
  62. } catch (MalformedURLException e) {
  63. } catch (IOException e) {
  64. } finally {
  65. if (r != null) {
  66. try {
  67. r.close();
  68. } catch (IOException e) {
  69. }
  70. }
  71. }
  72. }
  73. }

and output on the console

Here you can see all the URLs linked to the home page of this website


Cheer 🙂 Happy Learning