Sun ONE logo     
Web Services Coffee Break Sample Application



Web Services Coffee Break Sample Application


This document describes how to utilize the Webservices Coffee Break sample application in conjunction with Sun ONE Application Server version 7.

This sample application document contains the following sections:



Overview

The Coffee Break application facilitates the sale of coffee on the Internet. Customers communicate with the Coffee Break server to order coffee online. The server consists of Java Servlets, JSP pages, and JavaBean components. A customer enters the quantity of each coffee to order and clicks the "Submit" button to send the order.

The Coffee Break application does not maintain any inventory. It is designed to handle customer and order management and billing functions. Each order is filled by forwarding suborders to one or more coffee distributors. This process is depicted in Figure 1.



Figure 1   Coffee Break Application Flow

The Coffee Break server obtains the various coffees it sells and their associated prices by querying distributors at startup and on demand.

  1. The Coffee Break server uses JAXM messaging to communicate with one of its distributors. It has been dealing with this distributor for some time and has previously made the necessary arrangements for performing request-response JAXM messaging.

    The two parties have agreed to exchange four kinds of XML messages and have set up the DTDs that these messages will follow.

  2. The Coffee Break server uses JAXR to send a query searching for coffee distributors that support JAX-RPC to the Registry Server.

  3. The Coffee Break server requests price lists from each of the coffee distributors. The server makes the appropriate remote procedure calls and waits for the response, which is a JavaBean component representing a price list. The JAXM distributor returns the price lists as XML documents.

  4. Upon receiving the responses, the Coffee Break server processes the price lists from the JavaBean components returned by calls to the distributors.

  5. The Coffee Break Server creates a local database of distributors.

  6. When an order is placed, suborders are sent to one or more distributors using the distributor's preferred protocol.


Setting up the environment

The source code for the Coffee Break application is located in the directory <AS_HOME>/samples/webservices/cb. Within the cb directory are subdirectories for each Web application-: jaxm, jaxrpc, and server. It also contains a directory, common, for classes shared by the Web applications. Each subdirectory contains a build.xml file, and some contain the build.properties also. The Web application subdirectories in turn contain an src subdirectory for Java classes, a web subdirectory for Web resources and the Web application deployment descriptor.


Setting the Configuration

Set the following information before you build and deploy the application.

  1. In a terminal window, do the following:

    vi <AS_HOME>/samples/webservices/cb/jaxm/src/com/sun/cb/JAXMService.properties

  2. Change the host and port to appropriate values for the following entries:

    pricelist.url=http://localhost:1024/jaxm-coffee-supplier/getPriceList order.url=http://localhost:1024/jaxm-coffee-supplier/orderCoffee

  3. In a terminal window, do the following:

    vi

    <AS_HOME>/samples/webservices/cb/jaxrpc/src/com/sun/cb/CoffeeRegistry.properties.

  4. Change the host, port and the registry auth info to appropriate values for the following entries:

    endpoint=http://localhost:1024/jaxrpc-coffee-supplier/jaxrpc

    query.url=http://uddi.ibm.com/testregistry/inquiryapi

    publish.url=https://uddi.ibm.com/testregistry/protect/publishapi

    registry.username=

    registry.password=

    Leave the rest of the entries unchanged.

  5. In a terminal window, do the following:

    vi

    <AS_HOME>/samples/webservices/cb/jaxrpc/build.properties

  6. Change the host and port to appropriate values, for the following entries

  7. In a terminal window, do the following:

    vi

    <AS_HOME>/samples/webservices/cb/build.properties

  8. Change the instance,host, port and the admin server auth info to appropriate values, for the following entries

    admin.user=admin

    admin.host=localhost

    admin.port=4848

    as.instance=server1



Compiling and Assembling the Application

This section contains instructions to build and assemble the Coffee Break sample application:

Note Please refer to the section for setup above, before following this section

Building the Common Classes

To build the common classes, do the following:

  1. In a terminal window, go to <AS_HOME>/samples/webservices/cb/common.

  2. Run asant core.


Building and Deploying the JAX-RPC Service

To build the JAX-RPC service and client library, and install the service, do the following:

  1. In a terminal window, go to <AS_HOME>/samples/webservices/cb/jaxrpc.

  2. Run asant core.

    This task generates the JAX-RPC ties and stubs, creates the JAXR and client libraries, compiles the server classes, and copies them into the correct location for installation.

  3. If they are not already running, start the Sun ONE Application Server and registry server.

  4. Run asant set-up-service.

    This task deploys the JAX-RPC service into App Server and registers the service with the Registry Server. The registration process can take some time, so wait until you see the following output before proceeding to the next step:

    run-jaxr-publish:

    [echo] Running OrgPublisher.

    [echo] Note: Remember to start the registry server before running this program.

    [java] Created connection to registry

    [java] Got registry service, query manager, and life cycle manager

    [java] Established security credentials

    [java] Organization saved

    [java] Organization key is edeed14d-5eed-eed1-31c2- aa789a472fe0

  5. You can test that the JAX-RPC service has been installed correctly by running one or both of the following test programs:

    execute asant run-test-price

    or

    asant run-test-order.

    Here is what you should see when you run asant run-test-price:

    run-test-price:

    run-test-client:

    [java] 05/21/02 06/20/02

    [java] Kona 6.50

    [java] French Roast 5.00

    [java] Wake Up Call 5.50

    [java] Mocca 4.00

Later on, you may remove the JAX-RPC service by running asant take-down-service. This command deletes the service from the Registry Server and then uninstalls the service from App Server. Do not remove the service at this time.


Building and Deploying the JAXM Service

To build the JAXM service and client library and install the service, do the following:

  1. In a terminal window, go to <AS_HOME>/samples/webservices/cb/jaxm.

  2. Run asant package.

    This task creates the client library and compiles the server classes and copies them into the correct location for installation.

  3. Make sure the Sun ONE Application Server is started.

  4. Run asant deploy.

    This task installs the JAXM service into App Server.

  5. You can test that the JAXM service has been installed correctly by running one or both of the following test programs:

    execute asant run-test-price

    or

    asant run-test-order.

Building and Deploying the Coffee Break Server

To build and deploy the Coffee Break server:

  1. In a terminal window, go to <AS_HOME>/samples/webservices/cb/server.

  2. Run asant package.

    This task compiles the server classes and copies the classes, JSP pages, client libraries, and tag libraries into
    the correct location for Deployment. Note that the Coffee Break server depends on the client
    libraries generated by the JAX-RPC (jaxrpc-client.jar) and JAXM (jaxm-client.jar) build process.

  3. Make sure the Sun ONE Application Server is started.

  4. Run asant deploy.

    This task deploys the cbserver app into App Server.


Running the Sample Application


Note You may need to add <AS_HOME>/share/lib/xercesImpl.jar to the application server classpath suffix, using the application server administration tool, and restart the application server.



To run the Coffee Break client, do the following:

After you have installed all the Web applications, check that all the applications are running, from the Sun ONE Application Server Administation Tool.

Next, run the Coffee Break client by doing the following:

  1. Open the Coffee Break server URL in a Web browser:

    http://localhost:1024/cbserver/orderForm

  2. You should see a page something like the one shown in Figure 2.



Figure 2   Order Form

  1. After you have completed the application screens, you will receive an order confirmation that looks similar to the the one shown in Figure 3.



Figure 3   Order Confirmation



Troubleshooting



  • If you encounter problems when running the application, review the log files at <install-root>/domains/<domain-name>/<server-instance>/logs/server.log to learn what exactly went wrong.

  • If you encounter errors while deploying the application, make sure that your admin password is set correctly in <AS_HOME>/samples/webservices/cb/build.properties.

  • If you encounter errors while running the URL http://localhost/cbserver/orderForm, also verify the URL http://localhost/cbserver/loadPriceList, this gives the exact location where the application fails.

  • If none of the above works for you, please verify<AS_HOME>/samples/webservices/cb/jaxm/src/com/sun/cb/JAXMService.properties <AS_HOME>/samples/webservices/cb/jaxrpc/src/com/sun/cb/CoffeeRegistry.properties <AS_HOME>/samples/webservices/cb/jaxrpc/build.properties
Some Known Issues

  • The Coffee Break Server component can not be deployed from the application server administration GUI, if Precompile JSPs option is selected. Solution is, try deploying the application without Precompile JSPs, or deploy using asant.

  • The Coffee Break Server component can not be deployed using asadmin with option --precompilejsp=true. Solution is, try deploying the application without the option --precompilejsp=true, or deploy using asant.


Copyright © 2002 Sun Microsystems, Inc. All rights reserved.

Last Updated July 23, 2002