Using Java (Axis2) wrapper classes

Tutorial: Generate a Java wrapper for the "Employees" file

Java wrapper/stub classes are generated using the Apache Axis2 feature WSDL2Java.

If you do not have it already, download and install the latest Axis2 kit.

These are the steps required to generate the Java wrapper classes for the "adabas_EmployeesMini" DataView supplied with SOA Gateway:

  1. Create a new Java-project (refer to Getting started with Eclipse), name it "JavaEmployees"

  2. Right-click the "JavaEmployees" project folder, select "Build Path", then "Add External Archives..:"

    graphics/jaxis010.png

    Add all .jar files from the axis2 "lib" directory to the project's Build-Path.

    graphics/jaxis020.png

  3. Open a command prompt (aka "DOS box"), change to the "JavaEmployees\src" directory and run the following command

    wsdl2java -uri http://<yourserver>:<yourport>/adabas_EmployeesMini?WSDL -o ..\ -p SoaG

    graphics/jaxis030.png

    The following items are generated from a SOA Gateway WSDL:

    • A "Stub" class implementing all types and operations ( ports / bindings )

    • A CallbackHandler - a stub class (not used in this tutorial) providing hooks for client-side extensions to the generated result- and error handlers.

    • A Fault class

    graphics/jaxis040.png

  4. Add a new Java class named "Tut_02_List" to the project ( File -> New -> Class ), opt to create a "main" method, click "Finish".

    graphics/jaxis050.png

  5. Remove the generated code from the newly added class entirely, use (paste) the code from Tut_02_List.java to create your first test program accessing ADABAS data via SOA Gateway.

  6. Run the program as a "Java Application"

    graphics/jaxis060.png

  7. The output appears in the "Console" window:

    graphics/jaxis070.png

  8. This sample selects all "Employees" records with a personnel-id of 50005nnn, you may want to experiment varying the key data, this is easily done by modifying the properties passed to the generated classes. E.g. try the following to list all records for "Employees" whose names start "SMI", living in cities with names starting "D".

    keys.setPersonnel_id("");

    keys.setName("SMI*");

    keys.setCity("D*");

The following Java/Axis2 tutorial programs are available:

Tutorial What it does
Tut_01a_Get.java GET a single record by Personnel Id
Tut_01b_GetByISN.java GET a single record by ISN
Tut_02_List.java LIST some records
Tut_03a_SelectSimple.java SELECT by a range of Personnel IDs
Tut_03b_SelectSorted.java SELECT by a range of Personnel IDs and sort by Name
Tut_03c_SelectConversational.java SELECT by multiple ranges of Personnel IDs, returned in "chunks" of 20 records each
Tut_04a_AddUpdateDelete.java ADD + UPDATE + DELETE in "autocommit" mode
Tut_04b_AddTransactional.java ADD in a transactional context