0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2]; if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; } obj.visibility=v; } } //Define function to show one layer and hide others: function show(whichLayer) { if(layerDisp) { showHide(layerDisp,'','hide'); } showHide(whichLayer,'','show'); layerDisp = whichLayer; } //Define function to keep score and display feedback: function Engine(question, answer, layerSuffix) { if (answer != ans[question]) { show('incorrect'+layerSuffix); } else { if (!done[question]) { score++; } show('correct'+layerSuffix); } done[question] = -1; } //Define function to verify answer for checkbox: function checkAnswer(question, whichform, whichbox) { var checkTotal = 0; with (whichform) { for (i = 0; i < whichbox.length; i++) { if (whichbox[i].checked == true) { checkTotal = checkTotal + eval(whichbox[i].value); } } } Engine(question,checkTotal,question*10); } //Define function to show correct answer for checkbox: function showAnswer(question, whichform, whichbox) { var residue = ans[question]; var currAnswer = 1; if(layerDisp) { showHide(layerDisp,'','hide'); } with (whichform) { for (i = 0; i < whichbox.length; i++) { if ((residue>0) && (residue%(currAnswer*2)==currAnswer)){ whichbox[i].checked = true; residue-=currAnswer; } else { whichbox[i].checked = false; } currAnswer*=2; } } } //Define function to init a form function clearForm(form) { //Set all checkboxes and radio buttons on form to unchecked: for (xx=0; xx < form.elements.length; xx++) { if (form.elements[xx].type == 'checkbox' | form.elements[xx].type == 'radio') { form.elements[xx].checked = false; } } } //Define function to init all forms on reload: function InitForm() { clearForm(document.form1) clearForm(document.form2) clearForm(document.form3) } // End --> //-->

Calling a Web Service from Oracle Application Server 10g Forms Services

Purpose

This module describes how to call a Web Service from Oracle Application Server 10g (OracleAS) Forms Services. The web services referred to is unfortunately no longer available online. See the corresponding How-To for 10.1.2 for a working example.

Topics

This module discusses the following topics:

 Overview
 Calling a Web Service from Forms
   Create a Web Service Stub
   Call the Stub from a Forms Application

Sample code and more information

Viewing Screenshots

 Place the cursor on this icon to display all screenshots. You can also place the cursor on each icon to see only the screenshot associated with it.

Overview

Back to List of Topics

OracleAS Forms Services provides a comprehensive application framework to deploy enterprise-class applications to the Internet with a rich Java interface. A key feature of Oracle Forms is that it provides a number of integration points to allow Forms to communicate with other technologies.

One of the most popular technologies now emerging is Web services. A Web service can be used to encapsulate any kind of business information, from an entire application to a simple service. Oracle Forms enables you to easily integrate a Web service into an existing Forms application through the use of the Java Importer.

Prerequisites

Back to List of Topics

In order for this lesson to work successfully, you will need to have performed the following:

1.

Install Oracle JDeveloper 9.0.4.

 

2.

Install Forms Developer 9.0.4.

 

 

Calling a Web Service from Forms

Back to List of Topics

In order to call a Web service from a Forms application, you must complete two main steps:

 Create a Web service stub (you can use Oracle JDeveloper to perform this step)
 Call the stub from a Forms application

Create a Web Service Stub

Back to List of Steps

The first step is to create th e Web service stub. In this example, you use a simple Web service available on the Internet that provides currency conversion. The Web service is defined by its WSDL. You use Oracle JDeveloper 10g to create the Web service stub. This stub is a Java class that provides the interface to the Web service. Forms calls the interface rather than invoking the Web service directly.

1.

To create a new workspace and project, select File> New> General> Workspace and click OK.

Move your mouse over this icon to see the image

Name the directory and the workspace WebServiceWS. Be sure that Add a New Empty Project is checked, then click OK.

Move your mouse over this icon to see the image

Accept the default project name and click OK.

Move your mouse over this icon to see the image

 

2.

With the new project selected in JDeveloper, select File> New> General> Web Services> Web Service Stub/Skeleton and then click OK. The Web Service Stub/Skeleton Wizard displays.

Move your mouse over this icon to see the image

 

3.

If the Welcome screen appears, click Next to go to Step 1 of 2 in the Wizard. On this screen, in the WSDL Document URL enter the URL that points to the WSDL of the Web service. For this example, the URL is:

http://www.xmethods.net/sd/2001/CurrencyExchangeService.wsdl

Click Next .

Move your mouse over this icon to see the image

 

4.

Step 2 of 2 in the Wizard displays. This shows the facilities available to be called on this Web service. These should be selected by default. Click Finish .

Move your mouse over this icon to see the image

 

5.

JDeveloper automatically creates the code required to call the Web service. Save and Rebuild the project.

Move your mouse over this icon to see the image

 

5a.

(Optional Step).When you run a Web service stub from within JDeveloper, the proxy settings come from the IDE ( Tools > Preferences > Web Browser/Proxy ). Because you intend to invoke the Web service stub from Forms, you may have to define the proxy settings in the code. If you are using a proxy, then you must modify the CurrencyExchangeServiceStub constructor.

Replace

m_httpConnection = new OracleSOAPHTTPConnection();

with

Properties prop = new Properties();
prop.setProperty(OracleSOAPHTTPConnection.PROXY_HOST, "myproxy"); prop.setProperty(OracleSOAPHTTPConnection.PROXY_PORT,"80");
m_httpConnection = new OracleSOAPHTTPConnection(prop);

Replace " myproxy" with the host name of your proxy server.

Move your mouse over this icon to see the image

 

6.

Although you have created only one class, that class relies on a number of other Java classes. The next step is to package all the relevant files into a single JAR file.

Select File > New > General > Deployment Profiles > JAR File - Simple Archive and click OK.

Move your mouse over this icon to see the image

A dialog displays showing the name and location of the deployment descriptor. Accept the defaults and click Save.

 

7.

The JAR Deployment Profile Settings Dialog displays. Select Dependency Analyzer and check the check box for Oracle SOAP. Click OK.

Move your mouse over this icon to see the image

 

8.

This creates a deployment node on in the system navigator. Select the node, right mouse click and select Deploy to JAR File .

Move your mouse over this icon to see the image

This saves the JAR file to disk. Note the full directory path and name of this JAR file. You will need this information to set your CLASSPATH in the next step.

Move your mouse over this icon to see the image

 

Call the Stub from a Forms Application

Back to List of Steps

For this part of the exercise you need a working installation of Forms.

Once you have created the Web service stub, the next step is to create a form to call the stub to invoke the Web service. For this simple test case, you add a button that calls the Web service stub and returns (and messages out) the rate of exchange. This functionality can be modified to fit the needs of your application.

1.

Select Start > Settings > Control Panel .

Double-click on System, select the Advanced tab and click the Environment Variables button (or just select the Environment tab on NT).

From the System Variables, select CLASSPATH and then click Edit (there is no Edit button on NT).

Add the full directory name and name of the JAR file created in step 7 above.

Click OK (on NT, click S et , then OK) to dismiss the dialog.

Move your mouse over this icon to see the image

 

2.

The next step is to update the Forms environment file to indicate the location of the JAR file. The Forms environment file is called default.env in a default installation.

Prepend the full directory path and JAR file name to the CLASSPATH entry.

For example:

CLASSPATH=
d:\jdev904\jdev\mywork\WebServiceWS\Project1\deploy\archive1.jar;D:\...

Move your mouse over this icon to see the image

 

3.

Start up Oracle Forms Developer and create a new form. Create a canvas and a non-base table block.

Move your mouse over this icon to see the image

 

4.

Select Program > Import Java Classes and select the Java class created in JDeveloper. Click Import . This creates a PL/SQL package for the CurrencyExchangeServiceStub Java class.

Move your mouse over this icon to see the image

 

5.

Change the Import Classes field to java.lang.Float (just type this in) and click Options. Check the boxes Include inherited methods/fields and Include get/set for public fields. Click OK.

Click Import . This creates a PL/SQL package for the Float Java class. This is required because the CurrencyExchangeServiceStub returns an object of type Float. This is not native to Forms and so we also need to import the Float object.

Move your mouse over this icon to see the image

 

6.

Change the Import Classes field to java.lang.Exception (just type this in) and click Options. Check the boxes Include inherited methods/fields and Include get/set for public fields. Click OK.

Click Import . This creates a PL/SQL package for the Exception Java class. While this is not essential, it does make error reporting easier.

Move your mouse over this icon to see the image

Now click Close to dismiss the dialog.

 

7.

Create a button on the canvas and define a When-Button-Pressed trigger with the following code:

DECLARE
 jo ora_java.jobject;
 rv ora_java.jobject;
 ex ora_java.jobject;
BEGIN
 JO := CurrencyExchangeServiceStub. new;
--
--This will get the exchange rate from US Dollars to UK Sterling.
--
 RV := CurrencyExchangeServiceStub.getRate (JO,' USA',' UK' );
 message (float_.floatValue (RV));
EXCEPTION
 WHEN ORA_JAVA.JAVA_ERROR then
   message (' Unable to call out to Java, ' ||ORA_JAVA.LAST_ERROR );
 WHEN ORA_JAVA.EXCEPTION_THROWN then
  ex := ORA_JAVA.LAST_EXCEPTION;
  message (Exception_.toString (ex ));
END;

This calls out to the Java class with two parameters. The Java class returns the exchange rate that the code then displays as a message.

Move your mouse over this icon to see the image

 

8.

Run the form and click the button. The message line now displays the exchange rate from US to UK currency.

Move your mouse over this icon to see the image

 

0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //-->

Sample code and more information

Back to List of Topics

The following links point to more sources of information related to this topic.

Oracle Forms Services
Demo of calling a Web service from Forms (demo is near bottom of page)
Learn more about Web services at the Web Services Center on OTN
Using a WSDL to create a stub
Learn more about the Forms Java Importer

 Place the cursor on this icon to hide all screenshots

Copyright © 2004 Oracle Corporation. All Rights Reserved.

 

 

 

Left Curve
Popular Downloads
Right Curve