2 Replies Latest reply on Apr 10, 2009 7:45 PM by mpurdy1973

    SOAP over JMS using JBOSS Messaging

    mpurdy1973

      i have used SOAP over JMS with TIBCO EMS Server; i would like to do the same with JBOSS Messaging in AS 5.0.1

      below is the client code for an example of what i am trying to do

      thanx,
      matt



      
      
      import javax.jms.JMSException;
      import javax.jms.MessageProducer;
      import javax.jms.Queue;
      import javax.jms.QueueConnection;
      import javax.jms.QueueConnectionFactory;
      import javax.jms.QueueReceiver;
      import javax.jms.QueueSession;
      import javax.jms.TextMessage;
      
      public class SoapOverJmsClient
      {
       public static final String SOAP_REQUEST = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ns0=\"http://www.pyxisengineering.com/Quote/\"><soapenv:Header/><soapenv:Body><ns0:GetAll><symbol>tibx</symbol></ns0:GetAll></soapenv:Body></soapenv:Envelope>";
       public static final String REQUEST_JMS_QUEUE_NAME = "queue.sample";
       public static final String REPLY_TO_JMS_QUEUE_NAME = "queue.sample";
      
       public static void main(String[] args)
       {
      
       String inputValue = "tibx";
       SoapOverJmsClient.sendJMS(inputValue);
      
       }//end SoapOverJmsClient entry point
      
       public static void sendJMS(String inputValue)
       {
       //receiving reply from the queue.
       try
       {
       //create the queues
       QueueConnectionFactory factory = new com.tibco.tibjms.TibjmsQueueConnectionFactory("localhost");
       QueueConnection connection = factory.createQueueConnection(null, null);
       QueueSession session = connection.createQueueSession(false, javax.jms.Session.AUTO_ACKNOWLEDGE);
       Queue requestQueue = session.createQueue(SoapOverJmsClient.REQUEST_JMS_QUEUE_NAME);
       javax.jms.Queue replyToQueue = session.createQueue(SoapOverJmsClient.REPLY_TO_JMS_QUEUE_NAME);
      
       //build jms message
       MessageProducer sender = session.createSender(requestQueue);
       TextMessage txtMsg = session.createTextMessage();
       txtMsg.setStringProperty("SoapAction", "\"GetAll\"");
       txtMsg.setStringProperty("Mime_Version", "1.0");
       txtMsg.setStringProperty("Content_Type", "application/xml; charset=\"utf-8\"");
       txtMsg.setText(SoapOverJmsClient.SOAP_REQUEST);
      
       //set the reply queue
       txtMsg.setJMSReplyTo(replyToQueue);
      
       //send message
       sender.send(txtMsg);
      
      
       //use createQueue() to enable receiving from dynamic queues.
       QueueReceiver receiver = session.createReceiver(replyToQueue);
      
       //start the connection to receive from queue
       connection.start();
      
       //read queue messages
       javax.jms.Message message = receiver.receive(10000);
       if(message != null)
       System.out.println("Received message: " + message);
       else
       System.out.println("Error while retriving message");
       connection.close();
       }
       catch(JMSException jmse)
       {
       jmse.printStackTrace();
       System.exit(0);
      
       }//end catch jmse
      
       }//end static sendJMS
      
      }//end class SoapOverJmsClient
      
      


        • 1. Re: SOAP over JMS using JBOSS Messaging
          gaohoward

          Hi,

          JBoss Messaging fully complies with JMS spec 1.1. So your code can be easily migrated to JBoss Messaging without much changes. The only place you need to adapt is the way to get a connection factory. JBM 1.4 uses JNDI look up. You may also take a look at the upcoming JBM 2.0, which has more ways than one to do the job.

          • 2. Re: SOAP over JMS using JBOSS Messaging
            mpurdy1973

             

            "gaohoward" wrote:
            Hi,

            JBoss Messaging fully complies with JMS spec 1.1. So your code can be easily migrated to JBoss Messaging without much changes. The only place you need to adapt is the way to get a connection factory. JBM 1.4 uses JNDI look up. You may also take a look at the upcoming JBM 2.0, which has more ways than one to do the job.


            thanx... i will check it out