SOAP to JMS Sample Application

  Samples Index




SOAP to JMS Sample Application


This document describes how to run the SOAP to JMS sample application on the current version of the Application Server.

This document contains the following sections:



Overview

The SOAP to JMS sample application contains one application client which can be used to invoke two simple Java objects, SendSOAPMessageWithJMS and ReceiveSOAPMessageWithJMS.



Compiling and Assembling the Application



This section describes how to build and assemble the SOAP to JMS sample application using the asadmin Command Line Interface (CLI).

  1. Go to the soaptojms/simple directory of the sample:
  2. cd <install_dir>/samples/jms/apps/soaptojms/simple

  3. By default, the SendSOAPMessageWithJMS object creates an attachment that includes the index.html file located at the URL http://localhost:8080/. If you want to attach a file at a different URL, or if you have changed the Application Server HTTP port from 8080 to some other value, open the file src/soaptojms.properties in a text editor and change the value of the url property.
  4. Compile and assemble the application:
  5. <install_dir>/bin/asant

    The default target core will be executed to compile the Java source files and build the JAR file.

  6. Clean the application project area using the asant clean command (optional):
  7. <install_dir>/bin/asant clean

  8. Generate API documentation (optional):
  9. <install_dir>/bin/asant javadocs

    After the API documentation has been generated, you may access it at <install_dir>/samples/jms/apps/soaptojms/simple/simple-client/javadocs.


Note <install_dir> is the application server installation home.




Configuring Resources

There are several ways to configure resources for this sample.
 

Configuring resources through asant

 build.xml file comes with a predefined set of ant targets for configuring  resources.

Execute  asant   deploy  under  <install_dir>/samples/jms/apps/soaptojms/simple

 You can logon to http://<hostname>:<admin-port>/asadmin to see, if the JMS resources are configured or not.
 

Configuring resource through admin GUI

Follow these steps to manually configure resources through admin.
1. Logon to http://<hostname>:<admin-port>/asadmin
2. In the left pane, click on Java Message Service
3. Click on Connection Factories. Click New in the right pane.
4. Add the following:
JNDI-Name: jms/TopicConnectionFactory
Type: javax.jms.TopicConnectionFactory
Resource: Select Enabled checkbox
5. Click on Destination Resources. Click New in the right pane.
6. Add the following:
JNDI-Name: jms/TestTopic
Type: javax.jms.Topic
Resource: Select Enabled checkbox
7. Add a new property for this destination resource, with name-value pair as imqDestinationName=TestTopic
 

Configuring resource through CLI admin

You can as well configure these resources using CLI admin, as follows:
for connection factory:

asadmin create-jms-resource  --user <username> --password <password>   --restype javax.jms.TopicConnectionFactory jms/TopicConnectionFactory

for destination(topic):

asadmin create-jms-resource  --user <amin-user> --password <admin-password>  --restype javax.jms.Topic --property imqDestinationName=TestTopic  jms/TestTopic



Running the Sample Application

To run the sample application using the asant command, do the following:

  1. Go to the top level directory of the sample in command window:
  2. cd <install_dir>/samples/jms/apps/soaptojms/simple/

  3. Set environment variable APPCPATH to point to <install_dir>/imq/lib/imqxm.jar
  4. Run the application client to invoke ReceiveSOAPMessageWithJMS object in a command window as follows:
  5. <install_dir>/bin/appclient -client SOAPtoJMSMessageSampleClient.jar Receive

  6. Wait until you see the message "ready to receive SOAP messages ...".
  7. Then, in another command window, set environment variable APPCPATH to point to <install_dir>/imq/lib/imqxm.jar
  8. In that same window where you just set APPCPATH for step 5, run the application client to invoke SendSOAPMessageWithJMS object as follows:
  9. <install_dir>/bin/appclient -client SOAPtoJMSMessageSampleClient.jar Send

    The SendSOAPMessageWithJMS object displays the following messages:

    [java] Create a SOAP message
    [java] Attaching the file from URL: http://localhost:8080
    [java] Convert the message to a JMS message
    [java] Publish the message
    [java] Finished

    As soon as the SendSOAPMessageWithJMS object finishes publishing the message, the ReceiveSOAPMessageWithJMS object in the first command window displays the following messages, followed by the HTML content of the attached URL:

    [java] Message received! Converting the JMS message to SOAP message
    [java] Attachment counts: 1
    [java] Content type: text/html
    [java] Content Id: cid-001
    [java] Attachment content:

  10. Exit the ReceiveSOAPMessageWithJMS and SendSOAPMessageWithJMS application client programs by typing CTRL-C.


Note <install_dir>  is the application server installation home.






Troubleshooting

  • If you are running this sample from a different domain than the default domain of domain1 then you need to pass in the location of sun-acc.xml to the appclient command, so that the application client runs using the correct port for that particular domain. Use the -xml flag to pass in this location of this sun-acc.xml file. For example, to run this example in the samples domain:

    • <install_dir>/bin/appclient -client SOAPtoJMSMessageSampleClient.jar Receive -xml <install_dir>/domains/samples/config/sun-acc.xml .

    • <install_dir>/bin/appclient -client SOAPtoJMSMessageSampleClient.jar Send -xml <install_dir>/domains/samples/config/sun-acc.xml .

  • You can optionally passing in the name of the Topic that you want the application client to reference when running. This optional paramater must match the value set to property queue.jndi.name, which is located in <install_dir>/samples/jms/apps/soaptojms/simple/build.xml file. The value is set to jms/TestTopic by default. If you choose to pass in this optional parameter, then you need to pass the Topic name to the appclient command, so that the application client runs using the correct Topic name. Both the Send and Receive invocations of the application client must use the same Topic name, and it must match the queue.jndi.name property value, which again is located in <install_dir>/samples/jms/apps/soaptojms/simple/build.xml file. For example, to run this example in the samples domain, using Topic name jms/TestTopic

  • <install_dir>/bin/appclient -client SOAPtoJMSMessageSampleClient.jar Receive jms/TestTopic -xml <install_dir>/domains/samples/config/sun-acc.xml .

  • <install_dir>/bin/appclient -client SOAPtoJMSMessageSampleClient.jar Send jms/TestTopic -xml <install_dir>/domains/samples/config/sun-acc.xml .

  • If you encounter problems when running the application, review the log files at <install-dir>/domains/<domain_name>/logs/server.log to see what went wrong.



  • Copyright © 2004 Sun Microsystems, Inc. All rights reserved.

    Last Updated February 18, 2004