WebLogic Server 7.0 Code Examples, BEA Systems, Inc.

Package examples.webservices.basic.javaclass

This example shows how to create a WebLogic Web service based on a custom Java class backend component.

See:
          Description

Class Summary
Client This class illustrates how to use the JAX-RPC API to statically invoke the HelloWorld WebLogic Web Service, implemented with a Java class.
HelloWorld Simple Java class that implements the HelloWorld Web service.
 

Package examples.webservices.basic.javaclass Description

This example shows how to create a WebLogic Web service based on a custom Java class backend component.

The Java class is a classic HelloWorld program that defines a single method called sayHello. The method takes only built-in data types as its parameters and return value. In particular, the sayHello method takes as input an int and a String parameter and returns a String return value.

When the Java class is converted into a Web service, the sayHello method becomes the public operation specified in the WSDL of the Web service.

The build.xml file compiles, assembles, packages, deploys, and runs the example. The file calls the servicegen WebLogic Ant task that automatically generates:

After servicegen generates these components, it packages them, along with the Java class, into an EAR file that can be deployed on WebLogic Server.

The build.xml file then calls the clientgen Ant task that creates another client JAR file used by a client application to invoke the Web service. This client JAR file is created locally rather than the one that's created as part of the servicegen Ant task that ends up on WebLogic Server. Typically users that need the client JAR file either use the clientgen Ant task or download it from the Web services Home Page.

Client.java is a static client application that directly uses the Web service interfaces to invoke the sayHello operation. It uses JAX-RPC style APIs to invoke the Web service.

Additional Resources for examples.webservices.basic.javaclass
build.xml The Java Ant build script that creates the Java class JAR file, creates the Web service EAR file using the servicegen Ant task, creates the client JAR file using the clientgen Ant task, compiles the client application, deploys the EAR file, and runs the application.

 

The following sections describe how to build and run the example.

  1. Prerequisites
  2. Build the Example
  3. Run the Example
  4. Check the Output

 

Prerequisites

Before you run this example, you need:

 

Build the Example

To build the example, follow these steps:
  1. Set up your development shell as described in Quick Start.

  2. Change to the SAMPLES_HOME\server\src\examples\webservices\basic\javaclass directory, where SAMPLES_HOME refers to the examples WebLogic Server domain directory.

  3. Assemble and compile the example by executing the Java ant utility at the command line:
    prompt> ant

 

Run the Example

  1. Start the examples WebLogic Server.

  2. In your development shell, run the Client Java application using the following command:
    prompt> ant run 
  3. After building and running the example, you can view the Web Service Home Page using the following URL:

    http://localhost:port/basic_javaclass/HelloWorld

    where

    From the Web Service Home Page you can view the generated WSDL and test the Web service to make sure it's working correctly.

 

Check the Output

If your example runs successfully, you will get the following message in the command shell from which you started WebLogic Server:
sayHello in webservices.basic.javaclass webservice has been invoked with arguments A and 4
And the following output in your client window:
Buildfile: build.xml

run:
     [java] The client passed the Values 4 and A to the webservice, and got back
 this result:
     [java] This message brought to you by the letter A and the number 4

BUILD SUCCESSFUL

 

See Also

Read more about:


Documentation is available at
http://e-docs.bea.com/wls/docs70

Copyright © 2002 BEA Systems, Inc. All Rights Reserved.