Showing posts with label Web Services in adf. Show all posts
Showing posts with label Web Services in adf. Show all posts

Sunday 30 March 2014

Use Web-Services in ADF

Hello ADF Fellas,
Today I'm sharing my experience of ADF in which I am going to create a ADF application that is going to use Weather's Web-Services.
WSDL Link:-
http://www.webservicex.net/globalweather.asmx?WSDL

Prerequisites:-
1. JDeveloper 11g R1.
2. Internet Connection.
Lets start from the beginning.

Name the Application as Weather_Web_Services.





Click Next



Select Finish.

Select New,Go to All technologioes


  • Name it as WSUrl
  • enter the url http://www.webservicex.net/globalweather.asmx?WSDL in the URL section.
  • Hit Services Button & See the results in below in Services column 
  • Select Next
  • Shuttle the Global Weather SOAP in the right hand side
  • You might select to use the Http Parameter it's not necessary tough.
  • Select Next For Step 3,4,5 then Finish.
You will find the data Controls in the application Navigator.



  • Double Click the adfc-config.xml from view-controller ->Web Content-> WEB-INF and then drag a new view to the adfc-config.xml


  • Double Click myView Object and create a JSF page with the same name.




  • Drag & Drop the second method from the data control on to the JSPX as it's the only method that's required. as adf parameter form.


  • Now Drop the String return type to myView.jspx as ADF output text


  • Right Click the myView.jspx and select the Debug.


The data is Complete in it self, but not complete, it's showing data in XML format which is unusable for the end user.
so we need to parse it.
  1. Select the output String goto the property inspector,select advanced, select bindings,edit it from the Property Menu, create new Managed Bean.
  2. Name it as DataCollection in Bean Name as well as ClassName then OK then create new Property as fetchedData
  3. Now in the myView.jspx, select the GetWeather button. again go to the property inspector and select the action, edit it
    select the managed bean, DataCollection and create new method, name it as myWeather select OK.

  4. Go to the DataCollection.java.
    a) Create a String name data at class level, two int type variable x,y.
    b)  in the myWeather() paste this code.

     data=(String)fetchedData.getValue();

    c) print it on the console using System.out.println(data);

    d) data will now be printed on the console.

    e) Goto the myView.jspx and again right click to rebuild it. and data will be displayed on console.


  5. but the data is still coming as in raw from to the web-browser, to avoid it please select the output box and goto the source and make it's visibility false, or you can change it from the property inspector. it will hide the data to come on the web page.
  6. Now the main work starts here, to trim the data and make it usable to the users. copy & paste the code in the myWeather() of DataCollection class just after the code which I asked you write
            i=data.lastIndexOf("<Location>");
            j=data.lastIndexOf("</Location>");
            String s1=data.substring(i,j);
            s1 = s1.replace('<', ' ');
            s1=s1.replace('>', ' ');
            i=data.lastIndexOf("<Temperature>");
            j=data.lastIndexOf("</Temperature>");
            String s2=data.substring(i, j);
            s2=s2.replace('<', ' ');
            s2=s2.replace('>', ' ');
            i=data.lastIndexOf("<RelativeHumidity>");
            j=data.lastIndexOf("</RelativeHumidity>");
            String s3=data.substring(i, j);
            s3=s3.replace('<', ' ');
            s3=s3.replace('>', ' ');
            data=null; data="<h1>"+s1+"<br>"+s2+"<br>"+s3+"</h1>";
            System.out.println(data);
  7. and keep the return type to null. again debug it, now it will show data like this on the Console
  8. to make visible on Web Page drag another output text and bind it with DataCollection.java as earlier done and make new property named as getNewData.
  9. and make some last changes in the myWeather() copy & paste this code snipet just before the return statement
  10. getNewData.setValue(data);
  11. to make the data HTML compatible make some changes in the source of myView.jspx and after clicking on the second output text, write escape=false
  12. One last changes in the Assignment. go to the output text  and make it's value to a blank in the property inspector or in source of myView.jspx
  13. Some Final Touch Ups.
  14. Change the label of the City Name to "City Name" From the Property Inspector and Country Name to "Country Name" again from the property inspector.

A Guide to Installing Oracle HR Schema on an Existing Docker Container

  Hi Reader, Today I want to share my learning on how to install Oracle HR schema on a existing docker container. Step 1: Download the verif...