The JavaTM Web Services Tutorial
Home
TOC
Index
PREV TOP NEXT
Divider

Setting Up


Note: Before you start developing the example applications, follow the instructions in About This Tutorial, then continue with this section.

Getting the Example Code

The source code for the example is in <JWSDP_HOME>/docs/tutorial/examples/gs/, a directory that is created when you unzip the tutorial bundle. If you are viewing this tutorial online, you can download the tutorial bundle from:

http://java.sun.com/webservices/downloads/webservicestutorial.html
 

Layout of the Example Code

In this example application, the source code directories are organized according to the "best practices approach to Web services programming", which is described in more detail in the file <JWSDP_HOME>/docs/tomcat/appdev/deployment.html. Basically, the document explains that it is useful to examine the runtime organization of a Web application when creating the application. A Web application is defined as a hierarchy of directories and files in a standard layout. Such a hierarchy can be accessed in its unpacked form, where each directory and file exists in the file system separately, or in a packed form known as a Web Application Archive, or WAR file. The former format is more useful during development, while the latter is used when you distribute your application to be installed.

To facilitate creation of a WAR file in the required format, it is convenient to arrange the files that Tomcat uses when executing your application in the same organization as required by the WAR format itself. In the example application at <JWSDP_HOME>/docs/tutorial/examples/gs/, which is the root directory for the source code for this application. The application consists of the following files that are either in the /gs directory or a subdirectory of /gs.

More information about WAR files can be found in Web Application Archives.

A key recommendation of the Tomcat Application Developer's Manual is to separate the directory hierarchy containing the source code from the directory hierarchy containing the deployable application. Maintaining this separation has the following advantages:

As discussed in Creating the Build and Deploy File for Ant, the Ant development tool makes the creation and processing of this type of directory hierarchies relatively simple.

The rest of this document shows how this example application is created, built, deployed, and run. If you would like to skip the information on creating the example application, you can go directly to Quick Overview.

Setting the PATH Variable

It is very important that you add the bin directories of the Java WSDP and J2SE SDK installations to the front of your PATH environment variable so that the Java WSDP startup scripts for Tomcat, Ant, and deploytool override other installations.


Note: Most of the examples are distributed with a configuration file for version 1.4.1 of Ant, a portable build tool contained in the Java WSDP. If your PATH variable does not point to the bin directory of the Java WSDP, many of the Ant commands will not work because the version of Ant shipped with the Java WSDP sets the jwsdp.home environment variable.

Creating the Build Properties File

In order to invoke many of the Ant tasks, you need to put a file named build.properties in your home directory. On the Solaris operating system, your home directory is generally of the format /home/your_login_name. In the Windows operating environment (for example on Windows 2000), your home directory is generally C:\Documents and Settings\yourProfile.

The build.properties file contains a user name and password in plain text format that match the user name and password set up during installation. The user name and password that you entered during installation of the Java WSDP are stored in <JWSDP_HOME>/conf/tomcat-users.xml.

For security purposes, the Tomcat Manager application verifies that you (as defined in the build.properties file) are a user who is authorized to install and reload applications (as defined in tomcat-users.xml) before granting you access to the server.

If you have not already created a build.properties file in your home directory, do so now. The file will look like this:

username=your_username
password=your_password
 

Note: For security purposes, make the build.properties file unreadable to anyone but yourself.

The tomcat-users.xml file, which is created by the installer, looks like this:

<?xml version='1.0'?>
<tomcat-users>
<role rolename="admin"/>
<role rolename="manager"/>
<role rolename="provider"/>
<user username="your_username" password="your_password"
     roles="admin,manager,provider"/>
</tomcat-users>
 
Divider
Home
TOC
Index
PREV TOP NEXT
Divider

This tutorial contains information on the 1.0 version of the Java Web Services Developer Pack.

All of the material in The Java Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.