testcontent
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:
| |
Overview | |
| |
Calling a Web Service from Forms | |
| |
Create a Web Service Stub | |
| |
Call the Stub from a Forms Application | |
| |
||
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.
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:
| 1. |
Install Oracle JDeveloper 9.0.4.
|
| 2. |
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.
| 1. |
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.
|
| 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.
|
| 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: Click Next .
|
| 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 .
|
| 5. |
JDeveloper automatically creates the code required to call the Web service. Save and Rebuild the project.
|
| 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
Replace with Replace " myproxy" with the host name of your proxy server.
|
| 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. 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.
|
| 8. |
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.
| 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.
|
| 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:
|
| 3. |
Start up Oracle Forms Developer and create a new form. Create a canvas and a non-base table block.
|
| 4. |
Select
Program
>
Import
Java Classes
and select the Java class created in JDeveloper. Click
Import
. This creates a PL/SQL package for the
|
| 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
|
| 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. 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: 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.
|
| 8. |
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.
Place the cursor on this icon to hide all screenshots