You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ng...@apache.org on 2006/11/06 06:55:29 UTC

svn commit: r471644 [1/2] - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/client/ src/org/apache/axis2/jaxws/client/async/ src/org/apache/axis2/jaxws/client/proxy/ src/org/apache/axis2/jaxws/core/ src/org/apache/axis2/jaxws...

Author: ngallardo
Date: Sun Nov  5 21:55:26 2006
New Revision: 471644

URL: http://svn.apache.org/viewvc?view=rev&rev=471644
Log:
AXIS2-1476

A refactoring of the async invocation APIs along with adding in support for the async polling mechanism in JAX-WS.

Added:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/CallbackHandler.java
      - copied, changed from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/CallbackHandler.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DOMSourceDispatch.java
      - copied, changed from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DOMSourceDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestConstants.java
      - copied, changed from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DispatchTestConstants.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestSuite.java
      - copied, changed from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DispatchTestSuite.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBCallbackHandler.java
      - copied, changed from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBCallbackHandler.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBDispatch.java
      - copied, changed from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBSourceDispatch.java
      - copied, changed from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBSourceDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/SAXSourceDispatch.java
      - copied, changed from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/SAXSourceDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/SOAPMessageDispatch.java
      - copied, changed from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/SOAPMessageDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/StreamSourceDispatch.java
      - copied, changed from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/StreamSourceDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/StringDispatch.java
      - copied, changed from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/StringDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/AsyncCallback.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/ProxyNonWrappedTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/proxy/ProxyTests.java
Removed:
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/CallbackHandler.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DOMSourceDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DispatchTestConstants.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DispatchTestSuite.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBCallbackHandler.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBSourceDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/SAXSourceDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/SOAPMessageDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/StreamSourceDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/StringDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/proxy/
Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/ParamTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/SOAP12Dispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/source/SourceProvider.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/provider/sourcemsg/SourceMessageProvider.java

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java?view=diff&rev=471644&r1=471643&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/BaseDispatch.java Sun Nov  5 21:55:26 2006
@@ -30,6 +30,7 @@
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.jaxws.BindingProvider;
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.client.async.AsyncResponse;
 import org.apache.axis2.jaxws.core.InvocationContext;
 import org.apache.axis2.jaxws.core.InvocationContextFactory;
 import org.apache.axis2.jaxws.core.MessageContext;
@@ -89,7 +90,7 @@
      * 
      * @return a configured AsyncListener instance
      */
-    protected abstract AsyncListener createAsyncListener();
+    protected abstract AsyncResponse createAsyncResponseListener();
     
     public Object invoke(Object obj) throws WebServiceException {
         if (log.isDebugEnabled()) { 
@@ -234,8 +235,8 @@
         invocationContext.setExecutor(e);
         
         // Create the AsyncListener that is to be used by the InvocationController.
-        AsyncListener listener = createAsyncListener();
-        invocationContext.setAsyncListener(listener);
+        AsyncResponse listener = createAsyncResponseListener();
+        invocationContext.setAsyncResponseListener(listener);
         
         // Send the request using the InvocationController
         Future<?> asyncResponse = ic.invokeAsync(invocationContext, asynchandler);
@@ -254,7 +255,58 @@
     }
   
     public Response invokeAsync(Object obj)throws WebServiceException{
-        throw new UnsupportedOperationException("Async (polling) invocations are not yet supported.");
+        if (log.isDebugEnabled()) { 
+            log.debug("Entered asynchronous (polling) invocation: BaseDispatch.invokeAsync()");
+        }
+        
+        // Create the InvocationContext instance for this request/response flow.
+        InvocationContext invocationContext = InvocationContextFactory.createInvocationContext(null);
+        invocationContext.setServiceClient(serviceClient);
+        
+        // Create the MessageContext to hold the actual request message and its
+        // associated properties
+        MessageContext requestMsgCtx = new MessageContext();
+        invocationContext.setRequestMessageContext(requestMsgCtx);
+        
+        Message requestMsg = null;
+        if (isValidInvocationParam(obj)) {
+            requestMsg = createMessageFromValue(obj);
+        }
+        else {
+            throw ExceptionFactory.makeWebServiceException("dispatchInvalidParam");
+        }
+        
+        setupMessageProperties(requestMsg);
+        requestMsgCtx.setMessage(requestMsg);
+        
+        // Copy the properties from the request context into the MessageContext
+        requestMsgCtx.getProperties().putAll(requestContext);
+
+        // Setup the Executor that will be used to drive async responses back to 
+        // the client.
+        // FIXME: We shouldn't be getting this from the ServiceDelegate, rather each 
+        // Dispatch object should have it's own.
+        Executor e = serviceDelegate.getExecutor();
+        invocationContext.setExecutor(e);
+        
+        // Create the AsyncListener that is to be used by the InvocationController.
+        AsyncResponse listener = createAsyncResponseListener();
+        invocationContext.setAsyncResponseListener(listener);
+        
+        // Send the request using the InvocationController
+        Response asyncResponse = ic.invokeAsync(invocationContext);
+        
+        //Check to see if we need to maintain session state
+        if (requestMsgCtx.isMaintainSession()) {
+            //TODO: Need to figure out a cleaner way to make this call. 
+            setupSessionContext(invocationContext.getServiceClient().getServiceContext().getProperties());
+        }
+        
+        if (log.isDebugEnabled()) {
+            log.debug("Asynchronous (polling) invocation sent: BaseDispatch.invokeAsync()");
+        }
+        
+        return asyncResponse;
     }
     
     //FIXME: This needs to be moved up to the BindingProvider and should actually
@@ -323,7 +375,7 @@
      * a violation.
      */
     private boolean isValidInvocationParam(Object object){
-    	String bindingId = port.getBindingID();
+        String bindingId = port.getBindingID();
         
         // If no bindingId was found, use the default.
         if (bindingId == null) {

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java?view=diff&rev=471644&r1=471643&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatch.java Sun Nov  5 21:55:26 2006
@@ -19,6 +19,7 @@
 import javax.xml.bind.JAXBContext;
 
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.client.async.AsyncResponse;
 import org.apache.axis2.jaxws.handler.PortData;
 import org.apache.axis2.jaxws.impl.AsyncListener;
 import org.apache.axis2.jaxws.marshaller.ClassUtils;
@@ -46,7 +47,7 @@
         jaxbContext = jbc;
     }
     
-    public AsyncListener createAsyncListener() {
+    public AsyncResponse createAsyncResponseListener() {
         JAXBDispatchAsyncListener listener = new JAXBDispatchAsyncListener();
         listener.setJAXBContext(jaxbContext);
         listener.setMode(mode);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java?view=diff&rev=471644&r1=471643&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/JAXBDispatchAsyncListener.java Sun Nov  5 21:55:26 2006
@@ -20,8 +20,8 @@
 import javax.xml.ws.Service.Mode;
 
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.client.async.AsyncResponse;
 import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.impl.AsyncListener;
 import org.apache.axis2.jaxws.message.Block;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.databinding.JAXBBlockContext;
@@ -33,7 +33,7 @@
  * {@link org.apache.axis2.jaxws.impl.AsyncListener} class to provide JAX-B
  * specific function when processing an async response.
  */
-public class JAXBDispatchAsyncListener extends AsyncListener {
+public class JAXBDispatchAsyncListener extends AsyncResponse {
     
     private Mode mode;
     private JAXBContext jaxbContext;

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatch.java?view=diff&rev=471644&r1=471643&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatch.java Sun Nov  5 21:55:26 2006
@@ -24,8 +24,8 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.client.async.AsyncResponse;
 import org.apache.axis2.jaxws.handler.PortData;
-import org.apache.axis2.jaxws.impl.AsyncListener;
 import org.apache.axis2.jaxws.message.Block;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.Protocol;
@@ -56,7 +56,7 @@
         type = c;
     }
     
-    public AsyncListener createAsyncListener() {
+    public AsyncResponse createAsyncResponseListener() {
         if (log.isDebugEnabled()) {
             log.debug("Creating new AsyncListener for XMLDispatch");
         }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java?view=diff&rev=471644&r1=471643&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/XMLDispatchAsyncListener.java Sun Nov  5 21:55:26 2006
@@ -5,8 +5,8 @@
 import javax.xml.ws.Service.Mode;
 
 import org.apache.axiom.om.OMElement;
+import org.apache.axis2.jaxws.client.async.AsyncResponse;
 import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.impl.AsyncListener;
 import org.apache.axis2.jaxws.message.Block;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.MessageException;
@@ -20,7 +20,7 @@
  * {@link org.apache.axis2.jaxws.impl.AsyncListener} class to provide 
  * proper deserialization into the target format (XML String or Source).
  */
-public class XMLDispatchAsyncListener extends AsyncListener {
+public class XMLDispatchAsyncListener extends AsyncResponse {
 
     private Mode mode;
     private Class type;

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java?view=auto&rev=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java Sun Nov  5 21:55:26 2006
@@ -0,0 +1,135 @@
+package org.apache.axis2.jaxws.client.async;
+
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceException;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.message.Message;
+import org.apache.axis2.jaxws.message.MessageException;
+import org.apache.axis2.jaxws.util.Constants;
+import org.apache.axis2.util.ThreadContextMigratorUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class AsyncResponse extends Callback implements Response {
+
+    private static final Log log = LogFactory.getLog(AsyncResponse.class);
+    
+    private boolean done;
+    private boolean cancelled;
+    private Object responseObj;
+    private MessageContext response;
+    private Map<String, Object> responseContext;
+    private Throwable fault;
+    
+    //-------------------------------------
+    // org.apache.axis2.client.async.Callback APIs
+    //-------------------------------------
+    @Override
+    public void onComplete(AsyncResult result) {
+        try {
+            org.apache.axis2.context.MessageContext axisResponse = result.getResponseMessageContext();
+            response = new MessageContext(axisResponse);
+            
+            //REVIEW: Are we on the final thread of execution here or does this get handed off to the executor?
+            // TODO: Remove workaround for WS-Addressing running in thin client (non-server) environment
+            try {
+                ThreadContextMigratorUtil.performMigrationToThread(Constants.THREAD_CONTEXT_MIGRATOR_LIST_ID, axisResponse);
+            }
+            catch (Throwable t) {
+                fault = t;
+                
+                if (log.isDebugEnabled()) {
+                    log.debug("JAX-WS AxisCallback caught throwable from ThreadContextMigratorUtil " + t);
+                    log.debug("...caused by " + t.getCause());
+                }
+                t.printStackTrace();
+            }
+        } catch (MessageException e) {
+            fault = e;
+            e.printStackTrace();
+        }
+        
+        done = true;
+    }
+
+    @Override
+    public void onError(Exception e) {
+        fault = e;
+    }
+    
+    //-------------------------------------
+    // javax.xml.ws.Response APIs
+    //-------------------------------------
+    
+    public boolean cancel(boolean mayInterruptIfRunning) {
+        return false;
+    }
+
+    public Object get() throws InterruptedException, ExecutionException {
+        if (hasFault()) {
+            throw new ExecutionException(fault);
+        }
+        if (response == null) {
+            WebServiceException wse = new WebServiceException("null response");
+            throw new ExecutionException(wse);
+        }
+        
+        // TODO: Check the type of the object to make sure it corresponds with
+        // the parameterized generic type.
+        if (responseObj == null) {
+            responseObj = getResponseValueObject(response);
+        }
+        
+        return responseObj;
+    }
+
+    public Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
+        return null;
+    }
+
+    public boolean isCancelled() {
+        return cancelled;
+    }
+
+    public boolean isDone() {
+        return done;
+    }
+
+    public Map getContext() {
+        return responseContext;
+    }
+    
+    public boolean hasFault() {
+        if (fault != null)
+            return true;
+        else
+            return false;
+    }
+    
+    /**
+     * A default implementation of this method that returns the contents
+     * of the message in the form of an XML String.  Subclasses should override
+     * this to convert the response message into whatever format they require.
+     * @param msg
+     */
+    protected Object getResponseValueObject(MessageContext mc) {
+        try {
+            Message msg = mc.getMessage();
+            OMElement om = msg.getAsOMElement();
+            return om.toString();
+        } catch (MessageException e) {
+            throw ExceptionFactory.makeWebServiceException(e);
+        }
+    }
+
+}

Added: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java?view=auto&rev=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java Sun Nov  5 21:55:26 2006
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axis2.jaxws.client.async;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Future;
+import java.util.concurrent.FutureTask;
+
+import javax.xml.ws.AsyncHandler;
+
+import org.apache.axis2.client.async.AsyncResult;
+import org.apache.axis2.client.async.Callback;
+
+public class CallbackFuture extends Callback {
+    
+    private CallbackFutureTask cft;
+    private Executor executor;
+    private FutureTask task;
+   
+    public CallbackFuture(AsyncResponse response, AsyncHandler handler, Executor exec) {
+        cft = new CallbackFutureTask(response, handler);
+        task = new FutureTask(cft);
+        executor = exec;
+    }
+    
+    public Future<?> getFutureTask() {
+        return (Future<?>) task;
+    }
+    
+    @Override
+    public void onComplete(AsyncResult result) {
+        cft.setResult(result);
+        execute();
+    }
+
+    @Override
+    public void onError(Exception e) {
+         cft.setError(e);
+         execute();
+    }
+    
+    private void execute() {
+        if (executor != null) {
+            executor.execute(task);
+        }
+    }    
+}
+
+class CallbackFutureTask implements Callable {
+    
+    AsyncResponse response;
+    AsyncResult result;
+    AsyncHandler handler;
+    Exception error;
+    
+    CallbackFutureTask(AsyncResponse r, AsyncHandler h) {
+        response = r;
+        handler = h;
+    }
+    
+    void setResult(AsyncResult r) {
+        result = r;
+    }
+    
+    void setError(Exception e) {
+        error = e;
+    }
+    
+    public Object call() throws Exception {
+        if (result != null) {
+            response.onComplete(result);    
+        }
+        else if (error != null) {
+            response.onError(error);
+        }
+        
+        handler.handleResponse(response);        
+        return null;
+    }
+}
\ No newline at end of file

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java?view=diff&rev=471644&r1=471643&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java Sun Nov  5 21:55:26 2006
@@ -21,7 +21,6 @@
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
-import java.util.Map;
 import java.util.concurrent.Future;
 
 import javax.jws.soap.SOAPBinding;
@@ -33,6 +32,7 @@
 
 import org.apache.axis2.jaxws.BindingProvider;
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.client.async.AsyncResponse;
 import org.apache.axis2.jaxws.core.InvocationContext;
 import org.apache.axis2.jaxws.core.InvocationContextFactory;
 import org.apache.axis2.jaxws.core.MessageContext;
@@ -44,7 +44,6 @@
 import org.apache.axis2.jaxws.description.ServiceDescriptionWSDL;
 import org.apache.axis2.jaxws.handler.PortData;
 import org.apache.axis2.jaxws.i18n.Messages;
-import org.apache.axis2.jaxws.impl.AsyncListener;
 import org.apache.axis2.jaxws.marshaller.MethodMarshaller;
 import org.apache.axis2.jaxws.marshaller.factory.MethodMarshallerFactory;
 import org.apache.axis2.jaxws.message.Message;
@@ -52,7 +51,6 @@
 import org.apache.axis2.jaxws.registry.FactoryRegistry;
 import org.apache.axis2.jaxws.spi.ServiceDelegate;
 import org.apache.axis2.jaxws.util.WSDLWrapper;
-import org.apache.axis2.transport.http.HTTPConstants;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -214,8 +212,8 @@
 			if(asyncHandler == null){
 				throw ExceptionFactory.makeWebServiceException("AynchHandler null for Async callback, Invalid AsyncHandler callback Object");
 			}
-			AsyncListener listener = createProxyListener(args);
-			requestIC.setAsyncListener(listener);
+			AsyncResponse listener = createProxyListener(args);
+			requestIC.setAsyncResponseListener(listener);
 			requestIC.setExecutor(delegate.getExecutor());
 				        
 	        Future<?> future = controller.invokeAsync(requestIC, asyncHandler);
@@ -233,8 +231,8 @@
 			if(log.isDebugEnabled()){
 				log.debug("Async Polling");
 			}
-			AsyncListener listener = createProxyListener(args);
-			requestIC.setAsyncListener(listener);
+			AsyncResponse listener = createProxyListener(args);
+			requestIC.setAsyncResponseListener(listener);
 			requestIC.setExecutor(delegate.getExecutor());
 	        
 			Response response = controller.invokeAsync(requestIC);
@@ -264,7 +262,7 @@
 		return null;
 	}
 	
-	private AsyncListener createProxyListener(Object[] args){
+	private AsyncResponse createProxyListener(Object[] args){
 		ProxyAsyncListener listener = new ProxyAsyncListener();
 		listener.setHandler(this);
 		listener.setInputArgs(args);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java?view=diff&rev=471644&r1=471643&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/ProxyAsyncListener.java Sun Nov  5 21:55:26 2006
@@ -16,10 +16,9 @@
  */
 package org.apache.axis2.jaxws.client.proxy;
 
-import org.apache.axis2.jaxws.AxisCallback;
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.client.async.AsyncResponse;
 import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.impl.AsyncListener;
 
 
 /**
@@ -28,7 +27,7 @@
  * The Class will return the data type associated with Response<T> Generic Class.
  * Example Response<Float> will return a Float object to client on Response.get() call.
  */
-public class ProxyAsyncListener extends AsyncListener {
+public class ProxyAsyncListener extends AsyncResponse {
 
 	JAXWSProxyHandler handler = null;
 	Object[] inputArgs = null;
@@ -48,23 +47,15 @@
 		this.inputArgs = inputArgs;
 	}
 
-	/**
-	 * @param cb
-	 */
-	public ProxyAsyncListener(AxisCallback cb) {
-		super(cb);
-		
+	public Object getResponseValueObject(MessageContext mc) {
+	    try{
+	        //I will delegate the request to create respose to proxyHandler 
+            //since it has all the logic written to create response for Sync 
+            //and oneWay.
+	        return handler.createResponse(null,inputArgs, mc);
+	    }
+	    catch (Throwable e) {
+	        throw ExceptionFactory.makeWebServiceException(e);
+	    }
 	}
-	
-	 public Object getResponseValueObject(MessageContext mc){
-		 
-		 try{
-			 //I will delegate the request to create respose to proxyHandler since it has all the logic written to create response for Sync and oneWay.
-			  return handler.createResponse(null,inputArgs, mc);
-		 }catch(Throwable e){
-			throw ExceptionFactory.makeWebServiceException(e);
-		 }
-	 }
-
-	 
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java?view=diff&rev=471644&r1=471643&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java Sun Nov  5 21:55:26 2006
@@ -22,7 +22,7 @@
 import javax.xml.ws.handler.Handler;
 
 import org.apache.axis2.client.ServiceClient;
-import org.apache.axis2.jaxws.impl.AsyncListener;
+import org.apache.axis2.jaxws.client.async.AsyncResponse;
 
 /**
  * The <code>InvocationContext</code> encapsulates all of the information 
@@ -47,9 +47,9 @@
     
     public void setExecutor(Executor e);
     
-    public AsyncListener getAsyncListener();
+    public AsyncResponse getAsyncResponseListener();
     
-    public void setAsyncListener(AsyncListener al);
+    public void setAsyncResponseListener(AsyncResponse al);
     
     //FIXME: This is temporary.
     public void setServiceClient(ServiceClient client);

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java?view=diff&rev=471644&r1=471643&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java Sun Nov  5 21:55:26 2006
@@ -22,6 +22,7 @@
 import javax.xml.ws.handler.Handler;
 
 import org.apache.axis2.client.ServiceClient;
+import org.apache.axis2.jaxws.client.async.AsyncResponse;
 import org.apache.axis2.jaxws.impl.AsyncListener;
 
 /**
@@ -35,7 +36,7 @@
     private MessageContext requestMsgCtx;
     private MessageContext responseMsgCtx;
     private Executor executor;
-    private AsyncListener asyncListener;
+    private AsyncResponse asyncResponse;
     
     private ServiceClient serviceClient; //FIXME: This is temporary
     
@@ -101,12 +102,12 @@
         executor = e;
     }
     
-    public AsyncListener getAsyncListener() {
-        return asyncListener;
+    public AsyncResponse getAsyncResponseListener() {
+        return asyncResponse;
     }
     
-    public void setAsyncListener(AsyncListener al) {
-        asyncListener = al;
+    public void setAsyncResponseListener(AsyncResponse ar) {
+        asyncResponse = ar;
     }
     
     // FIXME: This is temporary

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java?view=diff&rev=471644&r1=471643&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java Sun Nov  5 21:55:26 2006
@@ -22,8 +22,6 @@
 import java.net.URL;
 import java.util.Iterator;
 import java.util.Map;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 
 import javax.xml.namespace.QName;
@@ -43,15 +41,14 @@
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.description.AxisOperation;
 import org.apache.axis2.engine.MessageReceiver;
-import org.apache.axis2.jaxws.AxisCallback;
 import org.apache.axis2.jaxws.BindingProvider;
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.client.async.AsyncResponse;
+import org.apache.axis2.jaxws.client.async.CallbackFuture;
 import org.apache.axis2.jaxws.core.InvocationContext;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.description.OperationDescription;
 import org.apache.axis2.jaxws.i18n.Messages;
-import org.apache.axis2.jaxws.impl.AsyncListener;
-import org.apache.axis2.jaxws.impl.AsyncListenerWrapper;
 import org.apache.axis2.jaxws.marshaller.ClassUtils;
 import org.apache.axis2.jaxws.message.Message;
 import org.apache.axis2.jaxws.message.MessageException;
@@ -227,68 +224,34 @@
         OperationClient opClient = createOperationClient(svcClient, operationName);
         
         initOperationClient(opClient, request);
-        
-        org.apache.axis2.context.MessageContext axisRequestMsgCtx = request.getAxisMessageContext();
-        
+                
         // Setup the client so that it knows whether the underlying call to
         // Axis2 knows whether or not to start a listening port for an
         // asynchronous response.
         Boolean useAsyncMep = (Boolean) request.getProperties().get(Constants.USE_ASYNC_MEP);
         if((useAsyncMep != null && useAsyncMep.booleanValue()) 
                 || opClient.getOptions().isUseSeparateListener()) {
-            if (log.isDebugEnabled()) {
-                log.debug("Enabling asynchronous message exchange.  An asynchronous listener will be establish.");
-            }
-
-            opClient.getOptions().setUseSeparateListener(true);
-            opClient.getOptions().setTransportInProtocol("http");
-
-            //FIXME: This has to be here so the ThreadContextMigrator can pick it up.
-            //This should go away once AXIS2-978 is fixed.
-            axisRequestMsgCtx.getOptions().setUseSeparateListener(true);
-            
-            // Setup the response callback receiver to receive the async response
-            // This logic is based on org.apache.axis2.client.ServiceClient.sendReceiveNonBlocking(...)
-            AxisOperation op = opClient.getOperationContext().getAxisOperation();
-            MessageReceiver messageReceiver = op.getMessageReceiver();
-            if (messageReceiver == null || !(messageReceiver instanceof CallbackReceiver))
-                op.setMessageReceiver(new CallbackReceiver());
+            configureAsyncListener(opClient, request.getAxisMessageContext());
         }
-        else {
+		else {
             if (log.isDebugEnabled()) {
                 log.debug("Asynchronous message exchange not enabled.  The invocation will be synchronous.");
             }
         }
-
         
-        // There should be an AsyncListener that is configured and set on the
-        // InvocationContext.  We must get this and use it to wait for the 
-        // async response to come back.  The AxisCallback that is set on the 
-        // AsyncListener is the callback that Axis2 will call when the response
-        // has arrived.
-        AsyncListener listener = ic.getAsyncListener();
-        AxisCallback axisCallback = new AxisCallback();
-        listener.setAxisCallback(axisCallback);
-        listener.setInvocationContext(ic);
-        
-        // Once the AsyncListener is configured, we must include that in an 
-        // AsyncListenerWrapper.  The wrapper is what will handle the lifecycle 
-        // of the listener and determine when it's started and stopped.
-        AsyncListenerWrapper<?> wrapper = new AsyncListenerWrapper<Object>(listener);
-
-        // Inside of the wrapper we must set the callback that the JAX-WS
-        // client programmer provided.  This is the user object that we 
-        // must call back on once we've done everything we need to do at
-        // the JAX-WS layer.
+        
+        CallbackFuture cbf = null;
         if(callback != null){
-            wrapper.setAsyncHandler(callback);
+            cbf = new CallbackFuture(ic.getAsyncResponseListener(), 
+                    callback, ic.getExecutor());
         }
         else {
             throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr4"));
         }
 
-        opClient.setCallback(axisCallback);
+        opClient.setCallback(cbf);
         
+        org.apache.axis2.context.MessageContext axisRequestMsgCtx = request.getAxisMessageContext();
         try {
             execute(opClient, false, axisRequestMsgCtx);
         } catch(AxisFault af) {
@@ -300,42 +263,64 @@
         	af.printStackTrace(System.out);
         }
         
-        // Now that the request has been sent, start the listener thread so that it can
-        // catch the async response.
-        // TODO: Need to determine whether this should be done BEFORE or AFTER
-        // we send the request.  My guess is before though.
-        try {
-            // TODO:Need to figure out where we get the Executor from
-            // Can't be from the MessageContext, but should maybe be 
-            // set somewhere accessible.
-            // FIXME: This should NOT be an ExecutorService, but should just
-            // be a plain old Executor.
-            ExecutorService exec = (ExecutorService) ic.getExecutor();
-            Future<?> future = exec.submit(wrapper);
-            future.get();
-            //TODO temp fix to resolve async callback hang.
-            exec.shutdown();
-        } catch (InterruptedException e) {
-            e.printStackTrace();
-            throw ExceptionFactory.makeWebServiceException(e);
-        } catch (ExecutionException e) {
-            e.printStackTrace();
-            throw ExceptionFactory.makeWebServiceException(e);
-        }
-        
-        return wrapper;
+        return cbf.getFutureTask();
     }
     
     /*
      *  (non-Javadoc)
      * @see org.apache.axis2.jaxws.core.controller.InvocationController#invokeAsync(org.apache.axis2.jaxws.core.InvocationContext)
      */
-    public Response invokeAsync(InvocationContext ic) {
-        if (log.isDebugEnabled()) {
-            log.debug("Invocation pattern: async (polling)");
+    public Response doInvokeAsync(MessageContext request) {
+        // We need the qname of the operation being invoked to know which 
+        // AxisOperation the OperationClient should be based on.
+        // Note that the OperationDesc is only set through use of the Proxy. Dispatch
+        // clients do not use operations, so the operationDesc will be null.  In this
+        // case an anonymous AxisService with anoymouns AxisOperations for the supported
+        // MEPs will be created; and it is that anonymous operation name which needs to
+        // be specified
+        // TODO: Fix this logic once AxisService is created via annoations and not just WSDL
+        //       If ServiceDesc.axisService is null, then we created an Annon Service and operations in 
+        //       ServiceDelegate.getServiceClient(), and that is what the service client points to.
+        //       Therefore, we need to use the annonymous operation name in that case, so the anonymous service client will find 
+        //       the anonymous AxisOperation on that service.  
+        //       This means the ServiceDesc was not build with WSDL, and so there are no Axis objects attached to them
+        //       i.e the OperationDesc.axisOperation == null
+        QName operationName = getOperationNameToUse(request, ServiceClient.ANON_OUT_IN_OP);
+
+        // TODO: Will the ServiceClient stick around on the InvocationContext
+        // or will we need some other mechanism of creating this?
+        // Try to create an OperationClient from the passed in ServiceClient
+        InvocationContext ic = request.getInvocationContext();
+        ServiceClient svcClient = ic.getServiceClient();
+        OperationClient opClient = createOperationClient(svcClient, operationName);
+        
+        initOperationClient(opClient, request);
+        
+        // Setup the client so that it knows whether the underlying call to
+        // Axis2 knows whether or not to start a listening port for an
+        // asynchronous response.
+        Boolean useAsyncMep = (Boolean) request.getProperties().get(Constants.USE_ASYNC_MEP);
+        if((useAsyncMep != null && useAsyncMep.booleanValue()) 
+                || opClient.getOptions().isUseSeparateListener()) {
+            configureAsyncListener(opClient, request.getAxisMessageContext());
+        }
+        
+        AsyncResponse resp = ic.getAsyncResponseListener(); 
+        opClient.setCallback(resp);
+        
+        org.apache.axis2.context.MessageContext axisRequestMsgCtx = request.getAxisMessageContext();
+        try {
+            execute(opClient, false, axisRequestMsgCtx);
+        } catch(AxisFault af) {
+            // TODO MIKE revisit?
+            // do nothing here.  The exception we get is from the endpoint,
+            // and will be sitting on the message context.  We need to save it
+            // to process it through jaxws
+            System.out.println("Swallowed Exception =" + af);
+            af.printStackTrace(System.out);
         }
         
-        throw ExceptionFactory.makeWebServiceException(Messages.getMessage("AsyncPollingNotSupported"));
+        return resp;
     }
     
     /*
@@ -475,6 +460,26 @@
             //TODO: NLS and ExceptionFactory
             throw ExceptionFactory.makeWebServiceException(e);
         }
+    }
+    
+    private void configureAsyncListener(OperationClient client, org.apache.axis2.context.MessageContext mc) {
+    	if (log.isDebugEnabled()) {
+        	log.debug("Enabling asynchronous message exchange.  An asynchronous listener will be establish.");
+		}
+    
+        client.getOptions().setUseSeparateListener(true);
+        client.getOptions().setTransportInProtocol("http");
+
+        //FIXME: This has to be here so the ThreadContextMigrator can pick it up.
+        //This should go away once AXIS2-978 is fixed.
+        mc.getOptions().setUseSeparateListener(true);
+        
+        // Setup the response callback receiver to receive the async response
+        // This logic is based on org.apache.axis2.client.ServiceClient.sendReceiveNonBlocking(...)
+        AxisOperation op = client.getOperationContext().getAxisOperation();
+        MessageReceiver messageReceiver = op.getMessageReceiver();
+        if (messageReceiver == null || !(messageReceiver instanceof CallbackReceiver))
+            op.setMessageReceiver(new CallbackReceiver());
     }
     
     private Message createMessageFromOM(OMElement om) throws MessageException {

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java?view=diff&rev=471644&r1=471643&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java Sun Nov  5 21:55:26 2006
@@ -1,204 +1,226 @@
-/*
- * Copyright 2006 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.axis2.jaxws.core.controller;
-
-import java.util.concurrent.Future;
-
-import javax.xml.ws.AsyncHandler;
-import javax.xml.ws.Response;
-import javax.xml.ws.WebServiceException;
-
-import org.apache.axis2.jaxws.ExceptionFactory;
-import org.apache.axis2.jaxws.core.InvocationContext;
-import org.apache.axis2.jaxws.core.MessageContext;
-import org.apache.axis2.jaxws.i18n.Messages;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * The <tt>InvocationController</tt> is an abstract implementation modeling
- * the invocation of a target web service.  All of the information that the 
- * InvocationController needs should exist within the InvocatonContext
- * that is passed in to the various invoke methods.  
- * 
- * The request information is passed in within the InvocationContext.  The
- * InvocationController assumes that there is a MessageContext within that
- * InvocationContext that is populated with all of the information that it
- * needs to invoke.  If not, an error will be returned.  Once the response 
- * comes back, the information for that response will be held inside of the
- * MessageContext representing the response, that exists in the 
- * InvocationContext.
- * 
- * The InvocationController supports four different invocation patterns:
- * 
- * 1) synchronous - This is represented by the {@link #invoke(InvocationContext)}
- * method.  This is a blocking, request/response call to the web service.
- * 
- * 2) one-way - This is represented by the {@link #invokeOneWay(InvocationContext)}
- * method.  This is a one-way invocation that only returns errors related
- * to sending the message.  If an error occurs while processing, the client
- * will not be notified.
- * 
- * 3) asynchronous (callback) - {@link #invokeAsync(InvocationContext, AsyncHandler)}
- * 
- * 4) asynchronous (polling) - {@link #invokeAsync(InvocationContext)}
- */
-public abstract class InvocationController {
-    
-    private static final Log log = LogFactory.getLog(InvocationController.class);
-    
-    /**
-     * Performs a synchronous (blocking) invocation of a target service.  The 
-     * InvocationContext passed in should contain a valid MessageContext 
-     * containing the properties and message to be sent for the request.  The
-     * response contents will be processed and placed in the InvocationContext
-     * as well.
-     * 
-     * @param ic
-     * @return
-     */
-    public InvocationContext invoke(InvocationContext ic) {
-        if (log.isDebugEnabled()) {
-            log.debug("Invocation pattern: synchronous");
-        }
-        
-        // Check to make sure we at least have a valid InvocationContext
-        // and request MessageContext
-        if (ic == null) {
-            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr1"));
-        }
-        if (ic.getRequestMessageContext() == null) {
-            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
-        }
-        
-        MessageContext request = ic.getRequestMessageContext();
-        MessageContext response = null;
-
-        // TODO: Place-holder for running the JAX-WS request handler chain
-        
-        prepareRequest(request);
-        
-        response = doInvoke(request);
-        prepareResponse(response);
-        ic.setResponseMessageContext(response);
-        
-        // TODO: Place-holder for running the JAX-WS response handler chain
-        
-        return ic;
-    }
-    
-    protected abstract MessageContext doInvoke(MessageContext request);
-    
-    /**
-     * Performs a one-way invocation of the client.  This is SHOULD NOT be a 
-     * robust invocation, so any fault that occurs during the processing of 
-     * the request will not be returned to the client.  Errors returned to the
-     * client are problems that occurred during the sending of the message to 
-     * the server.
-     * 
-     * @param ic
-     */
-    public void invokeOneWay(InvocationContext ic) {
-        if (log.isDebugEnabled()) {
-            log.debug("Invocation pattern: one-way");
-        }
-        
-        // Check to make sure we at least have a valid InvocationContext
-        // and request MessageContext
-        if (ic == null) {
-            throw ExceptionFactory.makeWebServiceException("ICErr1");
-        }
-        if (ic.getRequestMessageContext() == null) {
-            throw ExceptionFactory.makeWebServiceException("ICErr2");
-        }
-        
-        MessageContext request = ic.getRequestMessageContext();
-        
-        // TODO: Place-holder to run the JAX-WS request handler chain
-        
-        prepareRequest(request);
-        doInvokeOneWay(request);
-        return;
-    }
-    
-    protected abstract void doInvokeOneWay(MessageContext mc) throws WebServiceException;
-    
-    /**
-     * Performs an asynchronous (non-blocking) invocation of the client based 
-     * on a callback model.  The AsyncHandler that is passed in is the callback
-     * that the client programmer supplied when they invoked their JAX-WS
-     * Dispatch or their SEI-based dynamic proxy.  
-     * 
-     * @param ic
-     * @param callback
-     * @return
-     */
-    public abstract Response invokeAsync(InvocationContext ic);
-    
-    /**
-     * Performs an asynchronous (non-blocking) invocation of the client based 
-     * on a polling model.  The Response object that is returned allows the 
-     * client programmer to poll against it to see if a response has been sent
-     * back by the server.
-     * 
-     * @param ic
-     * @return
-     */
-    public Future<?> invokeAsync(InvocationContext ic, AsyncHandler asyncHandler) {
-        if (log.isDebugEnabled()) {
-            log.debug("Invocation pattern: asynchronous(callback)");
-        }
-        
-        // Check to make sure we at least have a valid InvocationContext
-        // and request MessageContext
-        if (ic == null) {
-            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr1"));
-        }
-        if (ic.getRequestMessageContext() == null) {
-            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
-        }
-        
-        MessageContext request = ic.getRequestMessageContext();
-
-        // TODO: Place-holder for running the JAX-WS request handler chain
-        
-        prepareRequest(request);
-        Future<?> future = doInvokeAsync(request, asyncHandler);
-        return future;        
-    }
-    
-    public abstract Future<?> doInvokeAsync(MessageContext mc, AsyncHandler asyncHandler);
-    
-    /**
-     * Abstract method that must be implemented by whoever is providing
-     * the specific client binding.  Once this is called, everything that
-     * is needed to invoke the operation must be available in the 
-     * MessageContext.
-     * @param mc
-     */
-    protected abstract void prepareRequest(MessageContext mc);
-    
-    /**
-     * Abstract method that must be implemented by whoever is providing
-     * the specific client binding.  This is called after the response has 
-     * come back and allows the client binding to put whatever info it has
-     * in the response MessageContext.
-     * @param mc
-     */
-    protected abstract void prepareResponse(MessageContext mc);
-    
-}
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ * Copyright 2006 International Business Machines Corp.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.jaxws.core.controller;
+
+import java.util.concurrent.Future;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.core.InvocationContext;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The <tt>InvocationController</tt> is an abstract implementation modeling
+ * the invocation of a target web service.  All of the information that the 
+ * InvocationController needs should exist within the InvocatonContext
+ * that is passed in to the various invoke methods.  
+ * 
+ * The request information is passed in within the InvocationContext.  The
+ * InvocationController assumes that there is a MessageContext within that
+ * InvocationContext that is populated with all of the information that it
+ * needs to invoke.  If not, an error will be returned.  Once the response 
+ * comes back, the information for that response will be held inside of the
+ * MessageContext representing the response, that exists in the 
+ * InvocationContext.
+ * 
+ * The InvocationController supports four different invocation patterns:
+ * 
+ * 1) synchronous - This is represented by the {@link #invoke(InvocationContext)}
+ * method.  This is a blocking, request/response call to the web service.
+ * 
+ * 2) one-way - This is represented by the {@link #invokeOneWay(InvocationContext)}
+ * method.  This is a one-way invocation that only returns errors related
+ * to sending the message.  If an error occurs while processing, the client
+ * will not be notified.
+ * 
+ * 3) asynchronous (callback) - {@link #invokeAsync(InvocationContext, AsyncHandler)}
+ * 
+ * 4) asynchronous (polling) - {@link #invokeAsync(InvocationContext)}
+ */
+public abstract class InvocationController {
+    
+    private static final Log log = LogFactory.getLog(InvocationController.class);
+    
+    /**
+     * Performs a synchronous (blocking) invocation of a target service.  The 
+     * InvocationContext passed in should contain a valid MessageContext 
+     * containing the properties and message to be sent for the request.  The
+     * response contents will be processed and placed in the InvocationContext
+     * as well.
+     * 
+     * @param ic
+     * @return
+     */
+    public InvocationContext invoke(InvocationContext ic) {
+        if (log.isDebugEnabled()) {
+            log.debug("Invocation pattern: synchronous");
+        }
+        
+        // Check to make sure we at least have a valid InvocationContext
+        // and request MessageContext
+        if (ic == null) {
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr1"));
+        }
+        if (ic.getRequestMessageContext() == null) {
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
+        }
+        
+        MessageContext request = ic.getRequestMessageContext();
+        MessageContext response = null;
+
+        // TODO: Place-holder for running the JAX-WS request handler chain
+        
+        prepareRequest(request);
+        
+        response = doInvoke(request);
+        prepareResponse(response);
+        ic.setResponseMessageContext(response);
+        
+        // TODO: Place-holder for running the JAX-WS response handler chain
+        
+        return ic;
+    }
+    
+    protected abstract MessageContext doInvoke(MessageContext request);
+    
+    /**
+     * Performs a one-way invocation of the client.  This is SHOULD NOT be a 
+     * robust invocation, so any fault that occurs during the processing of 
+     * the request will not be returned to the client.  Errors returned to the
+     * client are problems that occurred during the sending of the message to 
+     * the server.
+     * 
+     * @param ic
+     */
+    public void invokeOneWay(InvocationContext ic) {
+        if (log.isDebugEnabled()) {
+            log.debug("Invocation pattern: one-way");
+        }
+        
+        // Check to make sure we at least have a valid InvocationContext
+        // and request MessageContext
+        if (ic == null) {
+            throw ExceptionFactory.makeWebServiceException("ICErr1");
+        }
+        if (ic.getRequestMessageContext() == null) {
+            throw ExceptionFactory.makeWebServiceException("ICErr2");
+        }
+        
+        MessageContext request = ic.getRequestMessageContext();
+        
+        // TODO: Place-holder to run the JAX-WS request handler chain
+        
+        prepareRequest(request);
+        doInvokeOneWay(request);
+        return;
+    }
+    
+    protected abstract void doInvokeOneWay(MessageContext mc);
+    
+    /**
+     * Performs an asynchronous (non-blocking) invocation of the client based 
+     * on a callback model.  The AsyncHandler that is passed in is the callback
+     * that the client programmer supplied when they invoked their JAX-WS
+     * Dispatch or their SEI-based dynamic proxy.  
+     * 
+     * @param ic
+     * @param callback
+     * @return
+     */
+    public Response invokeAsync(InvocationContext ic) {
+        if (log.isDebugEnabled()) {
+            log.debug("Invocation pattern: asynchronous(callback)");
+        }
+        
+        // Check to make sure we at least have a valid InvocationContext
+        // and request MessageContext
+        if (ic == null) {
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr1"));
+        }
+        if (ic.getRequestMessageContext() == null) {
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
+        }
+        
+        MessageContext request = ic.getRequestMessageContext();
+
+        // TODO: Place-holder for running the JAX-WS request handler chain
+        
+        prepareRequest(request);
+        Response resp = doInvokeAsync(request);
+        return resp;
+    }
+    
+    public abstract Response doInvokeAsync(MessageContext mc);
+    
+    /**
+     * Performs an asynchronous (non-blocking) invocation of the client based 
+     * on a polling model.  The Response object that is returned allows the 
+     * client programmer to poll against it to see if a response has been sent
+     * back by the server.
+     * 
+     * @param ic
+     * @return
+     */
+    public Future<?> invokeAsync(InvocationContext ic, AsyncHandler asyncHandler) {
+        if (log.isDebugEnabled()) {
+            log.debug("Invocation pattern: asynchronous(callback)");
+        }
+        
+        // Check to make sure we at least have a valid InvocationContext
+        // and request MessageContext
+        if (ic == null) {
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr1"));
+        }
+        if (ic.getRequestMessageContext() == null) {
+            throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
+        }
+        
+        MessageContext request = ic.getRequestMessageContext();
+
+        // TODO: Place-holder for running the JAX-WS request handler chain
+        
+        prepareRequest(request);
+        Future<?> future = doInvokeAsync(request, asyncHandler);
+        return future;        
+    }
+    
+    public abstract Future<?> doInvokeAsync(MessageContext mc, AsyncHandler asyncHandler);
+    
+    /**
+     * Abstract method that must be implemented by whoever is providing
+     * the specific client binding.  Once this is called, everything that
+     * is needed to invoke the operation must be available in the 
+     * MessageContext.
+     * @param mc
+     */
+    protected abstract void prepareRequest(MessageContext mc);
+    
+    /**
+     * Abstract method that must be implemented by whoever is providing
+     * the specific client binding.  This is called after the response has 
+     * come back and allows the client binding to put whatever info it has
+     * in the response MessageContext.
+     * @param mc
+     */
+    protected abstract void prepareResponse(MessageContext mc);
+    
+}

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java?view=auto&rev=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/AsyncCallback.java Sun Nov  5 21:55:26 2006
@@ -0,0 +1,34 @@
+package org.apache.axis2.jaxws.dispatch;
+
+import java.util.concurrent.ExecutionException;
+
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Response;
+
+public class AsyncCallback<T> implements AsyncHandler<T> {
+
+    private T value;
+    private Throwable exception;
+    
+    public void handleResponse(Response<T> response) {
+        try {
+            value = response.get();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        } catch (ExecutionException e) {
+            e.printStackTrace();
+        }
+    }
+    
+    public boolean hasError() {
+        return (exception != null);
+    }
+    
+    public Throwable getError() {
+        return exception;
+    }
+    
+    public T getValue() {
+        return value;
+    }
+}

Copied: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/CallbackHandler.java (from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/CallbackHandler.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/CallbackHandler.java?view=diff&rev=471644&p1=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/CallbackHandler.java&r1=470019&p2=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/CallbackHandler.java&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/CallbackHandler.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/CallbackHandler.java Sun Nov  5 21:55:26 2006
@@ -1,34 +1,27 @@
 /*
- * Copyright 2004,2005 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
  *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.axis2.jaxws;
-
-import java.io.StringWriter;
+package org.apache.axis2.jaxws.dispatch;
 
 import javax.xml.soap.SOAPMessage;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamReader;
-import javax.xml.transform.Result;
 import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.sax.SAXSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Response;
 

Copied: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DOMSourceDispatch.java (from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DOMSourceDispatch.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DOMSourceDispatch.java?view=diff&rev=471644&p1=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DOMSourceDispatch.java&r1=470019&p2=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DOMSourceDispatch.java&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DOMSourceDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DOMSourceDispatch.java Sun Nov  5 21:55:26 2006
@@ -1,20 +1,22 @@
 /*
- * Copyright 2004,2005 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
  *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.axis2.jaxws;
+package org.apache.axis2.jaxws.dispatch;
 
 import java.io.ByteArrayInputStream;
 import java.util.concurrent.Future;
@@ -26,6 +28,7 @@
 import javax.xml.transform.Source;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.ws.Dispatch;
+import javax.xml.ws.Response;
 import javax.xml.ws.Service;
 
 import junit.framework.TestCase;
@@ -112,7 +115,7 @@
         DOMSource request = createDOMSourceFromString(DispatchTestConstants.sampleBodyContent);
 
         // Setup the callback for async responses
-        CallbackHandler<Source> callbackHandler = new CallbackHandler<Source>();
+        AsyncCallback<Source> callbackHandler = new AsyncCallback<Source>();
         
         System.out.println(">> Invoking async (callback) Dispatch");
         Future<?> monitor = dispatch.invokeAsync(request, callbackHandler);
@@ -121,6 +124,19 @@
             System.out.println(">> Async invocation still not complete");
             Thread.sleep(1000);
         }
+        
+        Source response = callbackHandler.getValue();
+        assertNotNull(response);
+        
+        // Turn the Source into a String so we can check it
+        String responseText = createStringFromSource(response);        
+        System.out.println(responseText);
+        
+        // Check to make sure the content is correct
+        assertTrue(!responseText.contains("soap"));
+        assertTrue(!responseText.contains("Envelope"));
+        assertTrue(!responseText.contains("Body"));
+        assertTrue(responseText.contains("echoStringResponse"));
     }
     
     public void testAsyncCallbackMessageMode() throws Exception {
@@ -137,7 +153,7 @@
         DOMSource request = createDOMSourceFromString(DispatchTestConstants.sampleSoapMessage);
 
         // Setup the callback for async responses
-        CallbackHandler<Source> callbackHandler = new CallbackHandler<Source>();
+        AsyncCallback<Source> callbackHandler = new AsyncCallback<Source>();
         
         System.out.println(">> Invoking async (callback) Dispatch");
         Future<?> monitor = dispatch.invokeAsync(request, callbackHandler);
@@ -146,7 +162,90 @@
             System.out.println(">> Async invocation still not complete");
             Thread.sleep(1000);
         }
+        
+        Source response = callbackHandler.getValue();
+        assertNotNull(response);
+        
+        // Turn the Source into a String so we can check it
+        String responseText = createStringFromSource(response);        
+        System.out.println(responseText);
+        
+        // Check to make sure the content is correct
+        assertTrue(responseText.contains("soap"));
+        assertTrue(responseText.contains("Envelope"));
+        assertTrue(responseText.contains("Body"));
+        assertTrue(responseText.contains("echoStringResponse"));
 	}
+    
+    public void testAsyncPollingPayloadMode() throws Exception {
+        System.out.println("---------------------------------------");
+        System.out.println("test: " + getName());
+        
+        // Initialize the JAX-WS client artifacts
+        Service svc = Service.create(DispatchTestConstants.QNAME_SERVICE);
+        svc.addPort(DispatchTestConstants.QNAME_PORT, null, DispatchTestConstants.URL);
+        Dispatch<Source> dispatch = svc.createDispatch(DispatchTestConstants.QNAME_PORT, 
+                Source.class, Service.Mode.PAYLOAD);
+        
+        // Create the DOMSource
+        DOMSource request = createDOMSourceFromString(DispatchTestConstants.sampleBodyContent);
+
+        System.out.println(">> Invoking async (polling) Dispatch");
+        Response<Source> asyncResponse = dispatch.invokeAsync(request);
+            
+        while (!asyncResponse.isDone()) {
+            System.out.println(">> Async invocation still not complete");
+            Thread.sleep(1000);
+        }
+        
+        Source response = asyncResponse.get();
+        assertNotNull(response);
+        
+        // Turn the Source into a String so we can check it
+        String responseText = createStringFromSource(response);        
+        System.out.println(responseText);
+        
+        // Check to make sure the content is correct
+        assertTrue(!responseText.contains("soap"));
+        assertTrue(!responseText.contains("Envelope"));
+        assertTrue(!responseText.contains("Body"));
+        assertTrue(responseText.contains("echoStringResponse"));
+    }
+    
+    public void testAsyncPollingMessageMode() throws Exception {
+        System.out.println("---------------------------------------");
+        System.out.println("test: " + getName());
+        
+        // Initialize the JAX-WS client artifacts
+        Service svc = Service.create(DispatchTestConstants.QNAME_SERVICE);
+        svc.addPort(DispatchTestConstants.QNAME_PORT, null, DispatchTestConstants.URL);
+        Dispatch<Source> dispatch = svc.createDispatch(DispatchTestConstants.QNAME_PORT, 
+                Source.class, Service.Mode.MESSAGE);
+        
+        // Create the DOMSource
+        DOMSource request = createDOMSourceFromString(DispatchTestConstants.sampleSoapMessage);
+
+        System.out.println(">> Invoking async (callback) Dispatch");
+        Response<Source> asyncResponse = dispatch.invokeAsync(request);
+            
+        while (!asyncResponse.isDone()) {
+            System.out.println(">> Async invocation still not complete");
+            Thread.sleep(1000);
+        }
+        
+        Source response = asyncResponse.get();
+        assertNotNull(response);
+        
+        // Turn the Source into a String so we can check it
+        String responseText = createStringFromSource(response);        
+        System.out.println(responseText);
+        
+        // Check to make sure the content is correct
+        assertTrue(responseText.contains("soap"));
+        assertTrue(responseText.contains("Envelope"));
+        assertTrue(responseText.contains("Body"));
+        assertTrue(responseText.contains("echoStringResponse"));
+    }
     
     public void testOneWayPayloadMode() throws Exception {
         System.out.println("---------------------------------------");

Copied: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestConstants.java (from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DispatchTestConstants.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestConstants.java?view=diff&rev=471644&p1=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DispatchTestConstants.java&r1=470019&p2=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestConstants.java&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DispatchTestConstants.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestConstants.java Sun Nov  5 21:55:26 2006
@@ -1,20 +1,22 @@
 /*
- * Copyright 2004,2005 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
  *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.axis2.jaxws;
+package org.apache.axis2.jaxws.dispatch;
 
 import javax.xml.namespace.QName;
 

Copied: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestSuite.java (from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DispatchTestSuite.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestSuite.java?view=diff&rev=471644&p1=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DispatchTestSuite.java&r1=470019&p2=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestSuite.java&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/DispatchTestSuite.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/DispatchTestSuite.java Sun Nov  5 21:55:26 2006
@@ -1,20 +1,22 @@
 /*
- * Copyright 2004,2005 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
  *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.axis2.jaxws;
+package org.apache.axis2.jaxws.dispatch;
 
 import junit.framework.TestSuite;
 
@@ -36,5 +38,4 @@
         suite.addTestSuite(JAXBSourceDispatch.class);
         return suite;
     }
-
 }

Copied: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBCallbackHandler.java (from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBCallbackHandler.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBCallbackHandler.java?view=diff&rev=471644&p1=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBCallbackHandler.java&r1=470019&p2=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBCallbackHandler.java&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBCallbackHandler.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBCallbackHandler.java Sun Nov  5 21:55:26 2006
@@ -1,20 +1,22 @@
 /*
- * Copyright 2004,2005 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
  *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.axis2.jaxws;
+package org.apache.axis2.jaxws.dispatch;
 
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Response;

Copied: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBDispatch.java (from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBDispatch.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBDispatch.java?view=diff&rev=471644&p1=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBDispatch.java&r1=470019&p2=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBDispatch.java&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBDispatch.java Sun Nov  5 21:55:26 2006
@@ -1,20 +1,22 @@
 /*
- * Copyright 2004,2005 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
  *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.axis2.jaxws;
+package org.apache.axis2.jaxws.dispatch;
 
 import java.util.concurrent.Future;
 

Copied: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBSourceDispatch.java (from r470019, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBSourceDispatch.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBSourceDispatch.java?view=diff&rev=471644&p1=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBSourceDispatch.java&r1=470019&p2=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBSourceDispatch.java&r2=471644
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/JAXBSourceDispatch.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/dispatch/JAXBSourceDispatch.java Sun Nov  5 21:55:26 2006
@@ -1,20 +1,22 @@
 /*
- * Copyright 2004,2005 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
  *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
-package org.apache.axis2.jaxws;
+package org.apache.axis2.jaxws.dispatch;
 
 import java.io.StringWriter;
 



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