|
FAQ
History |
|
Search
Feedback |
Deploying and Running the Application
The source code for the Coffee Break application is located in the directory
<INSTALL>/j2eetutorial/examples/cb. Within thecbdirectory are subdirectories for each Web application--jaxm,jaxrpc,cbservice.Add Web services JARs to the compilation classpath. To do so:
- Choose Options from the Tools menu.
- Expand the Building node, then the Compiler Types node.
- Choose External Compilation.
- Select the Expert tab.
- Click the Class Path property and open the property editor.
- Click Add JAR/Zip.
- In the file chooser, navigate to the
<S1AS7_HOME>/share/libdirectory and choose thejaxr-api.jarandsaaj-api.jarfiles.- Click OK.
- Click OK in the property editor, then click Close in the Options window.
The JARs are also located in the
<S1STUDIO_HOME>/jwsdp/common/libdirectory, so you may specify that location for the classpath if you prefer.Building, Deploying, and Registering the JAX-RPC Service
This section contains step-by-step instructions for the following tasks:
Creating the JAX-RPC Service
The
beanspackage contains JavaBeans components that represent business information, such asAddressBean. In the JAX-RPC service's methods, these beans are parameters or return types.The
registrypackage holds the JAXR programs that publish the service in (and remove it from) the registry.The
servicepackage containsDateHelper, a utility class;PriceLoader, which loads coffee prices into a list; andSupplier, which implements the service's remote procedures.If the "Collection of What?" window appears, click Cancel. In Sun ONE Studio 4 update 1, a bug prevents this operation from working correctly.
In the Explorer, the IDE displays a Web service node (a cube containing a sphere) for the
SupplierService.Specifying the Serializers
The JAX-RPC runtime system uses serializers when converting Java objects into XML data types. The runtime system needs a serializer for every parameter and return type of the service's methods. The IDE generates the serializers automatically when you perform the Generate Web Service task, as in the next section. The IDE identifies the serializers it needs to generate by examining the classes of the parameters and return types. However, if such a class contains a collection, the IDE cannot automatically identify the type of the collection's members. In this case, you must specify the collection's member type so that the IDE can generate a serializer for the member.
In this example, the
getPriceListmethod returns aPriceListBean, a collection made up ofPriceItemBeancomponents. TheplaceOrdermethodpasses anOrderBeanparameter, which contains a collection ofLineItemBeancomponents. To specify serializers forLineItemBeanandPriceItemBean, perform these steps:
- Right-click the Web service node for
SupplierService(a cube containing a sphere) and choose Properties.- In the properties sheet, choose Serialization Classes and open the properties editor.
- In the properties editor, add the
beans.LineItemBeanandbeans.PriceItemBeanclasses.- Click OK to close the properties editor.
- Close the properties sheet.
Generating the Service's WSDL File, Serializers, and other Helper Classes
To generate these files and classes, right-click the Web service node for
SupplierServiceand choose Generate Web Service. The IDE creates the following:Deploying the JAX-RPC Service
Right-click the Web service node for
SupplierService(a cube containing a sphere) and choose Deploy.Testing the JAX-RPC Service
To test the service, you create a Web service client and run the
TestOrderCallerandTestPriceFetcherprograms. Contained in thetestpackage, these programs are static stub clients. (For more information, see the section Static Stub Client Example.)
Note: The test programs assume that you have deployed
SupplierServiceonlocalhost. If you are running the service on a different host, you need to update the service URLs.
- Right-click the
clientutilpackage and choose FileNew
Web Services
Web Service Client.
- In the wizard's Specify Web Service Client pane, do the following:
- In the wizard's Select Local WSDL File pane, expand the
servicepackage and choose theSupplierServiceWSDL node (a rectangle with a sphere in the lower-left corner)- Click Finish.
- Right-click the
Orderclient node and choose Generate Client Proxy.This action creates the
OrderGenClientpackage, which contains the stub class, serializer classes, and other helper classes required by the client at runtime.
- In the
testpackage, executeTestOrderCaller. The output window should display:
orderId = 123
shippingDate =mm/dd/yy (tomorrow's date)- . Execute
TestPriceFetcher. The output window should display:
mm/dd/yy (today's date) mm/dd/yy (60 days from today)Mocca 4.00
Wake Up Call 5.50
French Roast 5.00
Kona 6.50Registering the JAX-RPC Service
Later on, you can remove the JAX-RPC service from the registry by executing
OrgRemover.Deploying the JAXM Service
To build and deploy the JAXM service:
Testing the JAXM Service
To test the JAXM service, you run the test programs
TestPriceListRequestorTestOrderRequestin the<INSTALL>/j2eetutorial/examples/cb/jaxm/testdirectory.
Note: The test programs assume that you have deployed the JAXM service on
localhost. If you are running the service on a different host, you need to update the service URLs.
To run the test programs in the IDE:
Deploying the Coffee Break Server
Server Configuration
The Coffee Break Server accesses three services--registry, JAX-RPC service, JAXM service--to build retail price lists and order coffee. The information needed to access the services is stored in the file
<INSTALL>/examples/cb/cbservice/CoffeeServices.properties. This file contains URLs and security parameters for accessing the registry, the name under which the JAX-RPC service is registered, and the URLs for making requests on the JAXM service.registryQuery.url=http://localhost:8089/registry- server/RegistryServerServlet registryPublish.url=http://localhost:8089/registry- server/RegistryServerServlet registry.username=testuser registry.password=testuser JAXRPCService.name=JAXRPCCoffeeDistributor JAXMPricelist.url=http://localhost:80/jaxm-coffee- supplier/getPriceList JAXMOrder.url=http://localhost:80/jaxm-coffee- supplier/orderCoffee
Note: The default configuration assumes that you are running the registry server and JAXM service on localhost. If you are running either service on a different host, you need to update the service URLs.
Importing the JAX-RPC Client
The Coffee Break server imports the JAX-RPC client classes in the package
clientutil. To make the classes available for compilation and deployment:
- Make sure the filesystem
<INSTALL>/j2eetutorial/examples/cb/jaxrpcis mounted. This is required so that the IDE includes theclientutilsubdirectory ofjaxrpcin the classpath during compilation.- In the IDE, mount the filesystem
<INSTALL>/j2eetutorial/examples/cb/cbservice.- Expand the
cbservicenode.- Add the
clientutilsubdirectory ofjaxrpcto the Web module as an extra file. When the IDE packages thecbserviceWeb module it will include theclientutildirectory. To add the directory as an extra file:
- Right-click the
WEB-INFdirectory.- Select the Archive property sheet.
- Click the Extra Files property and open the property editor.
- In the Chosen Content pane, select the
WEB-INF/classesDirectory Prefix from the drop-down list.- In the Source pane, expand the
<INSTALL>/j2eetutorial/examples/cb/jaxrpcnode.- Select the
clientutilnode.- Click Add.
- Click OK.
- Right-click the
WEB-INFnode and choose View WAR Content to check that theclientutilpackage was added.Deploying the Coffee Break Server.
To deploy the Coffee Break server, right-click the
WEB-INFdirectory of<INSTALL>/j2eetutorial/examples/cb/cbserviceand choose Deploy.Running the Coffee Break Client
After you have deployed all the Web applications, check that all the applications--
SupplierService,jaxm-coffee-supplier,cbservice--are running by viewing the deployed Web applications with the IDE or the application server administration tool.You may need to add
<S1AS7_HOME>/share/lib/xercesImpl.jarto the application server classpath suffix and restart the application server using the application server administration tool. To do so:To run the Coffee Break client, open the Coffee Break server URL in a Web browser:
You should see a page something like the one shown in Figure 12-2.
![]()
After you have gone through the application screens, you will get an order confirmation that looks like the one shown in Figure 12-3.
![]()
|
FAQ
History |
|
Search
Feedback |
All of the material in The J2EE Tutorial for the Sun ONE Platform is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.