Creating J2EE 1.4 Web Services Clients: Web Client

Contents

Overview

This example demonstrates a servlet acting as a J2EE client consuming a remote Web Service.

Quick Start

Ensure that you have installed the required software and set up your environment. You must have OC4J running. If it is not running on localhost, port 8888, you'll have to modify the ANT script (build.xml) to use the correct host and port to your server.

In addition to having the server configured and running, you also need to make sure that the Web Service referenced by this example has been deployed and is running. The end point address of the service is http://localhost:8888/hello/HelloService. This can be achieved by deploying the demo /basic/stateless/ - just type ant from the basic/stateless directory.

Once you have the server configured and running, just type ant from the ejb-client directory. The ant build.xml is configured for easily running this demo.

Step By Step

Step 1 - Assemble the application

To create a deployable application, type: ant assemble.
This results in a J2EE Web Services compliant application file: dist/consumerWeb.jar.

Step 2 - Deploy the application

To deploy the application, type: ant deploy-demo.

Step 3 - Run the Client

To run the client, type: ant run. You should see output such as the following.

client-run:
run-demo:
     [echo] Please fire up your browser and enter the following address
localhost:8888/consumerWeb/consumer
      [get] Getting: http://localhost:8888/consumerWeb/consumer
Check out ./result.html, you should see:
"result from service :Hello Servlet Consumer !"
or you can point your browser to the following URL: http://localhost:8888/consumerWeb/consumer.

Note: You need to make sure that your application server is up and the web site configured before attempting to build.