You want your application to retrieve the price of an item, given the item
number. This is handled by an RPG service program that contains a
procedure called QryProdCost. The WHOLESALE library contains an RPG
service program named CWWSSRV. This program contains a QryProdCost
procedure that can take the item numbers as input, open the Inventory file
within the WHOLESALE library, retrieve the price from the inventory database,
and return the price. To accommodate this task, the interface has two
parameters, one for the item number, and the other for the price. If
the item number or price is not found, the RPG program returns a message to
the interface.
To create this Web service, you first create a Java bean with the Program
Call wizard, to invoke the QryProdCost RPG procedure. Then, you use Web
services to enable the RPG procedure as a Web service through the Java
bean.
To create the Java bean:
- In the Web perspective, right-click Project514 and select
New > Other.
- Select iSeries > Java from the left pane of the window and
then select Program Call Bean on the right pane.
- Click Next to invoke the Program Call wizard.
- In the Java bean name field, underneath the Add
Program title, enter Inventory.
- In the Program object field, enter CWWSSRV, the name
of the RPG service program.
- In the Library field, enter WHOLESALE.
- From the Program type drop-down list, select
*SRVPGM.
- In the Entry point field, enter QryProdCost.
- Click OK to add the program definition.
Now that you have specified the program, you can add parameters. The
CWWSSRV RPG program contains the following two parameters:
- Item number parameter - The program uses this number to find the item in
the database.
- Item cost parameter - The program uses this number to find the item's
cost in the database.
To add the item number parameter:
- In the left panel of the Program Call wizard, click the
Inventory program call definition to select it. This action
re-populates the fields on the right side of the page.
- Click Add Parameter.
- In the Parameter name field, enter itemno.
- From the Data type drop-down list, select packed
decimal.
- In the Length field, enter 5.
- In the Precision field, enter 0.
- From the Usage drop-down list, select input.
- Click OK to add this parameter. In the left pane, note
that itemno appears beneath Inventory. Now you
are ready to add the second parameter.
To enter the item cost parameter:
- In the left panel of the Program Call wizard, click the
Inventory program call definition again to select it. This
action re-populates the fields on the right side of the page.
- Click Add Parameter.
- In the Parameter name field, enter cost.
- From the Data type drop-down list, select packed
decimal.
- In the Length field, enter 7.
- In the Precision field, enter 2.
- From the Usage drop-down list, select output.
- Click OK to add this parameter. In the left pane, notice
that cost appears beneath Inventory. At this
point, the wizard should look like this. Note that the icon to the left
of the a parameter shows if it is of type input, input & output, or
output:

To define the package name for these parameters, in the Program Call
Wizard,
- Click Next.
- In the Package field, enter scenario as a package
name. Leave the defaults in the other fields.
- Clear the Java Application check box.
- Note:
- Review the list of files under "These files will be generated by the wizard"
and note that the name of the generated Java bean will be
InventoryServices.java.
- Click Finish to generate the files.
After creating the Java bean that invokes the RPG program, the next step is
to convert the bean into a Web service so that other programs can access the
same RPG program over the Internet.
When creating the Web service, a Web Services wizard generates the WSDL
files that are distributed to users who need to use the Web Service. To
create the service:
- In the Navigator view of the Web perspective, expand Project514 >
Java Source > scenario.
- Right-click InventoryServices.java and select New >
Other.
- In the New window, click Web Services, click Web
Service on the right side of the window, and then click
Next.
- Select the Generate a proxy and the Test the generated
proxy check boxes.
- Click Next three times and notice the generation of the
necessary files. When you get to the Web Service Java Bean Identity
window, click Finish. You might need to click
Finish a second time if you see any errors. If you are not
able to finish the wizard, just click Cancel and most of the
necessary files will be created anyway.
[ Top of Page | Previous Page | Next Page | Table of Contents ]
Copyright IBM Corporation 1992, 2003. All Rights Reserved.