axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject cvs commit: xml-axis-wsif/java/test/jms NativeJMSTest.java
Date Fri, 14 Jun 2002 14:47:16 GMT
antelder    2002/06/14 07:47:16

  Modified:    java/test/util wsiftestjmssetup.bat wsiftestmqsetup.bat
               java/samples/addressbook/wsifservice AddressBook.wsdl
               java/test wsif.test.properties
               java/samples/stockquote/wsifservice Stockquote.wsdl
  Added:       java/src/org/apache/wsif/util/jms
                        NativeJMSRequestListener.java
               java/test/jms NativeJMSTest.java
  Log:
  New testcase for the native JMS provider
  
  Revision  Changes    Path
  1.4       +4 -0      xml-axis-wsif/java/test/util/wsiftestjmssetup.bat
  
  Index: wsiftestjmssetup.bat
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/util/wsiftestjmssetup.bat,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- wsiftestjmssetup.bat	11 Jun 2002 09:23:14 -0000	1.3
  +++ wsiftestjmssetup.bat	14 Jun 2002 14:47:16 -0000	1.4
  @@ -12,6 +12,10 @@
   echo def qcf(TempQCF) > wsiftestjmssetup.scp
   echo def q(AddressBookReplyTo) qu(AddressBookReplyTo) >> wsiftestjmssetup.scp
   
  +rem these should match the nativejms properties in wsif.test.properties 
  +echo def q(NativeJmsRequestQueue) queue(NativeJmsRequestQueue) >> wsifjmssetup.scp
  +echo def q(NativeJmsResponseQueue) queue(NativeJmsResponseQueue) >> wsifjmssetup.scp
  +
   rem this should match the wsif.async.replytoq value in wsif.test.properties 
   echo def q(AsyncReplyTo) qu(AsyncReplyTo) >> wsiftestjmssetup.scp
   
  
  
  
  1.4       +5 -1      xml-axis-wsif/java/test/util/wsiftestmqsetup.bat
  
  Index: wsiftestmqsetup.bat
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/util/wsiftestmqsetup.bat,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- wsiftestmqsetup.bat	11 Jun 2002 09:23:14 -0000	1.3
  +++ wsiftestmqsetup.bat	14 Jun 2002 14:47:16 -0000	1.4
  @@ -10,8 +10,12 @@
   
   echo DEFINE QLOCAL('AddressBookReplyTo') REPLACE > wsiftestmqsetup.mqs
   
  +rem these should match the nativejms properties in wsif.test.properties 
  +echo DEFINE QLOCAL('NativeJmsRequestQueue') REPLACE >> wsifmqsetup.mqs
  +echo DEFINE QLOCAL('NativeJmsResponseQueue') REPLACE >> wsifmqsetup.mqs
  +
   rem this should match the wsif.async.replytoq value in wsif.test.properties 
  -echo DEFINE QLOCAL('AsyncReplyTo') REPLACE > wsiftestmqsetup.mqs
  +echo DEFINE QLOCAL('AsyncReplyTo') REPLACE >> wsiftestmqsetup.mqs
   
   echo + Calling runmqsc in batch mode to create objects
   @REM w/o queue manger - use system default queuemanager
  
  
  
  1.2       +6 -12     xml-axis-wsif/java/samples/addressbook/wsifservice/AddressBook.wsdl
  
  Index: AddressBook.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/samples/addressbook/wsifservice/AddressBook.wsdl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AddressBook.wsdl	6 Jun 2002 08:28:46 -0000	1.1
  +++ AddressBook.wsdl	14 Jun 2002 14:47:16 -0000	1.2
  @@ -167,14 +167,15 @@
     </binding>
     
     <binding name="NativeJmsBinding" type="tns:AddressBook">
  -      <jms:binding type="TextMessage"/>
  +      <jms:binding type="ObjectMessage"/>
         <!-- executeInputOnlyOperation(WSIFMessage) -->
  +      <format:typeMapping encoding="Java" style="Java">
  +         <format:typeMap typeName="typens:address" formatType="com.ibm.www.namespace.wsif.samples.ab.types.Address"
/>
  +         <format:typeMap typeName="xsd:string" formatType="java.lang.String" />
  +      </format:typeMapping>
         <operation name="addEntry">
           <input name="AddEntryWholeNameRequest"/>       	
         </operation>  
  -  </binding>   
  -  <binding name="NativeJmsBinding2" type="tns:AddressBook">
  -      <jms:binding type="ObjectMessage"/> 
         <operation name="getAddressFromName">      	
         	<!-- executeRequestResponseAsync(WSIFMessage,WSIFResponseHandler) -->
         	<input name="GetAddressFromNameRequest"/>
  @@ -198,14 +199,7 @@
                      jndiProviderURL="file://C:/JNDI-Directory"/>
       </port>
       <port name="NativeJmsPort" binding="tns:NativeJmsBinding">
  -      <jms:address jndiDestinationName="NativeJmsAddressBookQueue"
  -                   destinationStyle="queue"
  -                   jndiConnectionFactoryName="WSIFSampleQCF"
  -                   initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory" 
  -                   jndiProviderURL="file://C:/JNDI-Directory"/>
  -    </port>
  -    <port name="NativeJmsPort2" binding="tns:NativeJmsBinding2">
  -      <jms:address jndiDestinationName="NativeJmsAddressBookQueue"
  +      <jms:address jndiDestinationName="NativeJmsRequestQueue"
                      destinationStyle="queue"
                      jndiConnectionFactoryName="WSIFSampleQCF"
                      initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory" 
  
  
  
  1.4       +4 -0      xml-axis-wsif/java/test/wsif.test.properties
  
  Index: wsif.test.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/wsif.test.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- wsif.test.properties	11 Jun 2002 09:23:14 -0000	1.3
  +++ wsif.test.properties	14 Jun 2002 14:47:16 -0000	1.4
  @@ -9,6 +9,10 @@
   # wsif.async.replytoq=<JMS q for async responses>
   wsif.async.replytoq=AsyncReplyTo
   #
  +# the nativejms properties should match the wsifjmssetup and wsifmqsetup bat files
  +wsif.nativejms.requestq=NativeJmsRequestQueue
  +wsif.nativejms.responseq=NativeJmsResponseQueue
  +#
   # wsif.test.components switches off some areas of unit test so that you can run 
   # whole suite without jms, ejb, remotewsdl (in WsdlLoadingTest) or jndi. By default,
   # all areas are on unless you explicitly turn them off.
  
  
  
  1.2       +1 -1      xml-axis-wsif/java/samples/stockquote/wsifservice/Stockquote.wsdl
  
  Index: Stockquote.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/samples/stockquote/wsifservice/Stockquote.wsdl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Stockquote.wsdl	6 Jun 2002 08:28:47 -0000	1.1
  +++ Stockquote.wsdl	14 Jun 2002 14:47:16 -0000	1.2
  @@ -108,7 +108,7 @@
                       jndiProviderURL="file://C:/JNDI-Directory"/>
       </port>
       <port name="NativeJmsPort" binding="tns:NativeJmsBinding">
  -      <jms:address jndiDestinationName="JmsStockQuoteQueue"
  +      <jms:address jndiDestinationName="NativeJmsRequestQueue"
                      destinationStyle="queue"
                      jndiConnectionFactoryName="WSIFSampleQCF"
                      initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory" 
  
  
  
  1.1                  xml-axis-wsif/java/src/org/apache/wsif/util/jms/NativeJMSRequestListener.java
  
  Index: NativeJMSRequestListener.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "WSIF" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, 2002, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.wsif.util.jms;
  
  import org.apache.wsif.WSIFOperation;
  import org.apache.wsif.WSIFException;
  import org.apache.wsif.WSIFCorrelationId;
  import org.apache.wsif.WSIFCorrelationService;
  import org.apache.wsif.util.WSIFCorrelationServiceLocator;
  import org.apache.wsif.base.WSIFDefaultCorrelationService;
  import org.apache.wsif.util.jms.*;
  import org.apache.wsif.util.jms.WSIFJMSFinderForJndi;
  import org.apache.wsif.logging.*;
  
  import addressbook.wsiftypes.AddressBook;
  import addressbook.wsiftypes.Address;
  import addressbook.wsiftypes.Phone;
  import stockquote.wsifservice.StockquotePT;
  import stockquote.wsiftypes.StockQuote;
  
  import java.io.Serializable;
  import java.util.*;
  import javax.jms.*;
  
  /**
   * Used to simulate the remote service for native JMS requests.
   * TODO this should be in the test package but the wsif.util.JMS classes aren't visable
   */
  public class NativeJMSRequestListener extends JMS2HTTPBridgeDestination {
   
      static final String startType = JMS2HTTPBridgeDestination.COLDSTART;
      static final String initialContextFactory = "com.sun.jndi.fscontext.RefFSContextFactory";
      static final String jndiUrl = "file://C:/JNDI-Directory";
      static final String sampleName = null;
      static final String queueConnectionFactory = "WSIFSampleQCF";
      static final String readQueue = null;
      static final String httpUrlString = "http://localhost:8080/soap/servlet/rpcrouter";
  
      private Thread listener;
  
      AddressBook ab = new AddressBook();
      StockQuote sq = new StockQuote();
      
      private WSIFJMSListener list = new WSIFJMSListener() {
          public void onException(JMSException arg1) {
              Tr.entry(this, arg1);
              System.out.println("Caught an exception!");
              arg1.printStackTrace();
              Tr.exit();
          }
  
          public void onMessage(Message message) {
              Tr.entry(this, message);
              processResponse(message);
              Tr.exit();
          }
      };
  
  
      public NativeJMSRequestListener(String msgQ) throws WSIFException {
      	super( new WSIFJMSFinderForJndi(
                      null,
                      initialContextFactory,
                      jndiUrl,
                      WSIFJMSFinder.STYLE_QUEUE,
                      queueConnectionFactory,
                      msgQ),
                  null,
                  WSIFJMSConstants.WAIT_FOREVER,
                  startType);
                  
          listener = new Thread() {
          	public void run() {
          		try {
     		           listen( list );
          		} catch (WSIFException ex) {
          		   ex.printStackTrace();
          		}
          	}
          };
          listener.start();
      }
      /**
       * Create a listener thread to listen for messages. This waits forever until it gets

       * an InterruptedException. 
       * @param listener is the JMS message and exception callback interface implementation
       * @param queue to listen on
       */
      public void listen(WSIFJMSListener listener, Queue queue)
          throws WSIFException {
          Tr.entry(this, listener, queue);
          areWeClosed();
  
          try {
              QueueReceiver qr = session.createReceiver(queue);
              qr.setMessageListener(listener);
              connection.setExceptionListener(listener);
  
              connection.start();
  
              for (int i = 1; !Thread.interrupted(); i++) {
                  Thread.yield();
                  Thread.sleep(5000);
                  System.out.println("JMSAsyncListener waiting... " + i);
              }
          } catch (JMSException je) {
          	je.printStackTrace();
              throw new WSIFException( je.getMessage() );
          } catch (InterruptedException ignored) {
              System.out.println("JMSAsyncListener Exitting");
          }
          Tr.exit();
      }
      
      public void stop() {
          listener.interrupt();
      }
  
      private void processResponse(Message msg) {
      	System.out.println( "NativeJMSRequestListener got msg:" + msg );
      	try {
      	    String op = msg.getStringProperty( "WSDL_Operation" );
      	    if ( "addEntry".equals( op ) ) {
      	    	abAddEntry( (ObjectMessage)msg );
      	    } else if ( "getAddressFromName".equals( op ) ) {
      	    	Address addr = abGetAddressFromName( (ObjectMessage)msg );
      	    	sendReply( msg, addr );
   	        } else if ( "getQuote".equals( op ) ) {
                  float value = sqGetQuote( (ObjectMessage)msg );                
                  sendReply( msg, new Float( value ) ); 
      	    } else {
      	    	System.err.println( "unknown op=" + op );
      	    } 
  
  
      	} catch (Exception ex) {
      		ex.printStackTrace();
      	}
      }
  
      private void abAddEntry(ObjectMessage msg) throws JMSException { 
         HashMap hm = (HashMap) msg.getObject();
         String name = (String)hm.get( "name" );  	
         Address addr = (Address)hm.get( "address" );  	
         ab.addEntry( name, addr );
      }
  
      private Address abGetAddressFromName(ObjectMessage msg) throws JMSException { 
         HashMap hm = (HashMap) msg.getObject();
         String name = (String)hm.get( "name" );  	
         return ab.getAddressFromName( name );
      }
      
      private float sqGetQuote(ObjectMessage msg) throws Exception { 
         HashMap hm = (HashMap) msg.getObject();
         String name = (String)hm.get( "symbol" );  	
         return sq.getQuote( name );
      }
      
      private void sendReply(Message msg, Object response) throws Exception {    
      		    Message replyMsg = session.createObjectMessage();
                  ((ObjectMessage)replyMsg).setObject((Serializable) response );
                  String s = "WSDL_PortType_NS";
         	        replyMsg.setStringProperty( s, msg.getStringProperty( s ) );
                  s = "WSDL_PortType_Local";
      	        replyMsg.setStringProperty( s, msg.getStringProperty( s ) );
                  s = "WSDL_Operation";
      	        replyMsg.setStringProperty( s, msg.getStringProperty( s ) );
                  s = "WSDL_Input";
      	        replyMsg.setStringProperty( s, msg.getStringProperty( s ) );
                  s = "WSDL_Output";
      	        replyMsg.setStringProperty( s, msg.getStringProperty( s ) );
  
          	    String replyq = ((Queue)msg.getJMSReplyTo()).getQueueName().substring( 9 );
          	    String id = msg.getJMSMessageID();
                  replyMsg.setJMSCorrelationID( id );
              
                  WSIFJMSDestination dest = new WSIFJMSDestination(
                        new WSIFJMSFinderForJndi(null,
                                     initialContextFactory, 
                                     jndiUrl,
                                     WSIFJMSFinder.STYLE_QUEUE,
                                     queueConnectionFactory,
                                     replyq )
                  );
                  dest.send( replyMsg, id );
      }
  
  }
  
  
  1.1                  xml-axis-wsif/java/test/jms/NativeJMSTest.java
  
  Index: NativeJMSTest.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "WSIF" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, 2002, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package jms;
  
  import junit.framework.*;
  
  import addressbook.wsiftypes.AddressBook;
  import addressbook.wsiftypes.Address;
  import addressbook.wsiftypes.Phone;
  import stockquote.wsifservice.StockquotePT;
  import stockquote.wsiftypes.StockQuote;
  
  import org.apache.wsif.*;
  import org.apache.wsif.util.*;
  import org.apache.wsif.base.*;
  import org.apache.wsif.util.jms.*;
  
  import javax.jms.*;
  import javax.mail.MessagingException;
  
  import org.apache.wsif.providers.jms.*;
  
  import util.TestUtilities;
  
  import com.ibm.mq.jms.MQQueueConnectionFactory;
  
  import java.util.HashMap;
  
  /**
   * Junit test to test the NativeJMSProvider
   * 
   * need to use the wsifjmssetup.bat and wsifmqset.bat 
   * 
   */
  public class NativeJMSTest extends TestCase {
  
    NativeJMSRequestListener nativeReqListener;
    
    public static String name1 = "Purdue Boilermaker";
    public static Address addr1 =
      new Address(
        1,
        "University Drive",
        "West Lafayette",
        "IN",
        47907,
        new Phone(765, "494", "4900"));
  
    public NativeJMSTest(String name) {
      super(name);
    }
  
    public static void main(String[] args) {
      junit.textui.TestRunner.run(suite());
    }
  
    public static Test suite() {
      return new TestSuite(NativeJMSTest.class);
    }
  
    public void setUp() {
      TestUtilities.setUpExtensionsAndProviders();
      try {
         nativeReqListener = 
            new NativeJMSRequestListener( 
               TestUtilities.getWsifProperty("wsif.nativejms.requestq") );
      } catch (WSIFException ex) {
      	ex.printStackTrace();
      }
    }
  
    public void tearDown() {
      if ( nativeReqListener != null ) nativeReqListener.stop();
    }
  
    public void testStockQuote() { StockQuote(); }
    //public void testAddressBook() { 
    //	 AddressBook_addEntry();
    //	 AddressBook_getAddressFromName(); 
    //}	
  
    /**
     * Query Stockquote sample
     */
    public void StockQuote() {
  
      String portType = "Stockquote";
      String portName = "NativeJmsPort";
      String operationName = "getQuote";
  
      String wsdlLocation =
          TestUtilities.getWsdlPath("java\\samples\\stockquote\\wsifservice")
              + "Stockquote.wsdl";
  
      System.out.println("\n=== StockQuote");
      try {
        WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
          WSIFService service = factory.getService(wsdlLocation, 
          	null, // serviceNS
      		null, // serviceName
      		null,
  //    		"http://www.ibm.com/namespace/wsif/samples/stockquote", // portTypeNS
    			portType); // portTypeName
  
        WSIFPort port = service.getPort(portName);
  
        WSIFOperation operation = port.createOperation(operationName);
  
        WSIFMessage context = new WSIFDefaultMessage();
        context.setObjectPart( WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo", 
                               TestUtilities.getWsifProperty("wsif.nativejms.responseq") );
        operation.setContext( context );
  
        WSIFMessage input = operation.createInputMessage();
        input.setName("GetQuoteInput");
        input.setObjectPart("symbol", "" );
  
        WSIFMessage output = operation.createOutputMessage();
        WSIFMessage fault = operation.createFaultMessage();
  
        System.out.println(
          "Executing executeRequestResponseAsync operation put: " + operationName);
  
        try {
           boolean ok = operation.executeRequestResponseOperation(input, output, fault );
           System.out.println("Sent req ok=" + ok );
           float value = ((Float)output.getObjectPart( "quote" )).floatValue();
           System.out.println("Found value = " + value);
           assertTrue( value == -1.0F );
        } catch (Exception ex) {
        	ex.printStackTrace();
        }
      } catch (Exception e) {
          System.err.println("StockQuote (" + portName + ") caught exception " + e);
          e.printStackTrace();
          assertTrue(false);
      }
  
    }
  
    /**
     * AddressBook sample 
     */
    public void AddressBook_addEntry() {
  
      String portType = "AddressBook";
      String portName = "NativeJmsPort";
      String operationName = "addEntry";
  
      String wsdlLocation =
          TestUtilities.getWsdlPath("java\\samples\\addressbook\\wsifservice")
              + "AddressBook.wsdl";
  
      System.out.println("\n=== AddressBook_addEntry");
  
      try {
        WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
          WSIFService service = factory.getService(wsdlLocation, 
          	null, // serviceNS
      		null, // serviceName
      		null,
  //    		"http://www.ibm.com/namespace/wsif/samples/ab", // portTypeNS
    			portType); // portTypeName
  
        WSIFPort port = service.getPort(portName);
  
        /**
         * add address
         */
        // invoke send request
        WSIFOperation operation = port.createOperation(operationName);
  
        WSIFMessage context = new WSIFDefaultMessage();
        context.setObjectPart( WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo", 
                               TestUtilities.getWsifProperty("wsif.nativejms.responseq") );
        operation.setContext( context );
  
        WSIFMessage input = operation.createInputMessage();
        input.setObjectPart("name", name1);
        input.setObjectPart("address", addr1); 
  
        operation.executeInputOnlyOperation(input);
        System.out.println("Put message.....: '" + name1 + "'");
      } catch (Exception e) {
        System.err.println("AddressBookTest(" + portName + ") caught exception " + e);
        e.printStackTrace();
        assertTrue(false);
      }
  
    }
  
    /**
     * AddressBook
     */
    public void AddressBook_getAddressFromName() {
  
      String portType = "AddressBook";
      String portName = "NativeJmsPort";
      String operationName = "getAddressFromName";
  
      String wsdlLocation =
          TestUtilities.getWsdlPath("java\\samples\\addressbook\\wsifservice")
              + "AddressBook.wsdl";
  
      System.out.println("\n=== AddressBook_getAddressFromName");
  
      try {
        WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
          WSIFService service = factory.getService(wsdlLocation, 
          	null, // serviceNS
      		null, // serviceName
      		null,
  //    		"http://www.ibm.com/namespace/wsif/samples/ab", // portTypeNS
    			portType); // portTypeName
  
        WSIFPort port = service.getPort(portName);
  
        String inputMsgName = "GetAddressFromNameRequest";
        String outputMsgName = "GetAddressFromNameResponse";
        WSIFOperation operation =
          port.createOperation(operationName, inputMsgName, outputMsgName);
  
        WSIFMessage context = new WSIFDefaultMessage();
        context.setObjectPart( WSIFConstants.CONTEXT_JMS_PREFIX + "JMSReplyTo", 
                               TestUtilities.getWsifProperty("wsif.nativejms.responseq") );
        operation.setContext( context );
      
        WSIFMessage input = operation.createInputMessage();
        WSIFMessage output = operation.createOutputMessage();
        WSIFMessage fault = operation.createFaultMessage();
        input.setObjectPart("name", name1);
  
        System.out.println(
          "Executing executeRequestResponseAsync operation put: "
            + operationName
            + ":"
            + inputMsgName
            + ":"
            + outputMsgName);
            
        Object correlId = null;
        try {
        boolean ok = operation.executeRequestResponseOperation(input, output, fault );
        System.out.println("Sent req ok=" + ok );
        Address addressResponse = (Address) output.getObjectPart("address");
        System.out.println("Found address = " + addressResponse);
  
        assertTrue( addr1.equals(addressResponse) );
        } catch (Exception ex) {
        	ex.printStackTrace();
        }
  
        System.out.println("output=" + output );
  
      } catch (Exception e) {
        System.err.println("AddressBook  (" + portName + ") caught exception " + e);
        e.printStackTrace();
        assertTrue(false);
      }
  
    }
  
  }
  
  

Mime
View raw message