The JavaTM Web Services Tutorial
Home
TOC
Index
PREV TOP NEXT
Divider

Creating a JAX-RPC Service With deploytool

In the examples of the preceding sections, you executed Ant tasks to build and install services. In this section, however, you'll create a service with deploytool instead of Ant. The deploytool utility automatically performs these tasks:

The client in this example is a dynamic proxy, similar to the one described in A Dynamic Proxy Client Example. At runtime, the client accesses the WSDL document that's installed by deploytool. The source code for this HelloClient program is in the <JWSDP_HOME>/docs/tutorial/examples/jaxrpc/dephello directory.

Before trying out the example in this section, you should be familiar with the basic operations of deploytool. For a quick introduction, see Deploying the Application Using deploytool.

Compiling the Source Code

  1. If you haven't already done so, follow the instructions in Setting Up.
  2. In a terminal window, go to the <JWSDP_HOME>/docs/tutorial/examples/jaxrpc/dephello directory.
  3. Type the following:
    ant build
    The build target performs these tasks:
    • Compiles the service interface and implementation class
    • Compiles the client
    • Packages the client into the dist/dephello-client.jar file

Building the Web Application

In this section, you will package the service into a WAR file by running the New Web Application wizard of deploytool. After you start the wizard (File->New Web Application), the following dialogs appear:

  1. Introduction
    1. Read this dialog to learn more about the wizard.
    2. Click Next.
  2. WAR File dialog
    1. In the Module File Name field, enter MyHello.war.
    2. In the War Display Name field, enter MyHelloWAR.
    3. Click Edit.
  3. Edit Contents dialog
    1. Navigate to the following directory, which contains the service interface and implementation class.
          <JWSDP_HOME>/docs/tutorial/examples/jaxrpc/dephello/
            build/shared
       
      
    2. Add HelloIF.class and HelloImpl.class to the field labelled Contents of MyHelloWAR.
    3. Click OK.
    4. Click Next.
  4. Choose Component Type dialog
    1. Select the JAX-RPC Endpoint radio button.
    2. Click Next.
  5. JAX-RPC Default Settings dialog
    1. In the WSDL Target Namespace Base String field, enter the following:
          http://wombat.com/wsdl/
       
      
    2. In the Schema Target Namespace Base String field, enter the following:
          http://wombat.com/xsd/
       
      
    3. In the Endpoint Alias Base String field, enter /jaxrpc.
    4. Click Next.
  6. JAX-RPC Endpoint dialog
    1. In the EndPoint Interface combo box, select dephello.HelloIF.
    2. In the EndPoint Class combo box, select dephello.HelloImpl.
    3. In the Endpoint Name field, enter MyHelloWorld.
    4. In the Endpoint Display Name field, enter MyHelloWorld.
    5. Leave the Alias field blank.
    6. Click Next.
  7. JAX-RPC Model dialog
    1. Select the Use Default Settings radio button.
    2. Click Next.
  8. Review Settings dialog
    1. Take a quick look at the two XML files displayed by this dialog. The file shown at the top of the dialog is the web.xml file that will be packaged in the WAR file. The file displayed at the bottom is the jaxrpc-ri.xml file, also to be packaged in the WAR file. The jaxrpc-ri.xml file is implementation-specific and is not defined by the specifications.
    2. Click Finish.

The deploytool utility now creates the MyHello.war file.

Deploying the Web Application

  1. From the main menu of deploytool, select Tools->Deploy.
  2. In the Text Input dialog, enter /jaxrpc-dephello for the Web context.
  3. The Deployment Console dialog appears and displays this line:
      OK - Installed application at context path /jaxrpc-dephello
     
    
  4. Click Close.

Checking the Status of the Web Service

In a browser, go to the following URL:

http://localhost:8080/jaxrpc-dephello/jaxrpc/MyHelloWorld
 

The browser displays a page showing the status of the MyHelloWorld port (or endpoint) name. This page also shows the URL for the WSDL document:

http://localhost:8080/jaxrpc-dephello/jaxrpc/MyHelloWorld?WSDL
 

This is the URL that the HelloClient program will use to locate the WSDL document that was created during deployment.


Note: If you have problems deploying the Web service, you may find it helpful to compare your MyHello.war file with the CompareMyHello.war file of the dephello/provided-jars subdirectory.

Running the Client

  1. In a terminal window, go to the directory named <JWSDP_HOME>/docs/tutorial/examples/jaxrpc/dephello.
  2. Type the following command:
      ant run
     
    

The client should display the following line:

  A dynamic proxy hello to Murphy!
 
Divider
Home
TOC
Index
PREV TOP NEXT
Divider

This tutorial contains information on the 1.0 version of the Java Web Services Developer Pack.

All of the material in The Java Web Services Tutorial is copyright-protected and may not be published in other works without express written permission from Sun Microsystems.