A Simple Example: HelloWorld
This example shows you how to use JAX-RPC to create a Web service named HelloWorld. A remote client of the HelloWorld service can invoke the sayHello method, which accepts a string parameter and then returns a string. 
HelloWorld at Runtime 
Figure 10-1 shows a simplified view of the HelloWorld service after it's been deployed. Here's a more detailed description of what happens at runtime: 
To call a remote procedure, the HelloClient program invokes a method on a stub, a local object that represents the remote service. 
The stub invokes routines in the JAX-RPC runtime system. 
The runtime system converts the remote method call into a SOAP message and then transmits the message as an HTTP request. 
When the server receives the HTTP request, the JAX-RPC runtime system extracts the SOAP message from the request and translates it into a method call. 
The JAX-RPC runtime system invokes the method on the tie object. 
The tie object invokes the method on the implementation of the HelloWorld service. 
The runtime system on the server converts the method's response into a SOAP message and then transmits the message back to the client as an HTTP response. 
On the client, the JAX-RPC runtime system extracts the SOAP message from the HTTP response and then translates it into a method response for the HelloClient program. 
 
Figure 10-1 The HelloWorld Example at Runtime 
The application developer only provides the top layers in the stacks depicted by Figure 10-1. Table 10-1 shows where the layers originate. 
Table 10-1 Who (or What) Provides the Layers 
Layer Source
HelloClient Program
HelloWorld Service (definition interface and implementation class) Provided by the application developer
Stubs
Ties Generated by the xrpcc tool, which is run by the application developer
JAX-RPC Runtime
System Included with the Java WSDP
HelloWorld Files 
To create a service with JAX-RPC, an application developer needs to provide just a few files. For the HelloWorld example, these files are in the <JWSDP_HOME>/docs/tutorial/examples/jaxrpc/hello directory: 
HelloIF.java - the service definition interface 
HelloImpl.java - the service definition implementation class, it implements the HelloIF interface 
config.xml - a configuration file read by the xrpcc tool, which creates the stub and tie classes 
web.xml - a deployment descriptor for the Web component (a servlet) that dispatches to the service 
HelloClient.java - the remote client that contacts the service and then invokes the sayHello method 
Setting Up 
If you haven't already done so, follow these instructions in the chapter Getting Started With Tomcat: 
Setting the PATH Variable 
Creating the Build Properties File 
Starting Tomcat 
Building and Installing the Service 
The basic steps for developing a JAX-RPC Web service are as follows. 
Code the service definition interface and implementation class. 
Compile the service definition code of step 1. 
Create the configuration file. 
Generate the ties. 
Create the deployment descriptor. 
Install the service on Tomcat. 
The sections that follow describe each of these steps in more detail.