SOAP Shopping Cart Sample
iPlanetTM Application Server Samples

Updated June 13, 2001

If you already went through the deployment process for the SOAP shopping cart  on this machine, you can run the application by clicking here.

The shopping cart sample is a simple application based on SOAP, EJBs, servlets and JSPs. Assembling this application and deploying it to iPlanet Application Server provides an introduction to the server's assembly, deployment and registration tools.

Application Overview

The Shopping Cart sample demonstrates how SOAP can be used to access a stateful session bean on iPlanet Application Server. The sample implements a basic shopping cart that enables you to perform very simple operations or adding and removing books to and from the cart. There are two modes for accessing the SOAP service:  one is through a servlet and the other is through a Java Swing GUI client.

There are four components of the application.

This illustrates the components described above:

Here's a summary of the interactions which occur when the application is run:

The key message of this sample is that the client maintains a reference to the CartSoapProxy which maintains a session with the CartService which, in turn, maintains a session using a Stateful Session Bean. This means that the business application client is indirectly maintaining a session using a Cart EJB.

Setting Up the Environment

Assembling and Deploying the Application

The remainder of this document describes how to assemble and deploy the SOAP Cart sample application using the command-line tools.  If you're interested in assembling and deploying the application using the application server's Deployment Tool GUI, please refer to the document Deploying Cart Sample Using Deployment Tool.

Command-line Assembly and Deployment

The Ant build facility is used to recompile and assemble the web application, GUI client, SOAP service, and EJB JAR.  For more information about this build facility and its use with the iPlanet Application Server samples, see the Sample Application Build Facility.

To recompile, reassemble, and redeploy the sample application, follow these steps:

1. Change directories to the SOAP Cart sample application:  cd install_dir/ias/ias-samples/soap/cart/src.  Edit the Ant build file for the sample, build.xml, to ensure the appropriate libraries are used when compiling and deploying the sample.  To do this, ensure the following properties are set correctly at the top of the script:

2. Compile and assemble the web application and EJB
Execute "build" under the install_dir/ias/ias-samples/soap/cart/src directory

The default target, core, will be executed.  It will recompile all of the Java classes, build the EJB stubs and skeletons, assemble the soap-cart.war web archive, and assemble the soap-cartEjb.jar EJB JAR

3. Deploy the web application and EJB
Execute "build deploy" under the install_dir/ias/ias-samples/soap/cart/src/ directory

The target deploy will be executed.  It will deploy the soap-cart.war web archive as well as the soap-cartEjb.jar EJB JAR, copy the SOAP service class to install_dir/ias/APPS/soap-services/, and register the service in SOAP using the descriptor file  install_dir/ias/ias-samples/soap/cart/src/DeploymentDescriptor.xml

4. Deploy and register the SOAP Service
Execute "build install_service" under the install_dir/ias/ias-samples/soap/cart/src/ directory

The target install_service will be executed.  It will copy the SOAP service class, CartService, to the SOAP service directory (we use install_dir/ias/APPS/soap-services/ for convenience).  The service is then registered in SOAP using the descriptor file  install_dir/ias/ias-samples/soap/cart/src/DeploymentDescriptor.xml  If you prefer to deploy and register the SOAP service manually without using Ant, please refer to the documentation found here

5. Restart Application Server
The application server must restarted only if you've modified a deployment descriptor, an EJB home/remote interface, or the SOAP service. For servlet and/or SOAP client modifications, no restart is is necessary.

Running the Sample Applications

Before running the sample applications, it's necessary to add the Cart EJB classes to the application server's classpath.  This is necessary because the SOAP service, CartService, is loaded by the system classloader and it will be unable to access the EJB classes if they are not also on the system classpath.  To do this, add the install_dir/ias/APPS/modules/soap-cartEjb/ to the application classpath.  For instructions on how to modify the iPlanet Application Server classpath, refer to the Apache SOAP installation instructions.

UNIX:

Add the following path to the server's classpath:

/usr/iplanet/ias6/ias/APPS/modules/soap-cartEjb

Windows:

Add the following path to the server's classpath:

d:\iplanet\ias6\ias\APPS\modules\soap-cartEjb

Now restart the application server to pickup the classpath changes.

To test the web-based SOAP client, view the following URL in a browser:  http://<server name>/NASApp/soap-cart

For example: http://localhost/NASApp/soap-cart

To test the Java Swing GUI client, change directories to the SOAP Cart sample application (cd install_dir/ias/ias-samples/soap/cart/src) and execute "build run_gui"

Known Issues

The prebuilt EAR file that ships with the server has the Apache SOAP router parametrized to http://localhost/NASApp/soap/rpcrouter. If your router is on another server and/or port, then you will need to edit the web.xml file (located at soap/cart/src) to change the SOAP_ROUTER parameter to match your environment. Once the change is made, the sample has to be reassembled and deployed to the server.

Copyright (c) 2001 Sun Microsystems, Inc. All rights reserved.