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.
This module discusses the following topics:
|Calling a Web Service from Forms|
|Create a Web Service Stub|
|Call the Stub from a Forms Application|
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.
In order for this lesson to work successfully, you will need to have performed the following:
Install Oracle JDeveloper 9.0.4.
Install Forms Developer 9.0.4.
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|
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.
To create a new workspace and project, select File> New> General> Workspace and click OK.
Name the directory and the workspace WebServiceWS. Be sure that Add a New Empty Project is checked, then click OK.
Accept the default project name and click OK.
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.
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:
Click Next .
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 .
JDeveloper automatically creates the code required to call the Web service. Save and Rebuild the project.
(Optional Step).When you run a Web service stub from within JDeveloper, the proxy settings come from the IDE (
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
Replace " myproxy" with the host name of your proxy server.
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.
A dialog displays showing the name and location of the deployment descriptor. Accept the defaults and click Save.
The JAR Deployment Profile Settings Dialog displays. Select Dependency Analyzer and check the check box for Oracle SOAP. Click OK.
This creates a deployment node on in the system navigator. Select the node, right mouse click and select Deploy to JAR File .
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.
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.
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.
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.
Start up Oracle Forms Developer and create a new form. Create a canvas and a non-base table block.
and select the Java class created in JDeveloper. Click
. This creates a PL/SQL package for the
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.
. This creates a PL/SQL package for the Float Java class. This is required because the
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.
Now click Close to dismiss the dialog.
Create a button on the canvas and define a When-Button-Pressed trigger with the following code:
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.
Run the form and click the button. The message line now displays the exchange rate from US to UK currency.
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|