WebLogic Server 7.0 Code Examples, BEA Systems, Inc.

Package examples.webservices.message

This example illustrates how to create a JMS-implemented WebLogic Web service.

Package examples.webservices.message Description

This example illustrates how to create a JMS-implemented WebLogic Web service.

The Web Service actually consists of two JMS components: one that, when invoked by a client application, sends a message to WebLogic Server, and the other that receives the message. The JMS backend components are two queues and a message- driven bean that transfers the message from the inqueue to the outqueue.

You can run the example using a simple data (String) or a more complex data type that contains XML data.

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

  1. Prerequisites
  2. Configure the JMS Components
  3. Compile and Configure the Message-Driven Bean
  4. Build and Run the Example with Simple Data
  5. Build and Run the Example with Complex Data

 

Prerequisites

Before you run this example, you need:

 

Configure the JMS Components

Follow these steps to configure the JMS components:

  1. Start the examples WebLogic Server.
  2. Invoke the Administration Console in your browser.
  3. Click to expand the JMS node under the Services node in the left pane.
  4. Click to expand the Servers node.
  5. Click to expand the examplesJMSServer node.
  6. Right-click the Destinations node and choose Configure a new JMSQueue from the drop-down list.
  7. Enter inqueue in the Name textfield.
  8. Enter weblogic.jms.inqueue in the JNDIName textfield.
  9. Click Create.
  10. Right-click the Destinations node in the left pane and choose Configure a new JMSQueue from the drop-down list.
  11. Enter outqueue in the Name textfield.
  12. Enter weblogic.jms.outqueue in the JNDIName textfield.
  13. Click Create.

 

Compile and Configure the Message-Driven Bean

Follow these steps to compile and configure the message-driven bean:

  1. Setup a development shell as described in Quick Start.
  2. Change to the SAMPLES_HOME\server\src\examples\webservices\message\setupEJB directory, where SAMPLES_HOME refers to the examples WebLogic Server domain directory.
  3. Assemble and compile the BounceBean example by executing the Java ant utility at the command line:
    prompt> ant
  4. Copy the BounceBean.ear file from the classDir directory to the WebLogic examples Server's applications directory.
  5. Verify the EJB deployment by monitoring the WebLogic Server log file. The log file should say: Activate application _appsdir_BounceBean_ear on myserver( Running )
  6. Verify that the Web Service is deployed and you can visit its Home Page and WSDL using the following URI: http://localhost:7001/BounceBean/BounceService and http://localhost:7001/BounceBean/BounceService?WSDL

 

Build and Run the Example With Simple Data

To build and run the example, follow these steps:
  1. Setup a development shell as described in Quick Start.
  2. Change to the SAMPLES_HOME\server\src\examples\webservices\message\client directory, where SAMPLES_HOME refers to the examples WebLogic Server domain directory.
  3. Compile the two client routines (send2WS and fromWS) by executing the Java ant utility at the command line:
    prompt> ant
  4. Execute fromWS by using the following command:
     java -classpath .;%CLASSPATH% fromWS
    The fromWS routine outputs a message indicating that it is waiting for a message.

  5. In another development shell, setup the WebLogic Server environment and execute the send2WS routine from the same client directory using the following command:
     java -classpath .;%CLASSPATH% send2WS
    The send2WS routine outputs a message indicating that it is waiting for input.

  6. In the send2WS window, type in a text string such as "Hello"
  7. The fromWS window responds with "Hello"
  8. Enter "quit" from the send2JMS window. Both routines should exit.

 

Build and Run the Example With Complex Data

To build and run the example with a complex data type, follow these steps:
  1. Setup a development shell as described in Quick Start.
  2. Change to the SAMPLES_HOME\server\src\examples\webservices\message\object directory, where SAMPLES_HOME refers to the examples WebLogic Server domain directory.
  3. Compile the two client routines (sendObj2WS and fromObjWS) by executing the Java ant utility at the command line:
    prompt> ant
  4. Execute the client class fromObjWS by using the following command:
    java -classpath .;%CLASSPATH% orderParser.fromObjWS
    The routine outputs a message indicating that it is waiting for a message.

  5. In another development shell, execute the client class send2ObjWS using the following command (Note this routine requires one argument - the XML file that describes the example purchase order):
    java -classpath .;%CLASSPATH% orderParser.sendObj2WS order.xml
    The sendObj2WS routine responds by outputting the following information:
            Successfully sent the document
  6. The fromObjWS responds as follows:
  7. Printing contents of OrderBO...
    
    Order Number:
    1234
    Customer Info:
    John Doe
    2000 Pine St
    San Francisco, CA 94403
    Order Info:
    4321 Stuffed Pastry 10x2.95
    8765 Chocolate 5x9.5
    9922 Cookie 30x0.85
    
    Successfully handled the document

 

See Also

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

Copyright © 2002 BEA Systems, Inc. All rights reserved.