WebLogic Server 6.1 Code Examples, BEA Systems, Inc.

Package examples.webservices.rpc

This example illustrates how to create an RPC-style WebLogic Web service and how to invoke it from a variety of client applications.

See:
          Description

Package examples.webservices.rpc Description

This example illustrates how to create an RPC-style WebLogic Web service and how to invoke it from a variety of client applications.

The example demonstrates how to:

Additional Resources for examples.webservices.rpc
weatherEJB/Weather.java The public interface of the Weather EJB.
weatherEJB/WeatherBean.java The actual implementation class of the Weather EJB.
weatherEJB/WeatherHome.java The Home interface of the Weather EJB.
weatherEJB/build-ejb.xml The Java Ant build script for assembling the Weather EJB.
weatherEJB/build-ws.xml The Java Ant build script for assembling the Weather Web Service.
weatherEJB/build.xml The Java Ant build script that calls the build-ejb.xml and build-ws.xml build scripts
javaClient/Client.java The static Java client that invokes the Weather Web service by directly referencing its WSDL and methods.
javaClient/DClient.java The dynamic Java client that invokes the Weather Web service by directly referencing its WSDL but indirectly referencing its methods via the WebServiceProxy class.
javaClient/XMethodClient.java The Java client that invokes the a Weather Web service hosted by the http://www.xmethods.net Web site.
javaClient/XMethodClient.java The Java client that invokes the a Weather Web service hosted by the http://www.xmethods.net Web site.
javaClient/build.xml The Java Ant build script for compiling the Java clients.

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

  1. Build the example
  2. Run the example

Build the Example

  1. Open a new command shell to build the example EJBs.

  2. Set up your development shell as described in Setting up your environment.

  3. Change to the %WL_HOME%/samples/examples/webservices/rpc/weatherEJB directory, where WL_HOME refers to the main WebLogic Server installation directory:
    $ cd %WL_HOME%\samples\examples\webservices\rpc\weatherEJB
  4. Compile the Weather EJB and assemble and deploy the Weather Web service by typing ant at the command line. The Java Ant utility uses the supplied Java Ant build script build.xml:
    $ ant

    The build script builds the example weather EJB, generates a Weather Web service, and places the resulting .ear files in the deployment directory of the examples server.

  5. Download the Java client JAR file for the Weather Web Service by following these steps:

    1. Invoke the WebLogic Web Services Home Page for the Weather Web service in your browser using the following URL:
      http://host:port/weather
      where host refers to the computer on which WebLogic Server is running and port refers to the port number WebLogic Server is listening to.
    2. Click statelessSession.WeatherHome.
    3. Click client.jar.
    4. Save the file in the %WL_HOME%/samples/examples/webservices/rpc/javaClient directory, where WL_HOME refers to the main WebLogic Server installation directory.

  6. Change to the %WL_HOME%/samples/examples/webservices/rpc/javaClient directory, where WL_HOME refers to the main WebLogic Server installation directory:
    $ cd %WL_HOME%\samples\examples\webservices\rpc\javaClient
  7. Ensure that your CLASSPATH environment variable contains the %WL_HOME%/samples/examples/webservices/rpc/javaClient/client.jar JAR file you just downloaded.

  8. Compile the Client classes by typing ant at the command line. The Java Ant utility uses the supplied Java Ant build script build.xml:
    $ ant
  9. If you want to run the Microsoft VisualBasic client, follow these steps:

    1. Download and install on your computer Microsoft's SOAP ToolKit 2.0 from Microsoft's SOAP Web site.
    2. Bring up Microsoft Visual Basic 6.0.
    3. Load the %WL_HOME%/samples/examples/webservices/rpc/vbClient/VBClient.vbp project, where WL_HOME refers to the main WebLogic Server installation directory.
    4. In Microsoft VisualBasic, click Project->References. Ensure that Microsoft SOAP Type Library is checked.

Run the Example

  1. Open a separate command-line window in which you will run the client.
  2. Set up the environment for your client as described in Setting up your environment for building and running the examples.
  3. Ensure that your CLASSPATH environment variable contains the %WL_HOME%/samples/examples/webservices/rpc/javaClient/client.jar JAR file you just downloaded.
  4. Run the static Java client using the command:
    $ java examples.webservices.rpc.javaClient.Client http://host:port

    where host refers to the computer on which WebLogic Server is running and port refers to the port number WebLogic Server is listening to. Specify http://localhost:7001 for WebLogic Server running on the local computer at the default port.

  5. Run the dynamic Java client using the command:
    $ java examples.webservices.rpc.javaClient.DClient http://host:port

    where host refers to the computer on which WebLogic Server is running and port refers to the port number WebLogic Server is listening to. Specify http://localhost:7001 for WebLogic Server running on the local computer at the default port.

  6. Run the Java XMethod client using the command:
    $ java examples.webservices.rpc.javaClient.XMethodClient
  7. Run the Microsoft Visual Basic client by changing to the vbClient directory and executing the VBClient.exe VisualBasic application:
    $ VBClient.exe

    Enter a zip code in the text field and click Get Temperature.

    NOTE: For the sake of simplicity, the actual Weather EJB is hardcoded to return a temperature of 77 for the 90210 zip code, and -273.15 for all other zip codes.

There's More...

Read more about:
Documentation is available at
http://e-docs.bea.com/wls/docs61

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