![]() |
JAX-RPC Simple Application |
JAX-RPC Simple Sample Application
This document describes how to utilize the JAX-RPC Simple sample application in conjunction with the Sun Java (tm) System Application Server 7.This sample application document contains the following sections:
Overview
Compiling and Assembling the Application
Deploying the Sample Application
Overview
This example shows you how to use the Java API for XML-based RPC (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 1 displays a simplified view of the HelloWorld service after it has been deployed.Following is 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 1    HelloWorld Example at Runtime ![]()
The application developer only provides the top layers in the stacks depicted by Figure 1. Table 1 describes where the layers originate.
For more information about the JAX-RPC and JAX-RPC simple applications, go to: http://java.sun.com/webservices/docs/1.0/tutorial/doc/JAXRPC3.html.
Compiling and Assembling the Application
To recompile, assemble and deploy the application, see the Sample Application Build Facility document for details on using a build facility to quickly perform these tasks.For example, to rebuild the entire application from scratch, perform the following steps:
Compile and Assemble the J2EE Application.
Deploy the application.
- Execute the asant command under <install_dir>/samples/webservices/jaxrpc/simple/src.
- The default target core is executed to rebuild the .jar and .war files.
Clean the application project area.
- After you have re-created the sample application from scratch, proceed to Deploying the Sample Application.
Undeploy the application.
- Execute the asant clean command to clean the application area.
Build Javadocs.
- Execute the asant undeploy command to undeploy the application.
- Execute the asant javadocs command to create Javadocs.
- The Javadocs are created under <install_dir>/samples/webservices/jaxrpc/simple/javadocs.
Deploying the Sample Application
A pre-built jaxrpc-simple.war file is supplied with the application server installation. The pre-built jaxrpc-simple.war file is the Web Archive (.war) file of the application. Within the .war file resides the .xml deployment descriptor files, application class files, and other content required by the application. You can use the pre-built .war file to deploy the application. If you want to compile and assemble the application from scratch, follow the instructions under Compiling and Assembling the Application.To deploy the application, the administrative server needs to be running.
To start the administrative server if it is not already started:
For UNIX
Execute <install_dir>/domains/domain1/admin-server/startserv
For Windows
Start->Programs->Sun Java (tm) System Application Server 7->Start Application ServerSelect one of the following approaches to deploy the application:
Command Line-Based Deployment describes how to manually register the application using a Command Line Interface (CLI).
Web-Based Deployment describes how to use the web-based administration tool to deploy the sample application.
- This is the quickest means of deploying the application.
Command Line-Based Deployment
While Command Line Interface is the quickest means of deploying the application, if you want to deploy through a GUI tool, follow the instructions under the Web-Based Deployment section.CLI deployment of the application can be performed using either the asant script or the asadmin command.
The deployment process includes deploying the application .war file to the Sun Java (tm) System application server.
Deploy the application using the asant command:
>cd <install_dir>/samples/webservices/jaxrpc/simple/src
Deploy the application file using the asadmin command:Execute the asant deploy command.
- It is an interactive command that might prompt you to provide the admin-server host, admin-server port, admin user name, admin password and appserv instance.
>cd <install_dir>/samples/webservices/jaxrpc/simple
The deployment process involves the following operations:Execute the asadmin deploy -u <user-name> -w <password> -H <hostname> -p <admin server port> --instance <instance name> jaxrpc-simple.war command.
It authenticates against the local application server's administrative server.
The .war file is transferred to the administrative server.
The administrative server begins the registration process:
Log in to the web-based administration tool from the browser.
Click Deploy.
- Application Server Instances --> <server instance> --> Applications --> Web Apps
Click Browse to locate the jaxrpc-simple.war file. The file is located under <install_dir>/samples/webservices/jaxrpc/simple.
Enter jaxrpc-simple in the Web Application Name field.
Enter jaxrpc-simple in the Context Root field.
Click the jaxrpc-simple link to verify that the application is deployed.
- Now you are ready to run the application (see Running the Sample Application).
Running the Sample Application
Perform the following steps to run the sample application:
>cd <install_dir>/samples/webservices/jaxrpc/simple/src
Execute the asant run command.
- The program should display the following line:
- Hello Duke!
Troubleshooting
If you see a Connection refused error, when you do asant run, make certain that soap:address location in <install_dir>/samples/webservices/jaxrpc/simple/src/HelloWorld.wsdl is set to http://<hostname>:<instance-port>/jaxrpc-simple/simple. Please modify the file and execute asant core before running the sample again.
Copyright © 2002 Sun Microsystems, Inc. All rights reserved.
Last Updated July 11, 2002