Sun Java System Application Server 

Samples Index

SOAP to JMS Sample Application

The SOAP to JMS sample application contains one application client which can be used to invoke two simple Java objects:

Building, Deploying, and Running the Application

The general instructions for building, deploying, and running sample applications are provided in Building, Deploying, and Running Sample Applications. In reading this document, use the following application-specific variables for this application:

Follow this general procedure:

  1. Build the Application. The build file, build.xml, is in the app_dir directory.

    By default, the application 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, change the value of the url property in the src/soaptojms.properties file.

    Before you deploy or run the application, you must ensure that the neccessary resources have been configured for Application Server. The included asant deployment script automatically performs this step for you. But if you are using another deployment mechanism, you must perform it manually. See the instructions in Configuring Resources.

  2. Run the Application as described below.

Configuring Resources

If you deploy the application using asant, it will configure all the resources automatically. Otherwise, you must do it manually.

Configuring Resources with Admin Console

Follow these steps to configure resources with Admin Console:

  1. Log on to the Admin Console.
  2. In the left pane, click on  Java Message Service
  3. Click on Connection Factories.
  4. Click New in the right pane.
  5. Add the following:
    JNDI-Name: jms/TopicConnectionFactory
    Type: javax.jms.TopicConnectionFactory
    Resource: Select Enabled checkbox
    
  6. Click on Destination Resources.
  7. Click New in the right pane.
  8. Add the following:
    JNDI-Name: jms/TestTopic
    Type: javax.jms.Topic
    Resource: Select Enabled checkbox
    
  9. Add a new property for this destination resource, with name-value pair as Name=TestTopic.

Configuring resources with asadmin

To configure the resources using asadmin, use these commands:

Configure connection factory::

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

Configure destination(topic):

asadmin create-jms-resource --user username --password password
  --restype javax.jms.Topic --property Name=TestTopic
  jms/TestTopic

Running the Sample Application

To run the sample application follow these steps:

  1. In a shell (console) window, change your working directory to app_dir
    cd install_dir/samples/jms/apps/soaptojms/simple/
    
  2. Set the value of the environment variable APPCPATH to install_dir/imq/lib/imqxm.jar.
  3. Run the application client to invoke the ReceiveSOAPMessageWithJMS object:
    install_dir/bin/appclient -client SOAPtoJMSMessageSampleClient.jar Receive
  4. Wait until you see the message "ready to receive SOAP messages ...".
  5. In another shell window, set the value of the environment variable APPCPATH to install_dir/imq/lib/imqxm.jar
  6. In this shell window, run the application client to invoke SendSOAPMessageWithJMS object as follows:
    install_dir/bin/appclient -client SOAPtoJMSMessageSampleClient.jar Send
    It 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
    
    When SendSOAPMessageWithJMS finishes publishing the message, ReceiveSOAPMessageWithJMS 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:
    
  7. Exit the ReceiveSOAPMessageWithJMS and SendSOAPMessageWithJMS application client programs by typing CTRL-C in the shell windows.

You can optionally pass 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, use these commands:

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 .

Troubleshooting

If you run the application in a different domain than the default, 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, use these commands:

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

Copyright © 2006 Sun Microsystems, Inc. All rights reserved.