Java Web Services Tutorial Quick Guide |
Cognitude - Partners In Professional Education |
|
This page is a quick guide to get Java Web Services Developer Pack with tutorial installed and running.
The information is very limited and only contains support to get one example
(Hello World with JAX-RPC) running,
using JWSDP 1.0_01 and
Java Web Services Tutorial 1.0_01.
These instructions also assume you are using Microsoft's Windows.
|
|
To run the JAX-RPC example you need installations of J2SE SDK, Java Web Services Developer Pack and the
Java Web Services tutorial. If any of these are not installed on your computer download and install:
|
|
Note that JWSDP/Tutorial contains "wrapped" installations of ANT and Tomcat.
Check the
tutorial
on Sun's site for details on installation.
|
|
|
The Tutorail ANT scripts rely on the following environment variables:
|
JAVA_HOME
|
Path to root of your J2SE SDK installation
|
JWSDP_HOME
|
Path to root of your JWSDP installation
|
|
In order for the ANT scripts in the tutorial to run correctly, the JWSDP instance of ANT must be used. Also
the executables of the specific J2SE SDK must be the ones activated when you are building/running the tutorial.
Therefore JWSDP_HOME, JAVA_HOME must be in your path. In order not to disturb programs on your computer depending
on e.g. other installations of Tomcat and ANT than the ones included in JWSDP it is suggested that you execute
the following command in a separate command window that you will use while working with the tutorial:
|
set Path=%JWSDP_HOME%\bin;%JAVA_HOME%\bin;
|
To deploy web services on Tomcat using ANT scripts you need a file, "build.properies" in your home directory
(e.g. C:\Documents and Settings\your_login_name on Windows).
You can find your password and username in JWSDP_HOME\conf\tomcat-users.xml
|
C:\Documents and Settings\your_login_name\build.properties :
|
username=your_username
password=your_password
|
Check the
tutorial
on Sun's site for details on configuration. |
|
|
Running the tools of the JWSDP (such as wsdeploy and wscompile ) by calling
them directly in a command shell is a quite cumbersome task as the parameter lists for those calls would be
of considerable length.
Therefore, the tutorial comes with a massive set of ANT targets that can be used to build and deploy
the examples. There are also two paths through the ANT targets when building a Web Service Client/Server application.
One path that has the a minimum number of targets and one path that consists of more targets where each
target does less. The latter path is more flexible when rebuilding only parts of the application and also gives
the user more understanding of what goes on "under the hood".
Both paths, for the JAX-RPC hello world example, are described below.
|
The ANT targets below should be executed in the JWSDP_HOME\docs\tutorial\examples\jaxrpc\hello
directory.
|
build
|
Creates a deployable WAR file containing the server side of the Web Service
|
deploy/redeploy
|
Deploy/redeploy the Web Service on Tomcat. Click
here
to check service deployment.
|
build-static
|
Creates the JAR file of the client (using the static stubs).
|
run
|
Run the client that will call the Web Service running on Tomcat.
|
|
compile-server
|
Compiles the "service definition", i.e. the service interface (HelloIF.java ) and its implementation
(HelloImpl.java ). The result is placed in the build subdirectory.
|
setup-web-inf
|
Creates the structure that is needed for running the web service as a web application, i.e. copies files
to the build\WEB-INF subdirectory.
|
package
|
Creates a (deployment environment independable) war file: dist\hello-portable.war .
|
process-war
|
Generates tie classes and WSDL file, using jaxrpc-ri.xml , and merges this with the
hello-portable.war file.
Generates the war file (dist\hello-jaxrpc.war ) for the specific (JAX-RPC) deployment type.
|
deploy/redeploy
|
Deploys the Web Service contained in dist\hello-jaxrpc.war on Tomcat.
Click
here
to check service deployment.
|
generate-stubs
|
Generates stubs (proxy) to be used by the client. This is done using the
WSDL file of the deployed
service (pointed out by the config.xml file). The output appears in the
build\client subdirectory.
|
compile-client
|
Compiles the client (HelloClient.java ). The output (one class file) appears in the
build\client subdirectory.
|
jar-client
|
Packs the client files into a jar file: dist\hello-client.jar
|
run
|
Calls main of hello.HelloClient in dist\hello-client.jar .
The client should now connect to the server resulting in Hello Duke! being displayed
in the command window.
|
|
Check the
tutorial
on Sun's site for details on building and running the tutorial. |