antelder    2002/06/07 01:42:29

  Modified:    java/test/async AsyncResponseHandler.java
                        AsyncAddressBookTest.java AsyncTest.java
               java/src/org/apache/wsif/util/jms WSIFJMSDestination.java
               java/test/util wsiftestmqsetup.bat
  Added:       java/test/async Stockquote.wsdl AddressBook.wsdl
               java/src/org/apache/wsif/util/jms JMSAsyncListener.java
  Removed:     java/test/async QuoteHandler.java
               java/src/org/apache/wsif/util/jms WSIFJMSAsyncListener.java
  Log:
  Async operation changes
  
  Revision  Changes    Path
  1.2       +4 -4      xml-axis-wsif/java/test/async/AsyncResponseHandler.java
  
  Index: AsyncResponseHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/async/AsyncResponseHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AsyncResponseHandler.java 6 Jun 2002 08:28:54 -0000       1.1
  +++ AsyncResponseHandler.java 7 Jun 2002 08:42:28 -0000       1.2
  @@ -68,11 +68,11 @@
    */
   public class AsyncResponseHandler implements WSIFResponseHandler {
   
  -    // These are static because as the QuoteHandler is serialized/unserialized 
  -    // by the correlation service the testcase looses its reference to the
  -    // handler which processes the repoonse. Being static lets the testcase
  +    // These are static because as the AsyncResponseHandler is 
serialized/unserialized 
  +    // by the correlation service the testcase loses its reference to the
  +    // handler which processes the reponse. Being static lets the testcase
       // see when the response has been processed. 
  -    // Obviously only a single QuoteHandler should be used at a time!
  +    // Obviously only a single AsyncResponseHandler should be used at a time!
   
       static private boolean done;
       static private int nrReplies;
  
  
  
  1.2       +20 -27    xml-axis-wsif/java/test/async/AsyncAddressBookTest.java
  
  Index: AsyncAddressBookTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/async/AsyncAddressBookTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AsyncAddressBookTest.java 6 Jun 2002 08:28:54 -0000       1.1
  +++ AsyncAddressBookTest.java 7 Jun 2002 08:42:28 -0000       1.2
  @@ -68,6 +68,9 @@
   import org.apache.wsif.WSIFService;
   import org.apache.wsif.WSIFServiceFactory;
   import org.apache.wsif.WSIFServiceImpl;
  +import org.apache.wsif.util.jms.JMSAsyncListener;
  +import org.apache.wsif.util.WSIFDefaultCorrelationService;
  +import org.apache.wsif.util.WSIFCorrelationServiceLocator;
   import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis;
   import addressbook.wsifservice.AddressBook;
   import addressbook.wsiftypes.Address;
  @@ -81,7 +84,7 @@
    */
   public class AsyncAddressBookTest extends TestCase {
       String wsdlLocation =
  -        TestUtilities.getWsdlPath("java\\samples\\addressbook\\wsifservice")
  +        TestUtilities.getWsdlPath("java\\test\\async")
               + "AddressBook.wsdl";
   
       static String name1 = "Purdue Boilermaker";
  @@ -141,33 +144,38 @@
                   new WSIFDynamicProvider_ApacheAxis());
           }
   
  +        JMSAsyncListener listener = null;
  +
           try {
               WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
                   WSIFService service = factory.getService(wsdlLocation, null, // 
serviceNS
  -        null, // serviceName
  -        "http://wsifservice.addressbook/";, // portTypeNS
  -    "AddressBook"); // portTypeName
  +            null, // serviceName
  +            "http://wsifservice.addressbook/";, // portTypeNS
  +            "AddressBook"); // portTypeName
   
               // add some addresses
               AddressBook abStub = (AddressBook) service.getStub(portName, 
AddressBook.class);
               abStub.addEntry(name1, addr1);
               abStub.addEntry(firstName2, lastName2, addr2);
  -            Address resp1 = abStub.getAddressFromName(name1);
  -            assertTrue(new AddressUtility(addr1).equals(resp1));
  +            //Address resp1 = abStub.getAddressFromName(name1);
  +            //assertTrue(new AddressUtility(addr1).equals(resp1));
   
               // try an async call 
               String inputName = "GetAddressFromNameRequest";
               String outputName = "GetAddressFromNameResponse";
  +            
  +            listener = new JMSAsyncListener( "AsyncReplyTo" );
               AsyncResponseHandler abHandler = new AsyncResponseHandler(1); // 1 
async calls
  +
               WSIFPort port =
                   (portName == null) ? service.getPort() : service.getPort(portName);
               WSIFOperation op =
                   port.createOperation("getAddressFromName", inputName, outputName);
               WSIFMessage inMsg = op.createInputMessage();
               inMsg.setObjectPart("name", name1);
  +            inMsg.setObjectPart( "partJmsReplyTo", "AsyncReplyTo" );
               WSIFMessage outmsg = op.createOutputMessage();
               WSIFMessage faultMsg = op.createFaultMessage();
  -            //input1.setObjectPart( "symbol", "IBM" ); 
   
               try {
                   WSIFCorrelationId id = op.executeRequestResponseAsync(inMsg, 
abHandler);
  @@ -179,13 +187,13 @@
               System.out.println("async requests sent, waiting for responses...");
               int i = 900;
               while (i-- > 0 && !abHandler.isDone()) {
  -                //System.out.println( "async requests sent, waiting for responses - 
" + i );
  +                System.out.println( "waiting for async responses - " + i );
                   try {
                       Thread.sleep(3000);
                   } catch (InterruptedException ex) {
                   }
               }
  -            assertTrue(i > 0); // no responses in time
  +            assertTrue("no response from async operation!",i > 0); // no responses 
in time
   
               System.out.println("async ops completed, testing responses...");
   
  @@ -194,31 +202,16 @@
   
               Address respAddr = (Address) outputs[0].getObjectPart("address");
   
  -            assertTrue("address response", addr1.equals(respAddr));
  -
  -            //float q1 = ((Float)outputs[0].getObjectPart( "quote" )).floatValue();
  -            //float q2 = ((Float)outputs[1].getObjectPart( "quote" )).floatValue();
  -
  -            //System.out.println( "Quote1 = " + q1 + " quote2 = " + q2 );     
  -
  -            /*
  -                    AddressBook abStub=(AddressBook)service.getStub(portName, 
AddressBook.class);
  +            assertTrue("incorrect address response!", addr1.equals(respAddr));
               
  -                    abStub.addEntry(name1, addr1);
  -                    abStub.addEntry(firstName2, lastName2, addr2);
  -                    
  -                    Address resp1 = abStub.getAddressFromName (name1);
  -                    assertTrue(new AddressUtility(addr1).equals(resp1));
  -                    
  -                    Address resp2 = abStub.getAddressFromName (firstName2+" 
"+lastName2);
  -                    assertTrue(new AddressUtility(addr2).equals(resp2));
  -            */
   
           } catch (Exception e) {
               System.err.println("AddressBookTest(" + portName + ") caught exception 
" + e);
               e.printStackTrace();
               assertTrue(false);
           } finally {
  +             listener.stop();
  +            
((WSIFDefaultCorrelationService)WSIFCorrelationServiceLocator.getCorrelationService()).shutdown();
               if (protocol.equals("axis")) {
                   WSIFServiceImpl.setDynamicWSIFProvider(
                       "http://schemas.xmlsoap.org/wsdl/soap/";,
  
  
  
  1.2       +31 -17    xml-axis-wsif/java/test/async/AsyncTest.java
  
  Index: AsyncTest.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/async/AsyncTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AsyncTest.java    6 Jun 2002 08:28:54 -0000       1.1
  +++ AsyncTest.java    7 Jun 2002 08:42:28 -0000       1.2
  @@ -71,9 +71,12 @@
   import org.apache.wsif.WSIFService;
   import org.apache.wsif.WSIFServiceFactory;
   import org.apache.wsif.WSIFServiceImpl;
  +import org.apache.wsif.util.WSIFDefaultCorrelationService;
  +import org.apache.wsif.util.WSIFCorrelationServiceLocator;
   import org.apache.wsif.providers.soap.apacheaxis.WSIFDynamicProvider_ApacheAxis;
   import org.apache.wsif.stub.WSIFUtils;
   import util.TestUtilities;
  +import org.apache.wsif.util.jms.JMSAsyncListener;
   
   /**
    * Junit test to test out the Asynchronous requests.
  @@ -81,7 +84,7 @@
    */
   public class AsyncTest extends TestCase {
       String wsdlLocation =
  -        TestUtilities.getWsdlPath("java\\samples\\stockquote\\wsifservice") + 
"Stockquote.wsdl";
  +        TestUtilities.getWsdlPath("java\\test\\async") + "Stockquote.wsdl";
   
       public AsyncTest(String name) {
           super(name);
  @@ -105,7 +108,7 @@
       //public void testAxis          () { doit("SOAPPort"   ,"axis"); }
       //public void testSoap          () { doit("SOAPPort"   ,"soap"); }
       //public void testJava          () { doit("JavaPort"   ,"java"); }
  -    //public void testSoapJms       () { if (TestUtilities.areWeTesting("jms")) 
doit("SOAPJMSPort","soap"); }
  +    public void testSoapJms       () { if (TestUtilities.areWeTesting("jms")) 
doit("SOAPJMSPort","soap"); }
       public void testAxisJms() {
           if (TestUtilities.areWeTesting("jms"))
               doit("SOAPJMSPort", "axis");
  @@ -128,8 +131,6 @@
               e.printStackTrace();
               assertTrue(false);
           } finally {
  -            //((WSIFDefaultCorrelationService)WSIFCorrelationServiceLocator.
  -            //getCorrelationService()).shutdown(); 
           }
   
       }
  @@ -166,7 +167,8 @@
           WSIFService dpf = factory.getService(def, service, portType);
           WSIFPort port = (portName == null) ? dpf.getPort() : dpf.getPort(portName);
   
  -        QuoteHandler quoteHandler = new QuoteHandler(2); // 2 async calls
  +        JMSAsyncListener listener = new JMSAsyncListener( "AsyncReplyTo" );
  +        AsyncResponseHandler quoteHandler = new AsyncResponseHandler(2); // 2 async 
calls
   
           // First do an async call to get a real quote from the remote service, ie 
slow
           System.out.println(
  @@ -178,10 +180,14 @@
           WSIFMessage fault1 = operation1.createFaultMessage();
           //input1.setObjectPart( "symbol", "IBM" ); 
           input1.setObjectPart("symbol", "");
  +        
  +        input1.setObjectPart( "partJmsReplyTo", "AsyncReplyTo" );
  +
           WSIFCorrelationId id1 =
               operation1.executeRequestResponseAsync(input1, quoteHandler);
  -        System.out.println("IBM operation  id1=" + id1.getCorrelationId());
  -
  +        String id = (id1==null)? "null" : id1.getCorrelationId();
  +        System.out.println("IBM operation  id1=" + id );
  +/*
           // Now do a sync call to get a null -1 quote, ie fast
           System.out.println(
               "Executing synchronous operation for null: " + operationName);
  @@ -190,6 +196,7 @@
           WSIFMessage input3 = operation3.createInputMessage();
           WSIFMessage output3 = operation3.createOutputMessage();
           WSIFMessage fault3 = operation3.createFaultMessage();
  +        input3.setObjectPart( "partJmsReplyTo", "" );
           input3.setObjectPart("symbol", "");
           boolean ok =
               operation3.executeRequestResponseOperation(input3, output3, fault3);
  @@ -198,7 +205,7 @@
           if (!ok || q3 != -1.0F) {
               assertTrue(false);
           }
  -
  +*/
           // Now do an async call to get a null -1 quote, ie fast
           System.out.println(
               "Executing asynchronous operation 2 for null: " + operationName);
  @@ -208,6 +215,9 @@
           WSIFMessage output2 = operation2.createOutputMessage();
           WSIFMessage fault2 = operation2.createFaultMessage();
           input2.setObjectPart("symbol", "");
  +
  +        input2.setObjectPart( "partJmsReplyTo", "AsyncReplyTo" );
  +
           WSIFCorrelationId id2 =
               operation2.executeRequestResponseAsync(input2, quoteHandler);
           System.out.println("null operation id2=" + id2.getCorrelationId());
  @@ -233,15 +243,19 @@
   
           System.out.println("Quote1 = " + q1 + " quote2 = " + q2);
   
  -        /*
  -            if ( q1 == -1.0F && ( q2 > 50 && q2 < 100 ) ) {
  -               assertTrue(true);
  -            } else if ( q2 == -1.0F && ( q1 > 50 && q1 < 100 ) ) {
  -               assertTrue(true);
  -            } else {
  -               assertTrue(false);
  -            }
  -        */
  +        //if ( q1 == -1.0F && ( q2 > 50 && q2 < 100 ) ) {
  +        if ( q1 == -1.0F && ( q2 == -1.0F ) ) {
  +           assertTrue(true);
  +        //} else if ( q2 == -1.0F && ( q1 > 50 && q1 < 100 ) ) {
  +        } else if ( q2 == -1.0F && ( q1 == -1.0F ) ) {
  +           assertTrue(true);
  +        } else {
  +            assertTrue(false);
  +        }
  +
  +             listener.stop();
  +        
((WSIFDefaultCorrelationService)WSIFCorrelationServiceLocator.getCorrelationService()).shutdown();
  +
           if ("axis".equals(protocol)) {
               WSIFServiceImpl.setDynamicWSIFProvider(
                   "http://schemas.xmlsoap.org/wsdl/soap/";,
  
  
  
  1.1                  xml-axis-wsif/java/test/async/Stockquote.wsdl
  
  Index: Stockquote.wsdl
  ===================================================================
  <?xml version="1.0" ?>
  
  <definitions targetNamespace="http://wsifservice.stockquote/";
               xmlns:tns="http://wsifservice.stockquote/";
               xmlns:xsd="http://www.w3.org/1999/XMLSchema";
               xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
               xmlns:jms="http://schemas.xmlsoap.org/wsdl/jms";
               xmlns:format="http://schemas.xmlsoap.org/wsdl/formatbinding/";
               xmlns:java="http://schemas.xmlsoap.org/wsdl/java/";
               xmlns="http://schemas.xmlsoap.org/wsdl/";>
  
    <message name="GetQuoteInput">
      <part name="symbol" type="xsd:string"/>
      <part name="partJmsReplyTo" type="xsd:string"/>
    </message>
  
    <message name="GetQuoteOutput">
      <part name="quote" type="xsd:float"/>     
    </message>
  
    <portType name="StockquotePT">
      <operation name="getQuote">
        <input message="tns:GetQuoteInput"/>
        <output message="tns:GetQuoteOutput"/>
      </operation>
    </portType>
  
    <binding name="JavaBinding" type="tns:StockquotePT">
      <java:binding/>
      <format:typeMapping encoding="Java" style="Java">
        <format:typeMap typeName="xsd:string" formatType="java.lang.String" />
      </format:typeMapping>
      <operation name="getQuote">
        <java:operation
           methodName="getQuote"
           parameterOrder="symbol"
           methodType="instance" />
        <input/>
        <output/>
      </operation>
    </binding>
  
    <binding name="SOAPHttpBinding" type="tns:StockquotePT">
      <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="getQuote">
        <soap:operation soapAction="http://example.com/GetTradePrice"/>
        <input>
           <soap:body use="encoded" namespace="urn:xmltoday-delayed-quotes"
                 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
         </input>
         <output>
           <soap:body use="encoded" namespace="urn:xmltoday-delayed-quotes"
                   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
         </output>
        </operation>
     </binding>
  
    <binding name="SOAPJmsBinding" type="tns:StockquotePT">
      <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/jms"/>
      <operation name="getQuote">
        <soap:operation soapAction="http://example.com/GetTradePrice"/>
        <input>
         <jms:property name="JMSReplyTo" part="partJmsReplyTo"/>                
           <soap:body use="encoded" namespace="urn:xmltoday-delayed-quotes"
                 encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
         </input>
         <output>
           <soap:body use="encoded" namespace="urn:xmltoday-delayed-quotes"
                   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
         </output>
        </operation>
     </binding>
     
     <binding name="NativeJmsBinding" type="tns:StockquotePT">
        <jms:binding type="ObjectMessage"/>     
  
          <format:typeMapping encoding="Java">
              <format:typeMap formatType="java.lang.String" typeName="xsd:string"/>
          </format:typeMapping>
          
        
        <operation name="getQuote">
                <input>                         
                        <jms:property name="JMSReplyTo" part="partJmsReplyTo"/>        
         
                        <jms:property name="JMSPriority" part="partJmsPriority"/>
  
                        <jms:body parts="symbol" use="encoded"/> 
                </input>
                <output>
  <!--                  <jms:property name="JMSExpiration" part="expiration"/>
  -->                   
                <jms:body parts="quote" use="encoded"/>                 
                </output>       
        </operation>     
     </binding>
  
     <service name="StockquoteService">
       <documentation>Stock quote service</documentation>
       <port name="SOAPPort" binding="tns:SOAPHttpBinding">
         <soap:address location="http://localhost:8080/soap/servlet/rpcrouter"/>
       </port>
       <port name="JavaPort" binding="tns:JavaBinding">
         <java:address className="stockquote.wsiftypes.StockQuote"/>
       </port>
       <port name="SOAPJMSPort" binding="tns:SOAPJmsBinding">
         <jms:address jndiDestinationName="SoapJmsStockquoteQueue"
                      destinationStyle="queue"
                      jndiConnectionFactoryName="WSIFSampleQCF"
                      
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
                      jndiProviderURL="file://C:/JNDI-Directory"/>
      </port>
      <port name="NativeJmsPort" binding="tns:NativeJmsBinding">
        <jms:address jndiDestinationName="JmsStockQuoteQueue"
                     destinationStyle="queue"
                     jndiConnectionFactoryName="WSIFSampleQCF"
                     
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory" 
                     jndiProviderURL="file://C:/JNDI-Directory"/>
      </port>
     </service>
  
  </definitions>
  
  
  1.1                  xml-axis-wsif/java/test/async/AddressBook.wsdl
  
  Index: AddressBook.wsdl
  ===================================================================
  <?xml version="1.0" ?>
  
  <definitions targetNamespace="http://wsifservice.addressbook/";
               xmlns:tns="http://wsifservice.addressbook/";
               xmlns:typens="http://wsiftypes.addressbook/";
               xmlns:xsd="http://www.w3.org/1999/XMLSchema";
               xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
               xmlns:format="http://schemas.xmlsoap.org/wsdl/formatbinding/";
               xmlns:java="http://schemas.xmlsoap.org/wsdl/java/";
               xmlns:jms="http://schemas.xmlsoap.org/wsdl/jms/";
               xmlns="http://schemas.xmlsoap.org/wsdl/";>
  
    <!-- type defs -->
    <types>
      <xsd:schema
        targetNamespace="http://wsiftypes.addressbook/";
                  xmlns:xsd="http://www.w3.org/1999/XMLSchema";>
        <xsd:complexType name="phone">
          <xsd:element name="areaCode" type="xsd:int"/>
          <xsd:element name="exchange" type="xsd:string"/>
          <xsd:element name="number" type="xsd:string"/>
        </xsd:complexType>
  
        <xsd:complexType name="address">
          <xsd:element name="streetNum" type="xsd:int"/>
          <xsd:element name="streetName" type="xsd:string"/>
          <xsd:element name="city" type="xsd:string"/>
          <xsd:element name="state" type="xsd:string"/>
          <xsd:element name="zip" type="xsd:int"/>
          <xsd:element name="phoneNumber" type="typens:phone"/>
        </xsd:complexType>
      </xsd:schema>
    </types>
  
    <!-- message declns -->
    <message name="AddEntryWholeNameRequestMessage">
      <part name="name" type="xsd:string"/>
      <part name="address" type="typens:address"/>
    </message>
  
    <message name="AddEntryFirstAndLastNamesRequestMessage">
      <part name="firstName" type="xsd:string"/>
      <part name="lastName" type="xsd:string"/>
      <part name="address" type="typens:address"/>
    </message>
  
    <message name="GetAddressFromNameRequestMessage">
      <part name="name" type="xsd:string"/>
      <part name="partJmsReplyTo" type="xsd:string"/>
    </message>
  
    <message name="GetAddressFromNameResponseMessage">
      <part name="address" type="typens:address"/>
    </message>
  
    <!-- port type declns -->
    <portType name="AddressBook">
      <operation name="addEntry">
        <input name="AddEntryWholeNameRequest" 
message="tns:AddEntryWholeNameRequestMessage"/>
      </operation>
      <operation name="addEntry">
        <input name="AddEntryFirstAndLastNamesRequest" 
message="tns:AddEntryFirstAndLastNamesRequestMessage"/>
      </operation>
      <operation name="getAddressFromName">
        <input name="GetAddressFromNameRequest" 
message="tns:GetAddressFromNameRequestMessage"/>
        <output name="GetAddressFromNameResponse" 
message="tns:GetAddressFromNameResponseMessage"/>
      </operation>
    </portType>
  
    <!-- binding declns -->
    <binding name="SOAPHttpBinding" type="tns:AddressBook">
      <soap:binding style="rpc"
                    transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="addEntry">
        <soap:operation soapAction=""/>
        <input name="AddEntryWholeNameRequest">
          <soap:body use="encoded"
                     namespace="http://wsifservice.addressbook/";
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
      </operation>
      <operation name="addEntry">
        <soap:operation soapAction=""/>
        <input name="AddEntryFirstAndLastNamesRequest">
          <soap:body use="encoded"
                     namespace="http://wsifservice.addressbook/";
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
      </operation>
      <operation name="getAddressFromName">
        <soap:operation soapAction=""/>
        <input name="GetAddressFromNameRequest">
          <soap:body use="encoded"
                     namespace="http://wsifservice.addressbook/";
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output name="GetAddressFromNameResponse">
          <soap:body use="encoded"
                     namespace="http://wsifservice.addressbook/";
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
      </operation>
    </binding>
  
    <binding name="SOAPJmsBinding" type="tns:AddressBook">
      <soap:binding style="rpc"
                    transport="http://schemas.xmlsoap.org/soap/jms"/>
      <operation name="addEntry">
        <soap:operation soapAction=""/>
        <input name="AddEntryWholeNameRequest">
          <soap:body use="encoded"
                     namespace="http://wsifservice.addressbook/";
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
      </operation>
      <operation name="addEntry">
        <soap:operation soapAction=""/>
        <input name="AddEntryFirstAndLastNamesRequest">
          <soap:body use="encoded"
                     namespace="http://wsifservice.addressbook/";
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
      </operation>
      <operation name="getAddressFromName">
        <soap:operation soapAction=""/>
        <input name="GetAddressFromNameRequest">
        <jms:property name="JMSReplyTo" part="partJmsReplyTo"/>                 
          <soap:body use="encoded"
                     namespace="http://wsifservice.addressbook/";
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output name="GetAddressFromNameResponse">
          <soap:body use="encoded"
                     namespace="http://wsifservice.addressbook/";
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
      </operation>
    </binding>
  
    <binding name="JavaBinding" type="tns:AddressBook">
      <java:binding/>
      <format:typeMapping encoding="Java" style="Java">
        <format:typeMap typeName="typens:address" 
formatType="addressbook.wsiftypes.Address" />
        <format:typeMap typeName="xsd:string" formatType="java.lang.String" />
      </format:typeMapping>
      <operation name="addEntry">
        <java:operation
           methodName="addEntry"
           parameterOrder="name address"
           methodType="instance" />
        <input name="AddEntryWholeNameRequest"/>
      </operation>
      <operation name="addEntry">
        <java:operation
           methodName="addEntry"
           parameterOrder="firstName lastName address"
           methodType="instance" />
        <input name="AddEntryFirstAndLastNamesRequest"/>
      </operation>
      <operation name="getAddressFromName">
        <java:operation
           methodName="getAddressFromName"
           parameterOrder="name"
           methodType="instance"
           returnPart="address" />
        <input name="GetAddressFromNameRequest"/>
        <output name="GetAddressFromNameResponse"/>
      </operation>
    </binding>
    
    <binding name="NativeJmsBinding" type="tns:AddressBook">
        <jms:binding type="TextMessage"/>
        <!-- executeInputOnlyOperation(WSIFMessage) -->
        <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"/>
                <output name="GetAddressFromNameResponse"/>
        </operation>   
    </binding>
  
    <!-- service decln -->
    <service name="AddressBookService">
      <port name="SOAPPort" binding="tns:SOAPHttpBinding">
        <soap:address location="http://localhost:8080/soap/servlet/rpcrouter"/>
      </port>
      <port name="JavaPort" binding="tns:JavaBinding">
        <java:address className="addressbook.wsiftypes.AddressBook"/>
      </port>
      <port name="SOAPJMSPort" binding="tns:SOAPJmsBinding">
        <jms:address jndiDestinationName="SoapJmsAddressBookQueue"
                     destinationStyle="queue"
                     jndiConnectionFactoryName="WSIFSampleQCF"
                     initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
                     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"
                     destinationStyle="queue"
                     jndiConnectionFactoryName="WSIFSampleQCF"
                     
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory" 
                     jndiProviderURL="file://C:/JNDI-Directory"/>
      </port>
    </service>
  
  </definitions>
  
  
  1.2       +4 -21     
xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSDestination.java
  
  Index: WSIFJMSDestination.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSDestination.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WSIFJMSDestination.java   6 Jun 2002 08:28:52 -0000       1.1
  +++ WSIFJMSDestination.java   7 Jun 2002 08:42:29 -0000       1.2
  @@ -91,7 +91,6 @@
       protected QueueSender sender = null;
   
       protected boolean asyncMode = false;
  -    protected WSIFJMSAsyncListener asyncListener = null;
       protected Queue syncTempQueue = null;
   
       protected WSIFJMSProperties inProps;
  @@ -296,8 +295,6 @@
               sender.send(msg);
               msgId = msg.getJMSMessageID();
   
  -            if (asyncMode)
  -                asyncListener.startListening(msgId);
           } catch (JMSException je) {
               throw WSIFJMSConstants.ToWsifException(je);
           } finally { // If properties were set, trash the sender so we get the 
default props next time.
  @@ -391,16 +388,11 @@
           try {
               if (syncTempQueue == null)
                   syncTempQueue = session.createTemporaryQueue();
  -
  -            if (asyncMode)
  -                tmp = asyncListener.getReadTempQ();
  -            else
  -                tmp = syncTempQueue;
           } catch (JMSException je) {
               throw WSIFJMSConstants.ToWsifException(je);
           }
   
  -        readQ = tmp; // So we don't overwrite readQ if there was an error.
  +        readQ = syncTempQueue; // So we don't overwrite readQ if there was an error.
           replyToName = null;
           Tr.exit();
       }
  @@ -428,8 +420,6 @@
           readQ = finder.findQueue(replyTo);
   
           replyToName = replyTo;
  -        if (asyncMode)
  -            asyncListener.setReadQ(readQ);
           Tr.exit();
       }
   
  @@ -444,15 +434,9 @@
       public void setAsyncMode(boolean b) throws WSIFException {
           Tr.entry(this, b);
           areWeClosed();
  -        if (asyncMode != b)
  -            try {
  -                asyncMode = b;
  -
  -                if (asyncMode && asyncListener == null)
  -                    asyncListener = new WSIFJMSAsyncListener(finder.getFactory());
  -            } catch (JMSException je) {
  -                throw WSIFJMSConstants.ToWsifException(je);
  -            }
  +        if (asyncMode != b) {
  +           asyncMode = b;
  +        }
           Tr.exit();
       }
   
  @@ -573,7 +557,6 @@
               buff += " writeQ: " + writeQ;
               buff += " sender: " + sender;
               buff += " asyncMode: " + asyncMode;
  -            buff += " asyncListener: " + asyncListener;
               buff += " syncTempQueue: " + syncTempQueue;
               buff += " inProps: " + inProps;
               buff += " outProps: " + outProps;
  
  
  
  1.1                  
xml-axis-wsif/java/src/org/apache/wsif/util/jms/JMSAsyncListener.java
  
  Index: JMSAsyncListener.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 [EMAIL PROTECTED]
   *
   * 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 java.util.ArrayList;
  import java.util.Arrays;
  
  import javax.jms.JMSException;
  import javax.jms.Message;
  import javax.jms.Queue;
  import javax.jms.QueueReceiver;
  import org.apache.wsif.WSIFException;
  import org.apache.wsif.logging.Tr;
  import org.apache.wsif.util.jms.*;
  import org.apache.wsif.util.*;
  import org.apache.wsif.*;
  import org.apache.wsif.util.jms.WSIFJMSCorrelationId;
  import java.io.Serializable;
  /**
   * A simple JMS listener which can be used to test async operations 
   * @author ant elder <[EMAIL PROTECTED]>
   */
  public class JMSAsyncListener 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;
      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 JMSAsyncListener(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) {
              throw WSIFJMSConstants.ToWsifException(je);
          } catch (InterruptedException ignored) {
              System.out.println("JMSAsyncListener Exitting");
          }
          Tr.exit();
      }
      
      private void processResponse(Message msg) {
          Serializable so;
        try {
                   System.out.println( "WSIFJmsAsyncListener.processResponse called" );
                   WSIFCorrelationService cs = 
              WSIFCorrelationServiceLocator.getCorrelationService();
             WSIFCorrelationId cid = new WSIFJMSCorrelationId( 
msg.getJMSCorrelationID() );
             synchronized( cs ) { 
                so = cs.get( cid ); 
             }
             if ( so != null && so instanceof WSIFOperation ) {      
              cs.remove( cid ); 
                ((WSIFOperation) so).fireAsyncResponse( msg );
             }
        } catch (Exception ex) {
                ex.printStackTrace();
        }
      }
  
      public void stop() {
          listener.interrupt();
      }
  
  }
  
  
  1.2       +1 -0      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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- wsiftestmqsetup.bat       6 Jun 2002 08:29:00 -0000       1.1
  +++ wsiftestmqsetup.bat       7 Jun 2002 08:42:29 -0000       1.2
  @@ -9,6 +9,7 @@
   echo + Creating script for object creation within MQ
   
   echo DEFINE QLOCAL('AddressBookReplyTo') 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
  
  
  


Reply via email to