Creating J2EE 1.4 Web Services Clients: EJB Client

Contents

Overview

This example demonstrates an EJB acting as a J2EE client of a 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/consumer.ear.

Step 2 - Deploy the Web Service

The service is now ready to be deployed. To deploy this ear to a running instance of oc4j, type: ant deploy-demo.

Step 4 - Run the Client

You are now ready to run the client for the webservice.
Examine the file application-client.xml in src/client. To run the client, type: ant run-demo. You should see output such as the following.

    run-demo:
    [echo] invoking ejb application client..
    [java] client started... 
    [java] result from service :Hello ..Ejb Client..!

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