axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From barre...@apache.org
Subject svn commit: r656721 - in /webservices/axis2/trunk/java/modules: jaxws-integration/test/org/apache/axis2/jaxws/sample/ kernel/src/org/apache/axis2/description/ kernel/src/org/apache/axis2/engine/
Date Thu, 15 May 2008 16:24:58 GMT
Author: barrettj
Date: Thu May 15 09:24:57 2008
New Revision: 656721

URL: http://svn.apache.org/viewvc?rev=656721&view=rev
Log:
Synchronous API operations over async-on-the-wire MEP do not get notified of error conditions
and timeout.  SyncCallBack implementation of AxisCallback 
needs to be notified of onComplete() after onError().  Added test to verify behavior.

Modified:
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/RuntimeExceptionsAsyncMepTest.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/RuntimeExceptionsAsyncMepTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/RuntimeExceptionsAsyncMepTest.java?rev=656721&r1=656720&r2=656721&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/RuntimeExceptionsAsyncMepTest.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/RuntimeExceptionsAsyncMepTest.java
Thu May 15 09:24:57 2008
@@ -18,6 +18,7 @@
  */
 package org.apache.axis2.jaxws.sample;
 
+import java.net.ConnectException;
 import java.net.UnknownHostException;
 import java.util.Map;
 import java.util.concurrent.ExecutionException;
@@ -50,12 +51,19 @@
 public class RuntimeExceptionsAsyncMepTest extends AbstractTestCase {
 
     private static final String DOCLITWR_ASYNC_ENDPOINT = "http://localhost:6060/axis2/services/AsyncService2.DocLitWrappedPortImplPort";
-
+    private static final String CONNECT_EXCEPTION_ENDPOINT = "http://localhost:6061/axis2/services/AsyncService2.DocLitWrappedPortImplPort";
     static final String CONNECT_404_ENDPOINT = DOCLITWR_ASYNC_ENDPOINT // Constants.DOCLITWR_ASYNC_ENDPOINT
             + "/DoesNotExist";
 
     static final String HOST_NOT_FOUND_ENDPOINT = "http://this.endpoint.does.not.exist/nope";
 
+    /*
+     * For async-on-the-wire exchanges, we need to enable WS-Addressing and get a transport
+     * listener setup to receive the inbound request from the service-provider which contains
the
+     * response.  We only need to do that one time for all the tests.
+     */
+    static boolean listenerAlreadySetup = false;
+
     public static Test suite() {
         Test test = getTestSetup(new TestSuite(
                 RuntimeExceptionsAsyncMepTest.class), null,
@@ -75,6 +83,33 @@
 
         return port;
     }
+    /**
+     * @testStrategy Invoke the proxy with sync method, specifying that it should use
+     *               the async-on-the-wire MEP.  The proxy enpdoint specifies a port that
+     *               does not exist.  Verify that the connection exception is received
+     *               by the client.
+     */
+  
+    public void testAsyncCallback_asyncWire_ConnectException() throws Exception {
+        setupAddressingAndListener();
+        
+        AsyncPort port = getPort();
+        Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
+        rc.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, CONNECT_EXCEPTION_ENDPOINT);
+        rc.put("org.apache.axis2.jaxws.use.async.mep", Boolean.TRUE);
+
+        try {
+            String resp = port.throwException(ExceptionTypeEnum.WSE);
+            fail("Did not get an exception as expected");
+        } catch (Exception ee) {
+            assertTrue("ExecutionException.getCause should be an instance of WebServiceException",
+                       ee instanceof WebServiceException);
+            assertTrue("Didn't get a cause within the WebServiceException",
+                       ee.getCause() != null);
+            assertTrue("Cause was not ConnectionException as expected", 
+                       ee.getCause() instanceof ConnectException);
+        }
+    }
 
     /**
      * @testStrategy Invoke the proxy with async-polling method, the proxy is
@@ -317,19 +352,7 @@
      */
     public void testAsyncCallback_asyncMEP_asyncWire_Addressing_WebServiceException()
             throws Exception {
-
-        // we want to use addressing on the client side
-        String repopath = System.getProperty("basedir", ".") + "/"
-                + System.getProperty("build.repository");
-        String axis2xmlpath = System.getProperty("basedir", ".")
-                + "/test-resources/axis2_addressing.xml";
-        FileSystemConfigurator configurator = new FileSystemConfigurator(
-                repopath, axis2xmlpath);
-        ClientConfigurationFactory factory = new ClientConfigurationFactory(
-                configurator);
-        MetadataFactoryRegistry.setFactory(ClientConfigurationFactory.class,
-                factory);
-
+        setupAddressingAndListener();
         AsyncPort port = getPort();
 
         Map<String, Object> rc = ((BindingProvider) port).getRequestContext();
@@ -395,5 +418,29 @@
 
         return found;
     }
+    
+    
+    /**
+     * Setup to use addressing and to start a listener to receive inbound async responses
+     * from the service-provider.
+     * 
+     * @throws Exception
+     */
+    synchronized private void setupAddressingAndListener() throws Exception {
+        if (!listenerAlreadySetup) {
+            listenerAlreadySetup = true;
+            // we want to use addressing on the client side
+            String repopath = System.getProperty("basedir", ".") + "/"
+                    + System.getProperty("build.repository");
+            String axis2xmlpath = System.getProperty("basedir", ".")
+                    + "/test-resources/axis2_addressing.xml";
+            FileSystemConfigurator configurator = new FileSystemConfigurator(
+                    repopath, axis2xmlpath);
+            ClientConfigurationFactory factory = new ClientConfigurationFactory(
+                    configurator);
+            MetadataFactoryRegistry.setFactory(ClientConfigurationFactory.class,
+                    factory);
+        }
+    }
 
 }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java?rev=656721&r1=656720&r2=656721&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java
Thu May 15 09:24:57 2008
@@ -450,7 +450,7 @@
                         AxisFault fault = new AxisFault(body.getFault(), response);
                         if (callback != null) {
                             callback.onError(fault);
-                        } else {
+                        } else if (axisCallback != null) {
                             axisCallback.onError(fault);
                         }
 
@@ -458,7 +458,7 @@
                         if (callback != null) {
                             AsyncResult asyncResult = new AsyncResult(response);
                             callback.onComplete(asyncResult);
-                        } else {
+                        } else if (axisCallback != null) {
                             axisCallback.onMessage(response);
                         }
 
@@ -468,13 +468,15 @@
             } catch (Exception e) {
                 if (callback != null) {
                     callback.onError(e);
-                } else {
+                } else if (axisCallback != null) {
                     axisCallback.onError(e);
                 }
 
             } finally {
                 if (callback != null) {
                     callback.setComplete(true);
+                }else if (axisCallback != null) {
+                    axisCallback.onComplete();
                 }
             }
         }

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java?rev=656721&r1=656720&r2=656721&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
Thu May 15 09:24:57 2008
@@ -639,11 +639,20 @@
                             Object callback = ((CallbackReceiver) msgReceiver)
                                     .lookupCallback(msgctx.getMessageID());
                             if (callback == null) return; // TODO: should we log this??
-
+                            
                             if (callback instanceof Callback) {
+                                // Instances of Callback only expect onComplete to be called
+                                // for a successful MEP.  Errors are reported through the
+                                // Async Response object, which the Callback implementations

+                                // all use.
                                 ((Callback)callback).onError(e);
                             } else {
+                                // The AxisCallback (which is OutInAxisOperationClient$SyncCallBack
+                                // used to support async-on-the-wire under a synchronous
API 
+                                // operation) need to be told the MEP is complete after being
told
+                                // of the error.
                                 ((AxisCallback)callback).onError(e);
+                                ((AxisCallback)callback).onComplete();
                             }
                         }
                     }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message