Beehive AddressBookWS and EnhancedAddressBookWS Samples
The Samples
The AddressBookWS sample is an annotation-aware web service based on the Apache Axis sample of the same name. AddressBookWS is organized as an application with POJO (Plain Old Java Objects) models, service interface, service implementation, and unit tests for the service. Apache Axis provides automatic client-generation and junit test cases for the sample. The directory structure and Ant build file can be used as a template for building new standalone web services.
The EnhancedAddressBookWS sample is a more comprehensive version of the AddressBookWS sample: it uses more metadata annotations, has customized annotations properties, and shows exception handling.
Apache Axis provides the automatic client-generation for the web services. Custom unit tests are provided to exercise the webservice methods. The unit tests create the database tables, insert new records, query the database, and finally drop the tables. Use the junit tests as a template for building automatic tests for your own web services
Running the Samples
Requirements for Running the Samples
To run the Samples, you need:
- Beehive
- Tomcat 5
- J2SE 5
- Ant 1.6.2
- junit.jar (v3.8.1 or later, details below)
To Set up the Environment
Before proceeding, complete all of the necessary and optional steps in the following topic: Beehive Installation and Setup
Open a command shell and confirm that the following variables have been set:
- ANT_HOME
- BEEHIVE_HOME
- CATALINA_HOME
- JAVA_HOME
Also ensure that the following elements are on your PATH:
- ANT_HOME/bin
- JAVA_HOME/bin
To Set up the Server
To Start Tomcat
To start Tomcat, run the following command:
%CATALINA_HOME%\bin\startup.bat
To Download Junit the JAR File
Download the junit ZIP archive from http://prdownloads.sourceforge.net/junit/junit3.8.1.zip?download
Unzip the archive, locate junit.jar, and copy junit.jar to ANT_HOME/lib.
Edit the build.properties Files
In this section you will edit the build.properties files--the files that set the build-related properties for the web services.
Open the files BEEHIVE_HOME/samples/wsm-addressbook/WEB-INF/src/build.properties and BEEHIVE_HOME/samples/wsm-addressbook-enhanced/WEB-INF/src/build.properties in a text editor.
Edit the files so that the beehive.home property points to the top-level folder of your beehive installation. For example, if you beehive installation resides at C:/apache/apache-beehive-1.0, then your build.properties files would appear as follows.
beehive.home=C:/apache/apache-beehive-1.0
To Compile the Apps
To compile the AddressBookWS app, enter the following Ant command.
ant -f %BEEHIVE_HOME%\samples\wsm-addressbook\WEB-INF\build.xml -Dto.dir=%CATALINA_HOME%\webapps clean build deploy Copy and paste version: ant -f %BEEHIVE_HOME%\samples\wsm-addressbook\WEB-INF\build.xml -Dto.dir=%CATALINA_HOME%\webapps clean build deploy
To compile the EnhancedAddressBookWS app, enter the following Ant command.
ant -f %BEEHIVE_HOME%\samples\wsm-addressbook-enhanced\WEB-INF\build.xml -Dto.dir=%CATALINA_HOME%\webapps clean build deploy Copy and paste version: ant -f %BEEHIVE_HOME%\samples\wsm-addressbook-enhanced\WEB-INF\build.xml -Dto.dir=%CATALINA_HOME%\webapps clean build deploy
To Verify the Deployments
Verify that the web services is running by pointing your browser to:
http://localhost:8080/AddressBookWS/
and
http://localhost:8080/EnhancedAddressBookWS/
Follow the validation WSDL links for each web service.
To Run the Web Service Clients
To generate and run the client, run the following build files.
ant -f %BEEHIVE_HOME%\samples\wsm-addressbook\WEB-INF\build-client.xml
ant -f %BEEHIVE_HOME%\samples\wsm-addressbook-enhanced\WEB-INF\build-client.xml
Note that you do not need to run a particular target within the build files client-build.xml. Simply run the Ant command shown above and the clients will be generated in WEB-INF/build/generated.
The clients consist of JUnit test cases that exercise the contract published in the WSDL. The final result shows the number of successfully passed JUnit tests.
The code generated in /WEB-INF/build/generated/ can be used as a template to write your own client side applications.
Note that the client-build.xml script makes certain assumptions about the Tomcat deployment context path, namely, that the apps are deployed on the context paths AddressBookWS and EnhancedAddressBookWS . If the context paths differ from these values, the URL in the build-client.xml files must be adjusted accordingly.