|
|
| 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.
- Prerequisites
- Configure the JMS Components
- Compile and Configure the Message-Driven Bean
- Build and Run the Example with Simple Data
- Build and Run the Example with Complex Data
Before you run this example, you need:
- WebLogic Server Version 7.0
Follow these steps to configure the JMS components:
- Start the examples WebLogic Server.
- Invoke the Administration Console in
your browser.
- Click to expand the JMS node under the Services node in the left pane.
- Click to expand the Servers node.
- Click to expand the examplesJMSServer node.
- Right-click the Destinations node and choose Configure a new JMSQueue from the drop-down list.
- Enter inqueue in the Name textfield.
- Enter weblogic.jms.inqueue in the JNDIName textfield.
- Click Create.
- Right-click the Destinations node in the left pane and choose Configure a new JMSQueue from the drop-down list.
- Enter outqueue in the Name textfield.
- Enter weblogic.jms.outqueue in the JNDIName textfield.
- Click Create.
Follow these steps to compile and configure the message-driven bean:
- Setup a development shell as described in Quick Start.
- Change to the SAMPLES_HOME\server\src\examples\webservices\message\setupEJB directory, where SAMPLES_HOME refers to the examples
WebLogic Server domain directory.
- Assemble and compile the BounceBean example by executing the Java ant utility at the command line:
prompt> ant
- Copy the BounceBean.ear file from the classDir directory to the
WebLogic examples Server's applications directory.
- Verify the EJB deployment by monitoring the WebLogic Server log file.
The log file should say:
Activate application _appsdir_BounceBean_ear on
myserver( Running )
- 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
To build and run the example, follow these steps:
- Setup a development shell as described in Quick Start.
- Change to the SAMPLES_HOME\server\src\examples\webservices\message\client directory, where SAMPLES_HOME refers to the examples
WebLogic Server domain directory.
- Compile the two client routines (send2WS and fromWS) by executing the Java ant utility at the command line:
prompt> ant
- 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.
- 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.
- In the
send2WS window, type in a text string such as
"Hello"
- The
fromWS window responds with "Hello"
- 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:
- Setup a development shell as described in Quick Start.
- Change to the SAMPLES_HOME\server\src\examples\webservices\message\object directory, where SAMPLES_HOME refers to the examples
WebLogic Server domain directory.
- Compile the two client routines (sendObj2WS and fromObjWS) by executing the Java ant utility at the command line:
prompt> ant
- 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.
- 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
- The
fromObjWS responds as follows:
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:
Copyright © 2002 BEA Systems, Inc. All rights reserved.