You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2007/04/26 07:19:33 UTC

svn commit: r532615 [3/13] - in /webservices/axis2/branches/java/1_2/modules: jaxws-api/src/javax/xml/ws/handler/soap/ jaxws-api/src/javax/xml/ws/soap/ jaxws/ jaxws/src/org/apache/axis2/jaxws/ jaxws/src/org/apache/axis2/jaxws/binding/ jaxws/src/org/apa...

Added: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingUtils.java?view=auto&rev=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingUtils.java (added)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/binding/BindingUtils.java Wed Apr 25 22:19:23 2007
@@ -0,0 +1,67 @@
+/*
+ * 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.binding;
+
+import javax.xml.ws.Binding;
+
+import org.apache.axis2.jaxws.description.EndpointDescription;
+
+public class BindingUtils {
+
+    /**
+     * Creates a Binding instance based on an EndpointDescription.
+     * @param ed
+     * @return
+     */
+    public static Binding createBinding(EndpointDescription ed) {
+        if (ed == null) {
+            // Do we default to the SOAPBinding?            
+        }
+        
+        String bindingType = ed.getBindingType();
+        if (BindingUtils.isSOAPBinding(bindingType)) {
+            return new SOAPBinding(ed);
+        }
+        else if (BindingUtils.isHTTPBinding(bindingType)) { 
+            return new HTTPBinding(ed);
+        }
+        else {
+            // If we can't figure it out, let's default to 
+            // a SOAPBinding
+            return new SOAPBinding(ed);
+        }
+    }
+    
+    public static boolean isSOAPBinding(String url) {
+        if (url != null && (url.equals(SOAPBinding.SOAP11HTTP_BINDING) ||
+                url.equals(SOAPBinding.SOAP11HTTP_MTOM_BINDING) ||
+                url.equals(SOAPBinding.SOAP12HTTP_BINDING)|| 
+                url.equals(SOAPBinding.SOAP12HTTP_MTOM_BINDING))) {
+            return true;
+        }
+        return false;
+    }
+    
+    public static boolean isHTTPBinding(String url) {
+        if (url != null && url.equals(HTTPBinding.HTTP_BINDING)) {
+            return true;
+        }
+        return false;
+    }
+}
\ No newline at end of file

Added: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/binding/HTTPBinding.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/binding/HTTPBinding.java?view=auto&rev=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/binding/HTTPBinding.java (added)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/binding/HTTPBinding.java Wed Apr 25 22:19:23 2007
@@ -0,0 +1,29 @@
+/*
+ * 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.binding;
+
+import org.apache.axis2.jaxws.description.EndpointDescription;
+
+public class HTTPBinding extends BindingImpl implements javax.xml.ws.http.HTTPBinding {
+
+    public HTTPBinding(EndpointDescription ed) {
+        super(ed);
+    }
+
+}
\ No newline at end of file

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/binding/SOAPBinding.java Wed Apr 25 22:19:23 2007
@@ -1,21 +1,24 @@
 /*
- * 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
- *
+ * 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.binding;
 
+import org.apache.axis2.jaxws.description.EndpointDescription;
 import org.apache.axis2.jaxws.utility.SAAJFactory;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -24,59 +27,63 @@
 import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPFactory;
 import javax.xml.ws.WebServiceException;
+
 import java.net.URI;
 import java.util.Set;
 
 /**
- * An implementation of the <link>javax.xml.ws.soap.SOAPBinding</link> interface.  This is the
- * default binding for JAX-WS, and will exist for all Dispatch and Dynamic Proxy instances unless
- * the XML/HTTP Binding is explicitly specificied.
+ * An implementation of the <link>javax.xml.ws.soap.SOAPBinding</link>
+ * interface. This is the default binding for JAX-WS, and will exist for all
+ * Dispatch and Dynamic Proxy instances unless the XML/HTTP Binding is
+ * explicitly specificied.
  */
-public class SOAPBinding extends BindingImpl
-        implements javax.xml.ws.soap.SOAPBinding {
+public class SOAPBinding extends BindingImpl implements javax.xml.ws.soap.SOAPBinding {
 
     private boolean mtomEnabled = false;
+
     private static Log log = LogFactory.getLog(SOAPBinding.class);
 
-    public SOAPBinding(String bindingId) {
-        super(bindingId);
+    public SOAPBinding(EndpointDescription endpointDesc) {
+        super(endpointDesc);
     }
 
     /*
-    * (non-Javadoc)
-    * @see javax.xml.ws.soap.SOAPBinding#getMessageFactory()
-    */
+     * (non-Javadoc)
+     * 
+     * @see javax.xml.ws.soap.SOAPBinding#getMessageFactory()
+     */
     public MessageFactory getMessageFactory() {
         String bindingNamespace = null;
         try {
             /*
-             * SAAJFactory.createMessageFactory takes a namespace String as a param:
-             *     "http://schemas.xmlsoap.org/soap/envelope/"  (SOAP1.1)
-             *     "http://www.w3.org/2003/05/soap-envelope"    (SOAP1.2)
-             *     
+             * SAAJFactory.createMessageFactory takes a namespace String as a
+             * param: "http://schemas.xmlsoap.org/soap/envelope/" (SOAP1.1)
+             * "http://www.w3.org/2003/05/soap-envelope" (SOAP1.2)
+             * 
              * The bindingId will be in one of the following forms:
-             *     "http://schemas.xmlsoap.org/wsdl/soap/http"      (SOAP1.1)
-             *     "http://www.w3.org/2003/05/soap/bindings/HTTP/"  (SOAP1.2)
+             * "http://schemas.xmlsoap.org/wsdl/soap/http" (SOAP1.1)
+             * "http://www.w3.org/2003/05/soap/bindings/HTTP/" (SOAP1.2)
              */
             if (bindingId.equalsIgnoreCase(SOAPBinding.SOAP12HTTP_BINDING)
-                    || bindingId.equalsIgnoreCase(SOAPBinding.SOAP12HTTP_MTOM_BINDING)) {
+                            || bindingId.equalsIgnoreCase(SOAPBinding.SOAP12HTTP_MTOM_BINDING)) {
                 bindingNamespace = SOAP12_ENV_NS;
             } else {
-                // TODO currently defaults to SOAP11.  Should we be more stricct about checking?
+                // TODO currently defaults to SOAP11. Should we be more stricct
+                // about checking?
                 bindingNamespace = SOAP11_ENV_NS;
             }
             return SAAJFactory.createMessageFactory(bindingNamespace);
         } catch (WebServiceException e) {
             // TODO log it and then what?
             if (log.isDebugEnabled()) {
-                log.debug("WebServiceException calling SAAJFactory.createMessageFactory(\"" +
-                        bindingNamespace + "\")");
+                log.debug("WebServiceException calling SAAJFactory.createMessageFactory(\""
+                                + bindingNamespace + "\")");
             }
         } catch (SOAPException e) {
             // TODO log it and then what?
             if (log.isDebugEnabled()) {
-                log.debug("SOAPException calling SAAJFactory.createMessageFactory(\"" +
-                        bindingNamespace + "\")");
+                log.debug("SOAPException calling SAAJFactory.createMessageFactory(\""
+                                + bindingNamespace + "\")");
             }
         }
         return null;
@@ -84,47 +91,50 @@
 
     /*
      * (non-Javadoc)
+     * 
      * @see javax.xml.ws.soap.SOAPBinding#getRoles()
      */
-    public Set<URI> getRoles() {
+    public Set<String> getRoles() {
         return roles;
     }
 
     /*
      * (non-Javadoc)
+     * 
      * @see javax.xml.ws.soap.SOAPBinding#getSOAPFactory()
      */
     public SOAPFactory getSOAPFactory() {
         String bindingNamespace = null;
         try {
             /*
-             * SAAJFactory.createMessageFactory takes a namespace String as a param:
-             *     "http://schemas.xmlsoap.org/soap/envelope/"  (SOAP1.1)
-             *     "http://www.w3.org/2003/05/soap-envelope"    (SOAP1.2)
-             *     
+             * SAAJFactory.createMessageFactory takes a namespace String as a
+             * param: "http://schemas.xmlsoap.org/soap/envelope/" (SOAP1.1)
+             * "http://www.w3.org/2003/05/soap-envelope" (SOAP1.2)
+             * 
              * The bindingId will be in one of the following forms:
-             *     "http://schemas.xmlsoap.org/wsdl/soap/http"      (SOAP1.1)
-             *     "http://www.w3.org/2003/05/soap/bindings/HTTP/"  (SOAP1.2)
+             * "http://schemas.xmlsoap.org/wsdl/soap/http" (SOAP1.1)
+             * "http://www.w3.org/2003/05/soap/bindings/HTTP/" (SOAP1.2)
              */
             if (bindingId.equalsIgnoreCase(SOAPBinding.SOAP12HTTP_BINDING)
-                    || bindingId.equalsIgnoreCase(SOAPBinding.SOAP12HTTP_MTOM_BINDING)) {
+                            || bindingId.equalsIgnoreCase(SOAPBinding.SOAP12HTTP_MTOM_BINDING)) {
                 bindingNamespace = SOAP12_ENV_NS;
             } else {
-                // TODO currently defaults to SOAP11.  Should we be more stricct about checking?
+                // TODO currently defaults to SOAP11. Should we be more stricct
+                // about checking?
                 bindingNamespace = SOAP11_ENV_NS;
             }
             return SAAJFactory.createSOAPFactory(bindingNamespace);
         } catch (WebServiceException e) {
             // TODO log it and then what?
             if (log.isDebugEnabled()) {
-                log.debug("WebServiceException calling SAAJFactory.createSOAPFactory(\"" +
-                        bindingNamespace + "\")");
+                log.debug("WebServiceException calling SAAJFactory.createSOAPFactory(\""
+                                + bindingNamespace + "\")");
             }
         } catch (SOAPException e) {
             // TODO log it and then what?
             if (log.isDebugEnabled()) {
-                log.debug("SOAPException calling SAAJFactory.createSOAPFactory(\"" +
-                        bindingNamespace + "\")");
+                log.debug("SOAPException calling SAAJFactory.createSOAPFactory(\""
+                                + bindingNamespace + "\")");
             }
         }
         return null;
@@ -132,6 +142,7 @@
 
     /*
      * (non-Javadoc)
+     * 
      * @see javax.xml.ws.soap.SOAPBinding#isMTOMEnabled()
      */
     public boolean isMTOMEnabled() {
@@ -140,6 +151,7 @@
 
     /*
      * (non-Javadoc)
+     * 
      * @see javax.xml.ws.soap.SOAPBinding#setMTOMEnabled(boolean)
      */
     public void setMTOMEnabled(boolean flag) {
@@ -148,9 +160,10 @@
 
     /*
      * (non-Javadoc)
+     * 
      * @see javax.xml.ws.soap.SOAPBinding#setRoles(java.util.Set)
      */
-    public void setRoles(Set<URI> set) {
+    public void setRoles(Set<String> set) {
         roles = set;
     }
 

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/AsyncResponse.java Wed Apr 25 22:19:23 2007
@@ -21,12 +21,15 @@
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.handler.HandlerChainProcessor;
+import org.apache.axis2.jaxws.handler.HandlerInvokerUtils;
 import org.apache.axis2.jaxws.spi.Constants;
 import org.apache.axis2.jaxws.spi.migrator.ApplicationContextMigratorUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import javax.xml.ws.Response;
+
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.CancellationException;
@@ -34,7 +37,6 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeoutException;
-
 /**
  * The AsyncResponse class is used to collect the response information from Axis2 and deliver it to
  * a JAX-WS client.  AsyncResponse implements the <link>javax.xml.ws.Response</link> API that is
@@ -203,8 +205,7 @@
         // TODO: IMPORTANT: this is the right call here, but beware that the messagecontext may be turned into
         // a fault context with a fault message.  We need to check for this and, if necessary, make an exception and throw it.
         // Invoke inbound handlers.
-        // TODO: integrate -- uncomment line
-        //HandlerInvokerUtils.invokeInboundHandlers(response, response.getEndpointDescription(), HandlerChainProcessor.MEP.RESPONSE, false);
+        HandlerInvokerUtils.invokeInboundHandlers(response, response.getInvocationContext().getHandlers(), response.getEndpointDescription(), HandlerChainProcessor.MEP.RESPONSE, false);
 
         // TODO: Check the type of the object to make sure it corresponds with
         // the parameterized generic type.
@@ -244,9 +245,11 @@
         // A faultMessageContext means that there could possibly be a SOAPFault
         // on the MessageContext that we need to unmarshall.
         if (faultMessageContext != null) {
+            // it is possible the message could be null.  For example, if we gave the proxy a bad endpoint address.
+            // If it is the case that the message is null, there's no sense running through the handlers.
+            if (faultMessageContext.getMessage() != null)
             // Invoke inbound handlers.
-            // TODO: integrate -- uncomment line
-            //HandlerInvokerUtils.invokeInboundHandlers(response, response.getEndpointDescription(), HandlerChainProcessor.MEP.RESPONSE, false);
+            HandlerInvokerUtils.invokeInboundHandlers(faultMessageContext, faultMessageContext.getInvocationContext().getHandlers(), faultMessageContext.getEndpointDescription(), HandlerChainProcessor.MEP.RESPONSE, false);
             Throwable t = getFaultResponse(faultMessageContext);
             if (t != null) {
                 return t;

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/CallbackFuture.java Wed Apr 25 22:19:23 2007
@@ -21,12 +21,14 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.client.async.AsyncResult;
 import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.jaxws.core.InvocationContext;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.WebServiceException;
+
 import java.util.concurrent.Callable;
 import java.util.concurrent.Executor;
 import java.util.concurrent.Future;
@@ -47,6 +49,9 @@
     private CallbackFutureTask cft;
     private Executor executor;
     private FutureTask task;
+    
+    private InvocationContext invocationCtx;
+    
     /*
      * There are two Async Callback Future.cancel scenario that we address
      * 1) Client app creates request and call Async Operation. Now before the request is submitted
@@ -67,10 +72,16 @@
      */
 
     @SuppressWarnings("unchecked")
-    public CallbackFuture(AsyncResponse response, AsyncHandler handler, Executor exec) {
-        cft = new CallbackFutureTask(response, handler);
+    public CallbackFuture(InvocationContext ic, AsyncHandler handler) {
+        cft = new CallbackFutureTask(ic.getAsyncResponseListener(), handler);
         task = new FutureTask(cft);
-        executor = exec;
+        executor = ic.getExecutor();
+        
+        /*
+         * TODO review.  We need to save the invocation context so we can set it on the
+         * response (or fault) context so the FutureCallback has access to the handler list.
+         */
+        invocationCtx = ic;
     }
 
     public Future<?> getFutureTask() {
@@ -86,6 +97,7 @@
         MessageContext response = null;
         try {
             response = AsyncUtils.createJAXWSMessageContext(result);
+            response.setInvocationContext(invocationCtx);
         } catch (WebServiceException e) {
             cft.setError(e);
             if (debug) {
@@ -111,8 +123,8 @@
             AxisFault fault = (AxisFault)e;
             MessageContext faultMessageContext = null;
             try {
-                faultMessageContext =
-                        AsyncUtils.createJAXWSMessageContext(fault.getFaultMessageContext());
+                faultMessageContext  = AsyncUtils.createJAXWSMessageContext(fault.getFaultMessageContext());
+                faultMessageContext.setInvocationContext(invocationCtx);
             }
             catch (WebServiceException wse) {
                 cft.setError(wse);

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/async/PollingFuture.java Wed Apr 25 22:19:23 2007
@@ -21,6 +21,7 @@
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.client.async.AsyncResult;
 import org.apache.axis2.client.async.Callback;
+import org.apache.axis2.jaxws.core.InvocationContext;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -32,9 +33,16 @@
     private static final Log log = LogFactory.getLog(PollingFuture.class);
 
     private AsyncResponse response;
-
-    public PollingFuture(AsyncResponse ar) {
-        response = ar;
+    private InvocationContext invocationCtx;
+    
+    public PollingFuture(InvocationContext ic) {
+        response = ic.getAsyncResponseListener();
+        
+        /*
+         * TODO review.  We need to save the invocation context so we can set it on the
+         * response (or fault) context so the FutureCallback has access to the handler list.
+         */
+        invocationCtx = ic;
     }
 
     @Override
@@ -47,6 +55,7 @@
         MessageContext responseMsgCtx = null;
         try {
             responseMsgCtx = AsyncUtils.createJAXWSMessageContext(result);
+            responseMsgCtx.setInvocationContext(invocationCtx);
         } catch (WebServiceException e) {
             response.onError(e, null);
             if (debug) {
@@ -73,6 +82,7 @@
             try {
                 faultMessageContext =
                         AsyncUtils.createJAXWSMessageContext(fault.getFaultMessageContext());
+                faultMessageContext.setInvocationContext(invocationCtx);
             }
             catch (WebServiceException wse) {
                 response.onError(wse, null);

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java Wed Apr 25 22:19:23 2007
@@ -21,6 +21,7 @@
 import org.apache.axis2.client.ServiceClient;
 import org.apache.axis2.jaxws.BindingProvider;
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.client.async.AsyncResponse;
 import org.apache.axis2.jaxws.core.InvocationContext;
 import org.apache.axis2.jaxws.core.InvocationContextFactory;
@@ -54,7 +55,9 @@
     private Log log = LogFactory.getLog(BaseDispatch.class);
 
     protected InvocationController ic;
+
     protected ServiceClient serviceClient;
+
     protected Mode mode;
 
     protected BaseDispatch(ServiceDelegate svcDelgate, EndpointDescription epDesc) {
@@ -110,7 +113,7 @@
             if (isValidInvocationParam(obj)) {
                 requestMsg = createMessageFromValue(obj);
             } else {
-                throw ExceptionFactory.makeWebServiceException("dispatchInvalidParam");
+                throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchInvalidParam"));
             }
 
             setupMessageProperties(requestMsg);
@@ -143,11 +146,7 @@
             Object returnObj = getValueFromMessage(responseMsg);
 
             //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());
-            }
+            checkMaintainSessionState(requestMsgCtx, invocationContext);
 
             if (log.isDebugEnabled()) {
                 log.debug("Synchronous invocation completed: BaseDispatch.invoke()");
@@ -185,7 +184,7 @@
             if (isValidInvocationParam(obj)) {
                 requestMsg = createMessageFromValue(obj);
             } else {
-                throw ExceptionFactory.makeWebServiceException("dispatchInvalidParam");
+                throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchInvalidParam"));
             }
 
             setupMessageProperties(requestMsg);
@@ -201,11 +200,7 @@
             ic.invokeOneWay(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());
-            }
+            checkMaintainSessionState(requestMsgCtx, invocationContext);
 
             if (log.isDebugEnabled()) {
                 log.debug("One-way invocation completed: BaseDispatch.invokeOneWay()");
@@ -243,7 +238,7 @@
             if (isValidInvocationParam(obj)) {
                 requestMsg = createMessageFromValue(obj);
             } else {
-                throw ExceptionFactory.makeWebServiceException("dispatchInvalidParam");
+                throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchInvalidParam"));
             }
 
             setupMessageProperties(requestMsg);
@@ -270,11 +265,7 @@
             Future<?> asyncResponse = ic.invokeAsync(invocationContext, asynchandler);
 
             //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());
-            }
+            checkMaintainSessionState(requestMsgCtx, invocationContext);
 
             if (log.isDebugEnabled()) {
                 log.debug("Asynchronous (callback) invocation sent: BaseDispatch.invokeAsync()");
@@ -312,7 +303,7 @@
             if (isValidInvocationParam(obj)) {
                 requestMsg = createMessageFromValue(obj);
             } else {
-                throw ExceptionFactory.makeWebServiceException("dispatchInvalidParam");
+                throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchInvalidParam"));
             }
 
             setupMessageProperties(requestMsg);
@@ -339,11 +330,7 @@
             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());
-            }
+            checkMaintainSessionState(requestMsgCtx, invocationContext);
 
             if (log.isDebugEnabled()) {
                 log.debug("Asynchronous (polling) invocation sent: BaseDispatch.invokeAsync()");
@@ -449,20 +436,20 @@
         // but only in PAYLOAD mode per JAX-WS Section 4.3.2.
         if (!bindingId.equals(HTTPBinding.HTTP_BINDING)) {
             if (mode.equals(Mode.MESSAGE) && object == null) {
-                throw ExceptionFactory.makeWebServiceException("dispatchNullParamMessageMode");
+                throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchNullParamMessageMode"));
             }
         } else {
             // In all cases (PAYLOAD and MESSAGE) we must throw a WebServiceException
             // if the parameter is null.
             if (object == null) {
-                throw ExceptionFactory.makeWebServiceException("dispatchNullParamHttpBinding");
+                throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchNullParamHttpBinding"));
             }
         }
 
         if (object instanceof DOMSource) {
             DOMSource ds = (DOMSource)object;
             if (ds.getNode() == null && ds.getSystemId() == null) {
-                throw ExceptionFactory.makeWebServiceException("dispatchBadDOMSource");
+                throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchBadDOMSource"));
             }
         }
 

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/client/proxy/JAXWSProxyHandler.java Wed Apr 25 22:19:23 2007
@@ -18,6 +18,7 @@
  */
 package org.apache.axis2.jaxws.client.proxy;
 
+import javax.xml.ws.handler.HandlerResolver;
 import org.apache.axis2.jaxws.BindingProvider;
 import org.apache.axis2.jaxws.ExceptionFactory;
 import org.apache.axis2.jaxws.client.async.AsyncResponse;
@@ -32,7 +33,9 @@
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.marshaller.factory.MethodMarshallerFactory;
 import org.apache.axis2.jaxws.message.Message;
+import org.apache.axis2.jaxws.spi.Constants;
 import org.apache.axis2.jaxws.spi.ServiceDelegate;
+import org.apache.axis2.jaxws.spi.migrator.ApplicationContextMigratorUtil;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -76,7 +79,9 @@
 
     //Reference to ServiceDelegate instance that was used to create the Proxy
     protected ServiceDescription serviceDesc = null;
+
     private Class seiClazz = null;
+
     private Method method = null;
 
     public JAXWSProxyHandler(ServiceDelegate delegate, Class seiClazz, EndpointDescription epDesc) {
@@ -163,6 +168,22 @@
                 requestMsg.setMTOMEnabled(true);
             }
         }
+        
+        /*
+         * TODO: review: make sure the handlers are set on the InvocationContext
+         * This implementation of the JAXWS runtime does not use Endpoint, which
+         * would normally be the place to initialize and store the handler list.
+         * In lieu of that, we will have to intialize and store them on the 
+         * InvocationContext.  also see the InvocationContextFactory.  On the client
+         * side, the binding is not yet set when we call into that factory, so the
+         * handler list doesn't get set on the InvocationContext object there.  Thus
+         * we gotta do it here.
+         */
+        
+        // be sure to use whatever handlerresolver is registered on the Service
+        //HandlerResolver handlerResolver = serviceDelegate.getHandlerResolver();
+        //bnd.setHandlerChain(handlerResolver.getHandlerChain(endpointDesc.getPortInfo()));
+        requestIC.setHandlers(bnd.getHandlerChain());
 
         // Before we invoke, copy all of the properties from the client request
         // context to the MessageContext
@@ -175,6 +196,12 @@
         // TODO: Change this to some form of factory so that we can change the IC to
         // a more simple one for marshaller/unmarshaller testing.
         InvocationController controller = new AxisInvocationController();
+        
+        // Migrate the properties from the client request context bag to
+        // the request MessageContext.
+        ApplicationContextMigratorUtil.performMigrationToMessageContext(
+                Constants.APPLICATION_CONTEXT_MIGRATOR_LIST_ID, 
+                getRequestContext(), request);
 
         // Check if the call is OneWay, Async or Sync
         if (operationDesc.isOneWay()) {
@@ -184,12 +211,7 @@
             controller.invokeOneWay(requestIC);
 
             // Check to see if we need to maintain session state
-            if (request.isMaintainSession()) {
-                //TODO: Need to figure out a cleaner way to make this call.  This could probably
-                //make use of the property migrator mentioned above.
-                setupSessionContext(
-                        requestIC.getServiceClient().getServiceContext().getProperties());
-            }
+            checkMaintainSessionState(request, requestIC);
         }
 
         if (method.getReturnType() == Future.class) {
@@ -231,11 +253,7 @@
             Future<?> future = controller.invokeAsync(requestIC, asyncHandler);
 
             //Check to see if we need to maintain session state
-            if (request.isMaintainSession()) {
-                //TODO: Need to figure out a cleaner way to make this call. 
-                setupSessionContext(
-                        requestIC.getServiceClient().getServiceContext().getProperties());
-            }
+            checkMaintainSessionState(request, requestIC);
 
             return future;
         }
@@ -251,11 +269,7 @@
             Response response = controller.invokeAsync(requestIC);
 
             //Check to see if we need to maintain session state
-            if (request.isMaintainSession()) {
-                //TODO: Need to figure out a cleaner way to make this call. 
-                setupSessionContext(
-                        requestIC.getServiceClient().getServiceContext().getProperties());
-            }
+            checkMaintainSessionState(request, requestIC);
 
             return response;
         }
@@ -264,13 +278,16 @@
             InvocationContext responseIC = controller.invoke(requestIC);
 
             //Check to see if we need to maintain session state
-            if (request.isMaintainSession()) {
-                //TODO: Need to figure out a cleaner way to make this call. 
-                setupSessionContext(
-                        requestIC.getServiceClient().getServiceContext().getProperties());
-            }
+            checkMaintainSessionState(request, requestIC);
 
             MessageContext responseContext = responseIC.getResponseMessageContext();
+            
+            // Migrate the properties from the response MessageContext back
+            // to the client response context bag.
+            ApplicationContextMigratorUtil.performMigrationFromMessageContext(
+                    Constants.APPLICATION_CONTEXT_MIGRATOR_LIST_ID, 
+                    getResponseContext(), responseContext);
+            
             Object responseObj = createResponse(method, args, responseContext, operationDesc);
             return responseObj;
         }

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/context/factory/MessageContextFactory.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/context/factory/MessageContextFactory.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/context/factory/MessageContextFactory.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/context/factory/MessageContextFactory.java Wed Apr 25 22:19:23 2007
@@ -19,11 +19,12 @@
 package org.apache.axis2.jaxws.context.factory;
 
 import org.apache.axis2.jaxws.context.WebServiceContextImpl;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.handler.LogicalMessageContext;
 import org.apache.axis2.jaxws.handler.ProtectedMessageContext;
 import org.apache.axis2.jaxws.handler.SoapMessageContext;
 
 import javax.xml.ws.WebServiceContext;
-import javax.xml.ws.handler.MessageContext;
 
 public class MessageContextFactory {
 
@@ -36,12 +37,32 @@
         return new WebServiceContextImpl();
     }
 
-    public static MessageContext createSoapMessageContext(
+    /**
+     * Creates a SOAPMessageContext based on the input core MessageContext.  
+     *       
+     * @param jaxwsMessageContext
+     * @return
+     */
+    public static SoapMessageContext createSoapMessageContext(
             org.apache.axis2.jaxws.core.MessageContext jaxwsMessageContext) {
         return new SoapMessageContext(jaxwsMessageContext);
     }
+    
+    /**
+     * Creates a LogicalMessageContext based on the input core MessageContext.
+     * 
+     * @param mc
+     * @return
+     */
+    public static LogicalMessageContext createLogicalMessageContext(MessageContext mc) {
+        return new LogicalMessageContext(mc);
+    }
 
-    public static MessageContext createProtectedMessageContext(
+    /*
+     * This method is deprecated as we will be removing the ProtectedMessageContext
+     */
+    @Deprecated
+    public static javax.xml.ws.handler.MessageContext createProtectedMessageContext(
             org.apache.axis2.jaxws.core.MessageContext jaxwsMessageContext) {
         return new ProtectedMessageContext(jaxwsMessageContext);
     }

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/context/utils/ContextUtils.java Wed Apr 25 22:19:23 2007
@@ -64,33 +64,33 @@
 
         EndpointDescription description = jaxwsMessageContext.getEndpointDescription();
         if (description !=null) {
-        // Set the WSDL properties
-        ServiceDescription sd =
+            // Set the WSDL properties
+            ServiceDescription sd =
                     description.getServiceDescription();
-        if (sd != null) {
-            URL wsdlLocation = ((ServiceDescriptionWSDL)sd).getWSDLLocation();
-            if (wsdlLocation != null && !"".equals(wsdlLocation)) {
-                URI wsdlLocationURI = null;
-                try {
-                    wsdlLocationURI = wsdlLocation.toURI();
-                }
-                catch (URISyntaxException ex) {
-                    // TODO: NLS/RAS
-                    log.warn("Unable to convert WSDL location URL to URI.  URL: " +
-                            wsdlLocation.toString() + "; Service: " + sd.getServiceQName(), ex);
+            if (sd != null) {
+                URL wsdlLocation = ((ServiceDescriptionWSDL)sd).getWSDLLocation();
+                if (wsdlLocation != null && !"".equals(wsdlLocation)) {
+                    URI wsdlLocationURI = null;
+                    try {
+                        wsdlLocationURI = wsdlLocation.toURI();
+                    }
+                    catch (URISyntaxException ex) {
+                        // TODO: NLS/RAS
+                        log.warn("Unable to convert WSDL location URL to URI.  URL: " +
+                                wsdlLocation.toString() + "; Service: " + sd.getServiceQName(), ex);
+                    }
+                    soapMessageContext
+                            .put(javax.xml.ws.handler.MessageContext.WSDL_DESCRIPTION, wsdlLocationURI);
+                    soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.WSDL_DESCRIPTION,
+                                                Scope.APPLICATION);
                 }
+    
+                soapMessageContext
+                        .put(javax.xml.ws.handler.MessageContext.WSDL_SERVICE, sd.getServiceQName());
                 soapMessageContext
-                        .put(javax.xml.ws.handler.MessageContext.WSDL_DESCRIPTION, wsdlLocationURI);
-                soapMessageContext.setScope(javax.xml.ws.handler.MessageContext.WSDL_DESCRIPTION,
-                                            Scope.APPLICATION);
-            }
-
-            soapMessageContext
-                    .put(javax.xml.ws.handler.MessageContext.WSDL_SERVICE, sd.getServiceQName());
-            soapMessageContext
-                    .setScope(javax.xml.ws.handler.MessageContext.WSDL_SERVICE, Scope.APPLICATION);
-            if (log.isDebugEnabled()) {
-                log.debug("WSDL_SERVICE :" + sd.getServiceQName());
+                        .setScope(javax.xml.ws.handler.MessageContext.WSDL_SERVICE, Scope.APPLICATION);
+                if (log.isDebugEnabled()) {
+                    log.debug("WSDL_SERVICE :" + sd.getServiceQName());
                 }
             }
         }

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContext.java Wed Apr 25 22:19:23 2007
@@ -33,6 +33,8 @@
 
     public List<Handler> getHandlers();
 
+    public void setHandlers(List<Handler> list);
+    
     public MessageContext getRequestMessageContext();
 
     public void setRequestMessageContext(MessageContext ctx);

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/InvocationContextImpl.java Wed Apr 25 22:19:23 2007
@@ -52,8 +52,8 @@
      *
      * @param list
      */
-    public void setHandlers(List<Handler> list) {
-        handlers = list;
+    public void setHandlers(List<Handler> handlers) {
+        this.handlers = handlers;
     }
 
     /** @see InvocationContext#setRequestMessageContext(MessageContext) */

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/MessageContext.java Wed Apr 25 22:19:23 2007
@@ -68,6 +68,9 @@
         if (mc != null) {
             axisMsgCtx = mc;
             message = MessageUtils.getMessageFromMessageContext(mc);
+            if (message != null) {
+                message.setMessageContext(this);
+            }
         } else {
             axisMsgCtx = new org.apache.axis2.context.MessageContext();
         }
@@ -121,6 +124,7 @@
 
     public void setMessage(Message msg) {
         message = msg;
+        msg.setMessageContext(this);
     }
 
     public Message getMessage() {

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/AxisInvocationController.java Wed Apr 25 22:19:23 2007
@@ -228,8 +228,7 @@
 
         CallbackFuture cbf = null;
         if (callback != null) {
-            cbf = new CallbackFuture(ic.getAsyncResponseListener(),
-                                     callback, ic.getExecutor());
+            cbf = new CallbackFuture(ic, callback);
         } else {
             throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr4"));
         }
@@ -303,7 +302,7 @@
         }
 
         AsyncResponse resp = ic.getAsyncResponseListener();
-        PollingFuture pf = new PollingFuture(resp);
+        PollingFuture pf = new PollingFuture(ic);
         opClient.setCallback(pf);
 
         org.apache.axis2.context.MessageContext axisRequestMsgCtx = request.getAxisMessageContext();

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/controller/InvocationController.java Wed Apr 25 22:19:23 2007
@@ -20,6 +20,8 @@
 import org.apache.axis2.jaxws.core.InvocationContext;
 import org.apache.axis2.jaxws.core.MessageContext;
 import org.apache.axis2.jaxws.core.util.MessageContextUtils;
+import org.apache.axis2.jaxws.handler.HandlerChainProcessor;
+import org.apache.axis2.jaxws.handler.HandlerInvokerUtils;
 import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.util.Constants;
 import org.apache.commons.logging.Log;
@@ -27,6 +29,7 @@
 
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Response;
+
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
 
@@ -87,22 +90,39 @@
         request.getProperties().put(Constants.INVOCATION_PATTERN, InvocationPattern.SYNC);
 
         // Invoke outbound handlers.
-        // TODO uncomment, and get the EndpointDescription from the request context, which should soon be available
-        boolean success =
-                true; //HandlerInvokerUtils.invokeOutboundHandlers(request, request.getEndpointDescription(), HandlerChainProcessor.MEP.REQUEST, false);
+        boolean success = HandlerInvokerUtils.invokeOutboundHandlers(request, ic.getHandlers(),
+                        request.getEndpointDescription(), HandlerChainProcessor.MEP.REQUEST, false);
 
         if (success) {
             prepareRequest(request);
             response = doInvoke(request);
             prepareResponse(response);
 
+            /*
+             * TODO TODO TODO review
+             * 
+             * In most cases we are adding the endpointDesc to the
+             * MessageContext. Notice here that the "response" object is set by
+             * the call to doInvoke. It's a new context we are now working with.
+             * The invokeInboundHandlers uses that context way down in
+             * createMessageContext --> ContextUtils.addProperties()
+             * 
+             * This may also occur in the AsyncResponse class when calling
+             * invokeInboundHandlers
+             * 
+             * For now, make sure the endpointDesc is set on the response
+             * context.
+             */
+            response.setEndpointDescription(request.getEndpointDescription());
+
             // Invoke inbound handlers.
-            // TODO uncomment, and get the EndpointDescription from the request context, which should soon be available
-            //HandlerInvokerUtils.invokeInboundHandlers(response, request.getEndpointDescription(), HandlerChainProcessor.MEP.RESPONSE, false);
-        } else
-        { // the outbound handler chain must have had a problem, and we've reversed directions
-            response = MessageContextUtils.createResponseMessageContext(request);
-            // since we've reversed directions, the message has "become a response message" (section 9.3.2.1, footnote superscript 2)
+            HandlerInvokerUtils.invokeInboundHandlers(response, ic.getHandlers(), request
+                            .getEndpointDescription(), HandlerChainProcessor.MEP.RESPONSE, false);
+        } else { // the outbound handler chain must have had a problem, and
+                    // we've reversed directions
+            response = MessageContextUtils.createMinimalResponseMessageContext(request);
+            // since we've reversed directions, the message has "become a
+            // response message" (section 9.3.2.1, footnote superscript 2)
             response.setMessage(request.getMessage());
         }
         ic.setResponseMessageContext(response);
@@ -137,9 +157,7 @@
         request.getProperties().put(Constants.INVOCATION_PATTERN, InvocationPattern.ONEWAY);
 
         // Invoke outbound handlers.
-        // TODO uncomment, and get the EndpointDescription from the request context, which should soon be available
-        boolean success =
-                true; //HandlerInvokerUtils.invokeOutboundHandlers(request, request.getEndpointDescription(), HandlerChainProcessor.MEP.REQUEST, false);
+        boolean success = HandlerInvokerUtils.invokeOutboundHandlers(request, ic.getHandlers(), request.getEndpointDescription(), HandlerChainProcessor.MEP.REQUEST, false);
 
         if (success) {
             prepareRequest(request);
@@ -180,8 +198,7 @@
 
         // Invoke outbound handlers.
         // TODO uncomment, and get the EndpointDescription from the request context, which should soon be available
-        boolean success =
-                true; //HandlerInvokerUtils.invokeOutboundHandlers(request, request.getEndpointDescription(), HandlerChainProcessor.MEP.REQUEST, false);
+        boolean success = HandlerInvokerUtils.invokeOutboundHandlers(request, ic.getHandlers(), request.getEndpointDescription(), HandlerChainProcessor.MEP.REQUEST, false);
         if (success) {
             prepareRequest(request);
             resp = doInvokeAsync(request);
@@ -223,12 +240,12 @@
             throw ExceptionFactory.makeWebServiceException(Messages.getMessage("ICErr2"));
         }
         if ((ic.getExecutor() != null) && (ic.getExecutor() instanceof ExecutorService)) {
-            ExecutorService es = (ExecutorService)ic.getExecutor();
+            ExecutorService es = (ExecutorService) ic.getExecutor();
             if (es.isShutdown()) {
                 // the executor service is shutdown and won't accept new tasks
                 // so return an error back to the client
-                throw ExceptionFactory
-                        .makeWebServiceException(Messages.getMessage("ExecutorShutdown"));
+                throw ExceptionFactory.makeWebServiceException(Messages
+                                .getMessage("ExecutorShutdown"));
             }
         }
 
@@ -238,21 +255,29 @@
         Future<?> future = null;
 
         // Invoke outbound handlers.
-        // TODO uncomment, and get the EndpointDescription from the request context, which should soon be available
-        boolean success =
-                true; //HandlerInvokerUtils.invokeOutboundHandlers(request, request.getEndpointDescription(), HandlerChainProcessor.MEP.REQUEST, false);
+        boolean success = HandlerInvokerUtils.invokeOutboundHandlers(request, ic.getHandlers(),
+                        request.getEndpointDescription(), HandlerChainProcessor.MEP.REQUEST, false);
         if (success) {
             prepareRequest(request);
             future = doInvokeAsync(request, asyncHandler);
-        } else
-        { // the outbound handler chain must have had a problem, and we've reversed directions
-            // since we've reversed directions, the message has "become a response message" (section 9.3.2.1, footnote superscript 2)
+        } else { // the outbound handler chain must have had a problem, and
+                    // we've reversed directions
+            // since we've reversed directions, the message has "become a
+            // response message" (section 9.3.2.1, footnote superscript 2)
+
+            // TODO: how do we deal with this? The response message may or may
+            // not be a fault
+            // message. We do know that the direction has reversed, so somehow
+            // we need to
+            // flow immediately out of the async and give the exception and/or
+            // response object
+            // back to the client app without calling
+            // AsyncResponse.processResponse or processFault
 
-            // TODO we know the message is a fault message, we should
-            // convert it to an exception and throw it.
-            // something like:
+            throw ExceptionFactory
+                            .makeWebServiceException("A client outbound handler cause a message flow direction reversal.  This case is not yet implemented.");
 
-            //throw new AxisFault(request.getMessage());
+            // throw new AxisFault(request.getMessage());
         }
         return future;
     }

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/core/util/MessageContextUtils.java Wed Apr 25 22:19:23 2007
@@ -1,18 +1,20 @@
 /*
- * 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
- *
+ * 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.core.util;
 
@@ -41,13 +43,28 @@
                     MessageContextBuilder.createOutMessageContext(sourceAxisMC);
 
             MessageContext newMC = new MessageContext(newAxisMC);
-
+            newMC.setEndpointDescription(mc.getEndpointDescription());
+            newMC.setOperationDescription(mc.getOperationDescription());
             return newMC;
         } catch (AxisFault e) {
             throw ExceptionFactory.makeWebServiceException(e);
         }
     }
-
+    
+    
+    /*
+     * special messagecontext that has no AxisContext associated with it.  Typically, this
+     * would be used in a "client outbound handler throws exception" case since that would
+     * mean we never hit the InvocationController and thus never hit the Axis layer.
+     */
+    public static MessageContext createMinimalResponseMessageContext(MessageContext mc) {
+        org.apache.axis2.context.MessageContext sourceAxisMC = mc.getAxisMessageContext();
+        MessageContext newMC = new MessageContext(sourceAxisMC);
+        newMC.setEndpointDescription(mc.getEndpointDescription());
+        newMC.setOperationDescription(mc.getOperationDescription());
+        return newMC;
+    }
+    
     /**
      * Given a request MessageContext, create a new MessageContext for a fault response.
      *
@@ -60,12 +77,13 @@
                     MessageContextBuilder.createFaultMessageContext(
                             mc.getAxisMessageContext(), null);
             MessageContext jaxwsFaultMC = new MessageContext(faultMC);
+            jaxwsFaultMC.setEndpointDescription(mc.getEndpointDescription());
+            jaxwsFaultMC.setOperationDescription(mc.getOperationDescription());
             return jaxwsFaultMC;
         }
         catch (AxisFault e) {
-
+            throw ExceptionFactory.makeWebServiceException(e);
         }
-        return null;
     }
 
 }

Modified: webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java?view=diff&rev=532615&r1=532614&r2=532615
==============================================================================
--- webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java (original)
+++ webservices/axis2/branches/java/1_2/modules/jaxws/src/org/apache/axis2/jaxws/handler/HandlerChainProcessor.java Wed Apr 25 22:19:23 2007
@@ -18,45 +18,48 @@
  */
 package org.apache.axis2.jaxws.handler;
 
-import org.apache.axis2.jaxws.ExceptionFactory;
-import org.apache.axis2.jaxws.i18n.Messages;
-import org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils;
-import org.apache.axis2.jaxws.message.Protocol;
-import org.apache.axis2.jaxws.message.XMLFault;
-import org.apache.axis2.jaxws.message.util.XMLFaultUtils;
-import org.apache.axis2.jaxws.utility.SAAJFactory;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 import javax.xml.soap.SOAPBody;
 import javax.xml.soap.SOAPConstants;
-import javax.xml.soap.SOAPException;
 import javax.xml.soap.SOAPFault;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.ws.ProtocolException;
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.Handler;
 import javax.xml.ws.handler.LogicalHandler;
-import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.soap.SOAPHandler;
-import javax.xml.ws.handler.soap.SOAPMessageContext;
-import java.util.ArrayList;
+
+import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.context.factory.MessageContextFactory;
+import org.apache.axis2.jaxws.core.MessageContext;
+import org.apache.axis2.jaxws.i18n.Messages;
+import org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils;
+import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.XMLFault;
+import org.apache.axis2.jaxws.message.factory.MessageFactory;
+import org.apache.axis2.jaxws.message.util.XMLFaultUtils;
+import org.apache.axis2.jaxws.registry.FactoryRegistry;
+import org.apache.axis2.jaxws.utility.SAAJFactory;
 
 public class HandlerChainProcessor {
 
     public enum Direction {
         IN, OUT
-    }
-
-    ;
+    };
 
     // the type of message, not indicative of one-way vs. request-response
     public enum MEP {
         REQUEST, RESPONSE
-    }
+    };
 
-    ;
+    private javax.xml.ws.handler.MessageContext currentMC;
 
     private MessageContext mc;
-    private ArrayList<Handler> handlers = null;
+
+    private List<Handler> handlers = null;
 
     // track start/end of logical and protocol handlers in the list
     // The two scenarios are:  1) run logical handlers only, 2) run all handlers
@@ -69,8 +72,10 @@
     private final static int FAILED = 1;
     private final static int PROTOCOL_EXCEPTION = 2;
     private final static int OTHER_EXCEPTION = 3;
-    // save it if Handler.handleMessage throws one in HandlerChainProcessor.handleMessage
+    // save it if Handler.handleMessage throws one in
+    // HandlerChainProcessor.handleMessage
     private RuntimeException savedException;
+    private Protocol proto; // need to save it incase we have to make a fault message
 
     /*
       * HandlerChainProcess expects null, empty list, or an already-sorted
@@ -79,77 +84,97 @@
       * it may not be sorted.  The processChain and processFault methods check
       * for this by calling verifyChain.
       */
-    public HandlerChainProcessor(ArrayList<Handler> chain) {
+	public HandlerChainProcessor(List<Handler> chain, Protocol proto) {
         if (chain == null) {
             handlers = new ArrayList<Handler>();
-        } else
+		}
+		else
             handlers = chain;
+        this.proto = proto;
     }
 
     /*
-      * verifyChain will check that the chain is properly sorted, since it may be
+      * sortChain will properly sort the chain, logical then protocol, since it may be
       * a chain built or modified by a client application.  Also keep track of
       * start/end for each type of handler.
       */
-    private void verifyChain() throws WebServiceException {
-        boolean protocolHandlersStarted = false;
-        for (Handler handlerClass : handlers) {
-            if (LogicalHandler.class.isAssignableFrom(handlerClass.getClass())) {
-                if (protocolHandlersStarted)
-                    throw ExceptionFactory.makeWebServiceException(Messages.getMessage(
-                            "handlerChainErr0", handlerClass.getClass().getName()));
-                else {
-                    logicalLength++;
-                }
-            } else if (SOAPHandler.class.isAssignableFrom(handlerClass.getClass()))
-                protocolHandlersStarted = true;
-            else if (Handler.class.isAssignableFrom(handlerClass.getClass())) {
-                throw ExceptionFactory.makeWebServiceException(
-                        Messages.getMessage("handlerChainErr1", handlerClass.getClass().getName()));
+	private void sortChain() throws WebServiceException {
+        
+        ArrayList<Handler> logicalHandlers = new ArrayList<Handler>();
+        ArrayList<Handler> protocolHandlers = new ArrayList<Handler>();
+        
+        Iterator handlerIterator = handlers.iterator();
+        
+        while (handlerIterator.hasNext()) {
+            // this is a safe cast since the handlerResolver and binding.setHandlerChain
+            // and InvocationContext.setHandlerChain verifies it before we get here
+            Handler handler = (Handler)handlerIterator.next();
+            // JAXWS 9.2.1.2 sort them by Logical, then SOAP
+            if (LogicalHandler.class.isAssignableFrom(handler.getClass()))
+                logicalHandlers.add((LogicalHandler) handler);
+            else if (SOAPHandler.class.isAssignableFrom(handler.getClass()))
+                // instanceof ProtocolHandler
+                protocolHandlers.add((SOAPHandler) handler);
+            else if (Handler.class.isAssignableFrom(handler.getClass())) {
+                // TODO: NLS better error message
+                throw ExceptionFactory.makeWebServiceException(Messages
+                    .getMessage("handlerChainErr1", handler
+                            .getClass().getName()));
             } else {
-                throw ExceptionFactory.makeWebServiceException(
-                        Messages.getMessage("handlerChainErr2", handlerClass.getClass().getName()));
+                // TODO: NLS better error message
+                throw ExceptionFactory.makeWebServiceException(Messages
+                    .getMessage("handlerChainErr2", handler
+                            .getClass().getName()));
             }
-
         }
-    }
-
-
-    /**
-     * @param mc By the time processChain method is called, we already have the sorted chain, and now
-     *           we have the direction, MEP, MessageContext, and if a response is expected.  We should
-     *           be able to handle everything from here, no pun intended.
-     *           <p/>
-     *           Two things a user of processChain should check when the method completes: 1.  Has the
-     *           MessageContext.MESSAGE_OUTBOUND_PROPERTY changed, indicating reversal of message
-     *           direction 2.  Has the message been converted to a fault message? (indicated by a flag
-     *           in the message)
-     */
-    public MessageContext processChain(MessageContext mc, Direction direction, MEP mep,
-                                       boolean expectResponse) {
-        // make sure it's set:
-        mc.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY, (direction == Direction.OUT));
-
+        
+        logicalLength = logicalHandlers.size();
+        
+        // JAXWS 9.2.1.2 sort them by Logical, then SOAP
+        handlers.clear();
+        handlers.addAll(logicalHandlers);
+        handlers.addAll(protocolHandlers);
+	}
+	
+
+	
+	/**
+	 * @param mc
+	 * By the time processChain method is called, we already have the sorted chain,
+	 * and now we have the direction, MEP, MessageContext, and if a response is expected.  We should
+	 * be able to handle everything from here, no pun intended.
+	 * 
+	 * Two things a user of processChain should check when the method completes:
+	 * 1.  Has the MessageContext.MESSAGE_OUTBOUND_PROPERTY changed, indicating reversal of message direction
+	 * 2.  Has the message been converted to a fault message? (indicated by a flag in the message)
+	 */
+	public boolean processChain(MessageContext mc, Direction direction, MEP mep, boolean expectResponse) {
+
+        if (handlers.size() == 0)
+            return true;
+        
         this.mc = mc;
-        verifyChain();
+        sortChain();
+        initContext(direction);
 
-        if (SOAPMessageContext.class.isAssignableFrom(mc.getClass())) {  // all handlers
-            if (direction == Direction.OUT) {  // 9.3.2 outbound
-                callGenericHandlers(mep, expectResponse, 0, handlers.size() - 1, direction);
-            } else { // IN case - 9.3.2 inbound
-                callGenericHandlers(mep, expectResponse, handlers.size() - 1, 0, direction);
-            }
-        } else {  // logical handlers only
-            if (direction == Direction.OUT) {  // 9.3.2 outbound
-                callGenericHandlers(mep, expectResponse, 0, logicalLength - 1, direction);
-            } else { // IN case - 9.3.2 inbound
-                callGenericHandlers(mep, expectResponse, logicalLength - 1, 0, direction);
-            }
+        if (direction == Direction.OUT) { // 9.3.2 outbound
+            currentMC.put(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY,
+                            (direction == Direction.OUT));
+            callGenericHandlers(mep, expectResponse, 0, handlers.size() - 1, direction);
+        } else { // IN case - 9.3.2 inbound
+            currentMC.put(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY,
+                            (direction == Direction.OUT));
+            callGenericHandlers(mep, expectResponse, handlers.size() - 1, 0, direction);
         }
-        // message context may have been changed to be response, and message converted
+
+        // message context may have been changed to be response, and message
+        // converted
         // according to the JAXWS spec 9.3.2.1 footnote 2
-        return this.mc;
-    }
+        if ((Boolean) (currentMC.get(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY)) != (direction == Direction.OUT))
+            return false;
+        return true;
+
+	}
 
 
     /*
@@ -178,6 +203,8 @@
                 newEnd = 0;
                 newDirection = Direction.IN;
                 i++;
+                if (result == SUCCESSFUL)  // don't switch if failed, since we'll be reversing directions
+                    switchContext(direction, i);
             }
         } else { // IN case
             while ((i >= end) && (result == SUCCESSFUL)) {
@@ -187,11 +214,12 @@
                 newEnd = handlers.size() - 1;
                 newDirection = Direction.OUT;
                 i--;
+                if (result == SUCCESSFUL)  // don't switch if failed, since we'll be reversing directions
+                    switchContext(direction, i);
             }
         }
 
-        if (newDirection ==
-                direction) // we didn't actually process anything, probably due to empty list
+        if (newDirection == direction) // we didn't actually process anything, probably due to empty list
             return;  // no need to continue
 
         // 9.3.2.3 in all situations, we want to close as many handlers as
@@ -217,12 +245,35 @@
                 throw savedException;
             }
         } else { // everything was successful OR finished processing handlers
-            callCloseHandlers(newStart_inclusive, newEnd, newDirection);
+            /*
+             * This is a little confusing. There are several cases we should be
+             * aware of. An incoming request with false expectResponse is
+             * equivalent to server inbound one-way, for example.
+             * 
+             * An outgoing response is server outbound, and is always marked
+             * with a false expectResponse. The problem, however, is that the
+             * direction for the call to closehandlers will be incorrect. In
+             * this case, the handlers should be closed in the opposite order of
+             * the ORIGINAL invocation.
+             */
+            if (mep.equals(MEP.REQUEST)) {
+                // a request that requires no response is a one-way message
+                // and we should only close whomever got invoked
+                callCloseHandlers(newStart_inclusive, newEnd, newDirection);
+            }
+            else {
+                // it's a response, so we can safely assume that 
+                // ALL the handlers were invoked on the request,
+                // so we need to close ALL of them
+                if (direction.equals(Direction.IN))
+                    callCloseHandlers(handlers.size() - 1, 0, direction);
+                else
+                    callCloseHandlers(0, handlers.size() - 1, direction);
+            }
         }
 
     }
 
-
     /*
       * callGenericHandlers_avoidRecursion should ONLY be called from one place.
       * TODO:  We cannot necessarily assume no false returns and no exceptions will be
@@ -235,11 +286,13 @@
 
         if (direction == Direction.OUT) {
             for (; i <= end; i++) {
-                ((Handler)handlers.get(i)).handleMessage(mc);
+                switchContext(direction, i);
+				((Handler) handlers.get(i)).handleMessage(currentMC);
             }
         } else { // IN case
             for (; i >= end; i--) {
-                ((Handler)handlers.get(i)).handleMessage(mc);
+                switchContext(direction, i);
+				((Handler) handlers.get(i)).handleMessage(currentMC);
             }
         }
     }
@@ -254,21 +307,26 @@
     private int handleMessage(Handler handler, Direction direction,
                               boolean expectResponse) throws RuntimeException {
         try {
-            boolean success = handler.handleMessage(mc);
+            boolean success = handler.handleMessage(currentMC);
             if (success)
                 return SUCCESSFUL;
             else {
                 if (expectResponse)
-                    mc.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY, (direction != Direction.OUT));
+                    currentMC.put(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY,
+                                    (direction != Direction.OUT));
                 return FAILED;
             }
         } catch (RuntimeException re) {  // RuntimeException and ProtocolException
             savedException = re;
             if (expectResponse)
                 // mark it as reverse direction
-                mc.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY, (direction != Direction.OUT));
+                currentMC.put(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY,
+                                (direction != Direction.OUT));
             if (ProtocolException.class.isAssignableFrom(re.getClass())) {
-                convertToFaultMessage(mc, re);
+				convertToFaultMessage(mc, re, proto);
+                // just re-initialize the current handler message context since
+                // that will pick up the now-changed message
+                reInitContext();
                 return PROTOCOL_EXCEPTION;
             }
             return OTHER_EXCEPTION;
@@ -283,19 +341,28 @@
       */
     private void callCloseHandlers(int start, int end,
                                    Direction direction) {
+        int i = start;
 
         if (direction == Direction.OUT) {
-            for (int i = start; i <= end; i++) {
+            for (; i <= end; i++) {
                 try {
-                    ((Handler)handlers.get(i)).close(mc);
+                    switchContext(direction, i);
+					((Handler) handlers.get(i)).close(currentMC);
+                    // TODO when we close, are we done with the handler instance, and thus
+                    // may call the PreDestroy annotated method?  I don't think so, especially
+                    // if we've cached the handler list somewhere.
                 } catch (Exception e) {
                     // TODO: log it, but otherwise ignore
                 }
             }
         } else { // IN case
-            for (int i = start; i >= end; i--) {
+            for (; i >= end; i--) {
                 try {
-                    ((Handler)handlers.get(i)).close(mc);
+                    switchContext(direction, i);
+					((Handler) handlers.get(i)).close(currentMC);
+					// TODO when we close, are we done with the handler instance, and thus
+                    // may call the PreDestroy annotated method?  I don't think so, especially
+                    // if we've cached the handler list somewhere.
                 } catch (Exception e) {
                     // TODO: log it, but otherwise ignore
                 }
@@ -304,7 +371,7 @@
     }
 
     /*
-      * callHandleFault is available for a server to use when the endpoint
+     * processFault is available for a server to use when the endpoint
       * throws an exception or a client when it gets a fault response message
       *
       * In both cases, all of the handlers have run successfully in the
@@ -315,11 +382,12 @@
 
         // direction.IN = client
         // direction.OUT = server
-
-        // make sure it's right:
-        mc.put(MessageContext.MESSAGE_OUTBOUND_PROPERTY, (direction == Direction.OUT));
-
-        verifyChain();
+        if (handlers.size() == 0)
+            return;
+        this.mc = mc;
+		sortChain();
+        initContext(direction);
+		currentMC.put(javax.xml.ws.handler.MessageContext.MESSAGE_OUTBOUND_PROPERTY, (direction == Direction.OUT));
 
         try {
             if (direction == Direction.OUT) {
@@ -333,8 +401,10 @@
         } finally {
             // we can close all the Handlers in reverse order
             if (direction == Direction.OUT) {
+                initContext(Direction.IN);
                 callCloseHandlers(handlers.size() - 1, 0, Direction.IN);
             } else { // IN case
+                initContext(Direction.IN);
                 callCloseHandlers(0, handlers.size() - 1, Direction.OUT);
             }
         }
@@ -352,24 +422,29 @@
                                         Direction direction) throws RuntimeException {
 
         int i = start;
+        
+        // we may be starting in the middle of the list, and therefore may need to switch contexts
+        switchContext(direction, i);
 
         if (direction == Direction.OUT) {
             for (; i <= end; i++) {
-                if (((Handler)handlers.get(i)).handleFault(mc) == false) {
+				if (((Handler) handlers.get(i)).handleFault(currentMC) == false) {
                     break;
                 }
+                switchContext(direction, i+1);
             }
         } else { // IN case
             for (; i >= end; i--) {
-                if (((Handler)handlers.get(i)).handleFault(mc) == false) {
+				if (((Handler) handlers.get(i)).handleFault(currentMC) == false) {
                     break;
                 }
+                switchContext(direction, i-1);
             }
         }
     }
 
 
-    public static void convertToFaultMessage(MessageContext mc, Exception e) {
+	public static void convertToFaultMessage(MessageContext mc, Exception e, Protocol protocol) {
 
         // need to check if message is already a fault message or not,
         // probably by way of a flag (isFault) in the MessageContext or Message
@@ -379,12 +454,6 @@
                 * There has GOT to be a better way to do this.
                 */
 
-            // TODO how do we figure out the soap version on the MessageContext without
-            // using the message itself?  Reason for not using the message itself is that
-            // most of the SAAJ methods in Axis2 that we need are unimplemented.
-            // for testing, I'm gonna use soap11.
-            Protocol protocol = Protocol.soap11;
-
             if (protocol == Protocol.soap11 || protocol == Protocol.soap12) {
                 String protocolNS = (protocol == Protocol.soap11) ?
                         SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE :
@@ -401,17 +470,61 @@
                 // TODO something is wrong here.  The message should be a response message, not
                 // a request message.  I don't see how to change that.  (see the debugger...)
                 // TODO probably also need to turn on message.WRITE_XML_DECLARATION
-                ((SoapMessageContext)mc).setMessage(message);
+                mc.setMessage(((MessageFactory)(FactoryRegistry.getFactory(MessageFactory.class))).createFrom(message));
 
             } else {
-                // TODO throw an exception, because we only support SOAP11 and SOAP12, I think.
+                throw ExceptionFactory.makeWebServiceException("We only support SOAP11 and SOAP12 for JAXWS handlers");
             }
 
-        } catch (SOAPException soapex) {
-            // TODO not too sure what to do here.
+        } catch (Exception ex) {
+            throw ExceptionFactory.makeWebServiceException(ex);
         }
 
+	}
+    
+    /*
+     * utility method to re-initialize handlercontext so it picks up a changed 
+     * message under the org.apache.axis2.jaxws.core.MessageContext object
+     * 
+     * TODO: hopefully we can fix this so the message under the handler message context
+     * will grab it without us having to create new objects.
+     */
+    private void reInitContext() {
+        if (currentMC.getClass().isAssignableFrom(LogicalMessageContext.class))
+            currentMC = MessageContextFactory.createLogicalMessageContext(mc);
+        else
+            currentMC = MessageContextFactory.createSoapMessageContext(mc);
     }
 
+    private void initContext(Direction direction) {
+        if (direction == Direction.OUT) {
+            // logical context, then SOAP
+            if ((logicalLength == 0) && (handlers.size() > 0))  // we only have soap handlers
+                currentMC = MessageContextFactory.createSoapMessageContext(mc);
+            else
+                currentMC = MessageContextFactory.createLogicalMessageContext(mc);
+        }
+        else {
+            // SOAP context, then logical
+            if ((logicalLength == handlers.size()) && (handlers.size() > 0))  // we only have logical handlers
+                currentMC = MessageContextFactory.createLogicalMessageContext(mc);
+            else
+                currentMC = MessageContextFactory.createSoapMessageContext(mc);
+        }
+    }
+    
+    private void switchContext(Direction direction, int index) {
+
+        if ((logicalLength == handlers.size()) || (logicalLength == 0))
+            return;  // all handlers must be the same type, so no context switch
+        
+        if (((direction == Direction.OUT) && (index == logicalLength))
+                || ((direction == Direction.IN) && (index == (logicalLength - 1)))) {
+            if (currentMC.getClass().isAssignableFrom(LogicalMessageContext.class))
+                currentMC = MessageContextFactory.createSoapMessageContext(mc);
+            else
+                currentMC = MessageContextFactory.createLogicalMessageContext(mc);
+        }
+    }
 
 }



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