![]() |
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
- Compiling, Assembling and Deploying the Application Running the Sample Application
- Troubleshooting
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.
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 Coffee Break server uses JAXR to send a query searching for coffee distributors that support JAX-RPC to the Registry Server.
- The two parties have agreed to exchange four kinds of XML messages and have set up the DTDs that these messages will follow.
- 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.
- Upon receiving the responses, the Coffee Break server processes the price lists from the JavaBean components returned by calls to the distributors.
- The Coffee Break Server creates a local database of distributors.
- 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.
In a terminal window, do the following:
Change the host and port to appropriate values for the following entries:
In a terminal window, do the following:
- pricelist.url=http://localhost:1024/jaxm-coffee-supplier/getPriceList order.url=http://localhost:1024/jaxm-coffee-supplier/orderCoffee
Change the host, port and the registry auth info to appropriate values for the following entries:
In a terminal window, do the following:
- 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.
Change the host and port to appropriate values, for the following entries
- In a terminal window, do the following:
Change the instance,host, port and the admin server auth info to appropriate values, for the following entries
Compiling and Assembling the Application
This section contains instructions to build and assemble the Coffee Break sample application:
Building the Common Classes
Note Please refer to the section for setup above, before following this section- Building and Deploying the JAX-RPC Service
- Building and Deploying the JAXM Service
- Building and Deploying the Coffee Break Server
Building the Common Classes
To build the common classes, do the following:
Building and Deploying the JAX-RPC Service
To build the JAX-RPC service and client library, and install the service, do the following:
In a terminal window, go to <AS_HOME>/samples/webservices/cb/jaxrpc.
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.- Run asant core.
If they are not already running, start the Sun ONE Application Server and registry server.
- 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.
- Run asant set-up-service.
You can test that the JAX-RPC service has been installed correctly by running one or both of the following test programs:
- 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
Building and Deploying the JAXM Service
To build the JAXM service and client library and install the service, do the following:
In a terminal window, go to <AS_HOME>/samples/webservices/cb/jaxm.
- Run asant package.
Make sure the Sun ONE Application Server is started.
- This task creates the client library and compiles the server classes and copies them into the correct location for installation.
- Run asant deploy.
You can test that the JAXM service has been installed correctly by running one or both of the following test programs:
Building and Deploying the Coffee Break Server
To build and deploy the Coffee Break server:
In a terminal window, go to <AS_HOME>/samples/webservices/cb/server.
- Run asant package.
Make sure the Sun ONE Application Server is started.
- 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.- Run asant deploy.
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:
Open the Coffee Break server URL in a Web browser:
You should see a page something like the one shown in Figure 2.
![]()
Figure 2 Order Form 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 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.
Some Known Issues- 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
- 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