Home
TOC Index |
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 withdeploytool
instead ofAnt
. Thedeploytool
utility automatically performs these tasks:
- Creates the
web.xml
file- Creates the WAR file
- Installs the Web application
- Installs a WSDL document for the service on Tomcat
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 thisHelloClient
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
- If you haven't already done so, follow the instructions in Setting Up.
- In a terminal window, go to the
<JWSDP_HOME>
/docs/tutorial/examples/jaxrpc/dephello
directory.- Type the following:
ant build
- The
build
target performs these tasks: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:
- Introduction
- WAR File dialog
- In the Module File Name field, enter
MyHello.war
.- In the War Display Name field, enter
MyHelloWAR
.- Click Edit.
- Edit Contents dialog
- Navigate to the following directory, which contains the service interface and implementation class.
<JWSDP_HOME>/docs/tutorial/examples/jaxrpc/dephello/ build/shared- Add
HelloIF.class
andHelloImpl.class
to the field labelled Contents of MyHelloWAR.- Click OK.
- Click Next.
- Choose Component Type dialog
- JAX-RPC Default Settings dialog
- In the WSDL Target Namespace Base String field, enter the following:
http://wombat.com/wsdl/- In the Schema Target Namespace Base String field, enter the following:
http://wombat.com/xsd/- In the Endpoint Alias Base String field, enter
/jaxrpc
.- Click Next.
- JAX-RPC Endpoint dialog
- In the EndPoint Interface combo box, select
dephello.HelloIF
.- In the EndPoint Class combo box, select
dephello.HelloImpl
.- In the Endpoint Name field, enter
MyHelloWorld
.- In the Endpoint Display Name field, enter
MyHelloWorld
.- Leave the Alias field blank.
- Click Next.
- JAX-RPC Model dialog
- Review Settings dialog
- 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 thejaxrpc-ri.xml
file, also to be packaged in the WAR file. Thejaxrpc-ri.xml
file is implementation-specific and is not defined by the specifications.- Click Finish.
The
deploytool
utility now creates theMyHello.war
file.Deploying the Web Application
- From the main menu of
deploytool
, select Tools->Deploy.- In the Text Input dialog, enter
/jaxrpc-dephello
for the Web context.- The Deployment Console dialog appears and displays this line:
OK - Installed application at context path /jaxrpc-dephello- Click Close.
Checking the Status of the Web Service
In a browser, go to the following URL:
http://localhost:8080/jaxrpc-dephello/jaxrpc/MyHelloWorldThe 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?WSDLThis 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 yourMyHello.war
file with theCompareMyHello.war
file of thedephello/provided-jars
subdirectory.
Running the Client
Home
TOC Index |
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.