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 sc...@apache.org on 2008/09/19 18:11:04 UTC

svn commit: r697141 - in /webservices/axis2/trunk/java/modules: jaxws-integration/test/org/apache/axis2/jaxws/sample/ jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/ jaxws/src/org/apache/axis2/jaxws/ jaxws/src/org/apache/axis2/j...

Author: scheu
Date: Fri Sep 19 09:11:04 2008
New Revision: 697141

URL: http://svn.apache.org/viewvc?rev=697141&view=rev
Log:
AXIS2-4039
Summary of Changes:
  1) Added a new property "javax.outbound.response.webmethod.exception" that contains the Exception thrown
     from a web service implementation.  This property is only available on the outbound server response, and
     is provided so that a customer can access the exception in a jax-ws handler.
     
  2) Changed the AddNumberWithHandlers sample to test and verify the new code.  The service is changed to 
     throw both checked and unchecked exceptions.  An outbound jaxws handler uses the new property to 
     access the exception and add the stack trace to the faultString.  (This is one of the scenarios that
     the customer will use).  The client verifies proper processing.
     
  3) Also added a test to verify that this property does not hinder message context persistence.
     We don't necessarily need to support persistence of this property...the test only ensures that the new 
     property does not break persistance.

Modified:
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersHandlerPortTypeImpl.java
    webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersProtocolHandler.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Constants.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaDispatcher.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java?rev=697141&r1=697140&r2=697141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/AddNumbersHandlerTests.java Fri Sep 19 09:11:04 2008
@@ -32,6 +32,7 @@
 import java.util.concurrent.Future;
 
 import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPFault;
 import javax.xml.transform.Result;
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
@@ -59,6 +60,7 @@
 import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersClientLogicalHandler3;
 import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersClientLogicalHandler4;
 import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersClientProtocolHandler;
+import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersHandlerFault_Exception;
 import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersHandlerPortType;
 import org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersHandlerService;
 import org.test.addnumbershandler.AddNumbersHandlerResponse;
@@ -143,6 +145,191 @@
 		}
 	}
     
+    /**
+     * Client app sends MAXVALUE, MAXVALUE as params to add.
+     * No client-side handlers are configured for this scenario.  
+     * The endpoint method (addNumbersHandler) will detect the possible overflow and
+     * throw an application exception, AddNumbersHandleFault_Exception.
+     * 
+     * The server-side AddNumbersProtocolHandler will
+     * access the thrown exception using the "jaxws.webmethod.exception"
+     * property and add the stack trace string to fault string.
+     * 
+     * The client should receive a AddNumbersHandlerFault_Exception that has a stack
+     * trace as part of the message.
+     * This test verifies the following:
+     * 
+     * 1)  Proper exception/fault processing when handlers are installed.
+     * 2)  Access to the special "jaxws.webmethod.exception"
+     * 3)  Proper exception call flow when an application exception is thrown.
+     */
+    public void testAddNumbersHandler_WithCheckedException() throws Exception {
+
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+
+        AddNumbersHandlerService service = new AddNumbersHandlerService();
+        AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+        BindingProvider p = (BindingProvider)proxy;
+        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+        AddNumbersHandlerFault_Exception expectedException = null;
+        Throwable t = null;
+        try {
+            proxy.addNumbersHandler(Integer.MAX_VALUE, Integer.MAX_VALUE);
+            
+        } catch (Throwable e) {
+            // An exception is expected
+            t = e;
+            
+        } 
+        
+        // Make sure the proper exception is thrown
+        if (t == null) {
+            fail("Expected AddNumbersHandlerFault_Exception to be thrown");
+        }
+        if (t instanceof AddNumbersHandlerFault_Exception) {
+            expectedException = (AddNumbersHandlerFault_Exception) t;
+        } else {
+            fail("Expected AddNumbersHandlerFault_Exception to be thrown, " +
+                        "but the exception is: " + t);
+        }
+       
+        // also confirm that @PreDestroy method is called.  Since it only makes sense to call it on the managed
+        // (server) side and just before the handler instance goes out of scope, we are creating a file in the
+        // @PreDestroy method, and will check for its existance here.  If the file does not exist, it means
+        // @PreDestroy method was never called.  The file is set to .deleteOnExit(), so no need to delete it.
+        File file = new File("AddNumbersProtocolHandler.preDestroy.txt");
+        assertTrue("File AddNumbersProtocolHandler.preDestroy.txt does not exist, meaning the @PreDestroy method was not called.", file.exists());
+
+        String log = readLogFile();
+        String expected_calls =
+            "AddNumbersLogicalHandler2 POST_CONSTRUCT\n"
+            + "AddNumbersProtocolHandler2 GET_HEADERS\n"
+            + "AddNumbersProtocolHandler GET_HEADERS\n"
+            + "AddNumbersProtocolHandler HANDLE_MESSAGE_INBOUND\n"
+            + "AddNumbersProtocolHandler2 HANDLE_MESSAGE_INBOUND\n"
+            + "AddNumbersLogicalHandler2 HANDLE_MESSAGE_INBOUND\n"
+            + "AddNumbersLogicalHandler HANDLE_MESSAGE_INBOUND\n"
+            + "AddNumbersLogicalHandler HANDLE_FAULT_OUTBOUND\n"
+            + "AddNumbersLogicalHandler2 HANDLE_FAULT_OUTBOUND\n"
+            + "AddNumbersProtocolHandler2 HANDLE_FAULT_OUTBOUND\n"
+            + "AddNumbersProtocolHandler HANDLE_FAULT_OUTBOUND\n"
+            + "AddNumbersLogicalHandler CLOSE\n"
+            + "AddNumbersLogicalHandler2 CLOSE\n"
+            + "AddNumbersProtocolHandler2 CLOSE\n"
+            + "AddNumbersProtocolHandler CLOSE\n"
+            + "AddNumbersProtocolHandler PRE_DESTROY\n";
+        
+        assertEquals(expected_calls, log);
+        
+        TestLogger.logger.debug("Expected Exception is " + 
+                                expectedException.getMessage());
+        
+        // The outbound service handler adds the stack trace to the 
+        // message.  Make sure the stack trace contains the AddNumbersHandlerPortTypeImpl
+        assertTrue("A stack trace was not present in the returned exception's message:" + 
+                   expectedException.getMessage(),
+                   expectedException.getMessage().indexOf("AddNumbersHandlerPortTypeImpl") > 0);
+
+        TestLogger.logger.debug("----------------------------------");
+        
+    }
+    
+    /**
+     * Client app sends MAXVALUE, MAXVALUE as params to add.
+     * No client-side handlers are configured for this scenario.  
+     * The endpoint method (addNumbersHandler) will detect the possible overflow and
+     * throw an unchecked exception, NullPointerException.
+     * 
+     * The server-side AddNumbersProtocolHandler will
+     * access the thrown exception using the "jaxws.webmethod.exception"
+     * property and add the stack trace string to fault string.
+     * 
+     * The client should receive a SOAPFaultException that has a stack
+     * trace as part of the message.
+     * This test verifies the following:
+     * 
+     * 1)  Proper exception/fault processing when handlers are installed.
+     * 2)  Access to the special "jaxws.webmethod.exception"
+     * 3)  Proper exception call flow when an unchecked exception is thrown.
+     */
+    public void testAddNumbersHandler_WithUnCheckedException() throws Exception {
+
+        TestLogger.logger.debug("----------------------------------");
+        TestLogger.logger.debug("test: " + getName());
+
+        AddNumbersHandlerService service = new AddNumbersHandlerService();
+        AddNumbersHandlerPortType proxy = service.getAddNumbersHandlerPort();
+
+        BindingProvider p = (BindingProvider)proxy;
+        p.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, axisEndpoint);
+        SOAPFaultException expectedException = null;
+        Throwable t = null;
+        try {
+            proxy.addNumbersHandler(-1000, Integer.MIN_VALUE);
+            
+        } catch (Throwable e) {
+            // An exception is expected
+            t = e;
+            
+        } 
+        
+        // Make sure the proper exception is thrown
+        if (t == null) {
+            fail("Expected AddNumbersHandlerFault_Exception to be thrown");
+        }
+        if (t instanceof SOAPFaultException) {
+            expectedException = (SOAPFaultException) t;
+        } else {
+            fail("Expected SOAPFaultException to be thrown, " +
+                        "but the exception is: " + t);
+        }
+       
+        // also confirm that @PreDestroy method is called.  Since it only makes sense to call it on the managed
+        // (server) side and just before the handler instance goes out of scope, we are creating a file in the
+        // @PreDestroy method, and will check for its existance here.  If the file does not exist, it means
+        // @PreDestroy method was never called.  The file is set to .deleteOnExit(), so no need to delete it.
+        File file = new File("AddNumbersProtocolHandler.preDestroy.txt");
+        assertTrue("File AddNumbersProtocolHandler.preDestroy.txt does not exist, meaning the @PreDestroy method was not called.", file.exists());
+
+        String log = readLogFile();
+        String expected_calls =
+            "AddNumbersLogicalHandler2 POST_CONSTRUCT\n"
+            + "AddNumbersProtocolHandler2 GET_HEADERS\n"
+            + "AddNumbersProtocolHandler GET_HEADERS\n"
+            + "AddNumbersProtocolHandler HANDLE_MESSAGE_INBOUND\n"
+            + "AddNumbersProtocolHandler2 HANDLE_MESSAGE_INBOUND\n"
+            + "AddNumbersLogicalHandler2 HANDLE_MESSAGE_INBOUND\n"
+            + "AddNumbersLogicalHandler HANDLE_MESSAGE_INBOUND\n"
+            + "AddNumbersLogicalHandler HANDLE_FAULT_OUTBOUND\n"
+            + "AddNumbersLogicalHandler2 HANDLE_FAULT_OUTBOUND\n"
+            + "AddNumbersProtocolHandler2 HANDLE_FAULT_OUTBOUND\n"
+            + "AddNumbersProtocolHandler HANDLE_FAULT_OUTBOUND\n"
+            + "AddNumbersLogicalHandler CLOSE\n"
+            + "AddNumbersLogicalHandler2 CLOSE\n"
+            + "AddNumbersProtocolHandler2 CLOSE\n"
+            + "AddNumbersProtocolHandler CLOSE\n"
+            + "AddNumbersProtocolHandler PRE_DESTROY\n";
+        
+        assertEquals(expected_calls, log);
+        
+        // The outbound service handler adds the stack trace to the 
+        // message.  Make sure the stack trace contains the AddNumbersHandlerPortTypeImpl
+        
+        TestLogger.logger.debug("Expected Exception is " + 
+                                expectedException.getMessage());
+        
+        SOAPFault fault = expectedException.getFault();
+        assertTrue("A stack trace was not present in the returned exception's message:" + 
+                   fault.getFaultString(),
+                   fault.getFaultString().indexOf("AddNumbersHandlerPortTypeImpl") > 0);
+                   
+
+        TestLogger.logger.debug("----------------------------------");
+        
+    }
+    
     public void testAddNumbersHandlerDispatch() {
         try {
             QName serviceName =
@@ -511,9 +698,9 @@
             e.printStackTrace();
             assertTrue("Exception should be SOAPFaultException", e instanceof SOAPFaultException);
             //AXIS2-2417 - assertEquals(((SOAPFaultException)e).getMessage(), "AddNumbersLogicalHandler2 was here");
-            assertEquals(((SOAPFaultException)e).getMessage(), "Got value 101.  " +
+            assertTrue(((SOAPFaultException)e).getMessage().contains("Got value 101.  " +
             		"AddNumbersHandlerPortTypeImpl.addNumbersHandler method is " +
-            		"correctly throwing this exception as part of testing");
+            		"correctly throwing this exception as part of testing"));
             
             String log = readLogFile();
             String expected_calls = "AddNumbersClientLogicalHandler HANDLE_MESSAGE_OUTBOUND\n"

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersHandlerPortTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersHandlerPortTypeImpl.java?rev=697141&r1=697140&r2=697141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersHandlerPortTypeImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersHandlerPortTypeImpl.java Fri Sep 19 09:11:04 2008
@@ -20,8 +20,10 @@
 package org.apache.axis2.jaxws.sample.addnumbershandler;
 
 import org.apache.axis2.jaxws.TestLogger;
+import org.test.addnumbershandler.AddNumbersHandlerFault;
 import org.test.addnumbershandler.AddNumbersHandlerResponse;
 
+
 import javax.annotation.Resource;
 import javax.jws.HandlerChain;
 import javax.jws.WebService;
@@ -37,17 +39,17 @@
 
     private WebServiceContext ctx;
     
-	/* (non-Javadoc)
-	 * @see org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersHandlerPortType#addNumbersHandler(int, int)
-	 */
-	public int addNumbersHandler(int arg0, int arg1) throws AddNumbersHandlerFault_Exception {
+    /* (non-Javadoc)
+     * @see org.apache.axis2.jaxws.sample.addnumbershandler.AddNumbersHandlerPortType#addNumbersHandler(int, int)
+     */
+    public int addNumbersHandler(int arg0, int arg1) throws AddNumbersHandlerFault_Exception {
 
-	    /* FIXME: getHeaders() is currently not called
+        /* FIXME: getHeaders() is currently not called
 	    if (!tracker.isCalled(HandlerTracker.Methods.GET_HEADERS)) {
 	        throw new RuntimeException("getHeaders() was not called on the handler");
 	    }
-	    */
-	    
+         */
+
         // for these properties tests to always pass, an inbound server-side handler must "put" them
         MessageContext mc = ctx.getMessageContext();
         String propKey1 = "AddNumbersLogicalHandlerInboundAppScopedProperty";
@@ -57,14 +59,34 @@
             throw new RuntimeException("Property value for key \"" + propKey1 + "\" was null, but is APPLICATION scoped and should be accessible by the endpoint");
         if (mc.containsKey(propKey2))  // instead of "get", use "containsKey" to be a little more robust in testing
             throw new RuntimeException("MessageContext.containsKey reported true for key \"" + propKey2 + "\" was not null.  This property is HANDLER scoped and should not be accessible by the endpoint");
-        TestLogger.logger
-                .debug(">> Received addNumbersHandler request for " + arg0 + " and " + arg1);
-        if (arg0 == 101)
-            throw new RuntimeException("Got value 101.  AddNumbersHandlerPortTypeImpl.addNumbersHandler method is correctly throwing this exception as part of testing");
-        return arg0+arg1;
-	}
+        TestLogger.logger.debug(">> Received addNumbersHandler request for " + arg0 + " and " + arg1);
+        if (arg0 == 101) {
+            throw new RuntimeException("Got value 101.  " +
+                        "AddNumbersHandlerPortTypeImpl.addNumbersHandler method is " +
+                        "correctly throwing this exception as part of testing");
+        }
+        
+        long sum = (long) arg0 + (long) arg1;
+        TestLogger.logger.debug(">> Sum is " + sum);
+        TestLogger.logger.debug(">> MAX_VALUE is " + Integer.MAX_VALUE);
+        TestLogger.logger.debug(">> MIN_VALUE is " + Integer.MIN_VALUE);
+        
+        // For testing purposes, an overflow triggers an application exception AddNumbersHandlerPortType
+        // For testing purposes, an underflow triggers an NPE.
+        if (sum > Integer.MAX_VALUE) {
+            TestLogger.logger.debug("Overflow detected.  Throwing AddNumbersHandlerFault");
+            AddNumbersHandlerFault faultInfo = new AddNumbersHandlerFault();
+            faultInfo.setFaultInfo("overflow");
+            faultInfo.setMessage("overflow");
+            throw new AddNumbersHandlerFault_Exception("overflow", faultInfo);
+        } else if (sum < Integer.MIN_VALUE) {
+            TestLogger.logger.debug("Underflow detected.  Throwing NullPointerException");
+            throw new NullPointerException("underflow");
+        }
+        return (int) sum;
+    }
 
-	public Future<?> addNumbersHandlerAsync(int arg0, int arg1, AsyncHandler<AddNumbersHandlerResponse> asyncHandler) {
+    public Future<?> addNumbersHandlerAsync(int arg0, int arg1, AsyncHandler<AddNumbersHandlerResponse> asyncHandler) {
         return null;
     }
 

Modified: webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersProtocolHandler.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersProtocolHandler.java?rev=697141&r1=697140&r2=697141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersProtocolHandler.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws-integration/test/org/apache/axis2/jaxws/sample/addnumbershandler/AddNumbersProtocolHandler.java Fri Sep 19 09:11:04 2008
@@ -20,11 +20,13 @@
 package org.apache.axis2.jaxws.sample.addnumbershandler;
 
 import org.apache.axis2.jaxws.ExceptionFactory;
+import org.apache.axis2.jaxws.TestLogger;
 
 import javax.annotation.PreDestroy;
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.namespace.QName;
+import javax.xml.soap.SOAPFault;
 import javax.xml.ws.WebServiceException;
 import javax.xml.ws.handler.MessageContext;
 import javax.xml.ws.handler.soap.SOAPMessageContext;
@@ -48,6 +50,26 @@
     
     public boolean handleFault(SOAPMessageContext messagecontext) {
         tracker.handleFault((Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY));
+        
+        try {
+            SOAPFault fault = messagecontext.getMessage().getSOAPBody().getFault();
+            String faultString = fault.getFaultString();
+            Throwable webmethodException = (Throwable)
+                messagecontext.get("jaxws.outbound.response.webmethod.exception");
+            
+            // Update the fault string with the stack trace
+            if (webmethodException != null) {
+                TestLogger.logger.debug("The webmethod exception is available...setting the fault string");
+                faultString += "stack = " +  stackToString(webmethodException);
+                fault.setFaultString(faultString);
+            } else {
+                TestLogger.logger.debug("The webmethod exception was not available");
+            }
+        } catch (Exception e) {
+            tracker.log("Exception occurred:" + e.getMessage(),
+                        (Boolean) messagecontext.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY));
+        }
+        
         return true;
     }
 
@@ -109,4 +131,12 @@
     	}
     }
 
+    private static String stackToString(Throwable e) {
+        java.io.StringWriter sw = new java.io.StringWriter();
+        java.io.BufferedWriter bw = new java.io.BufferedWriter(sw);
+        java.io.PrintWriter pw = new java.io.PrintWriter(bw);
+        e.printStackTrace(pw);
+        pw.close();
+        return sw.getBuffer().toString();
+    }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Constants.java?rev=697141&r1=697140&r2=697141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/Constants.java Fri Sep 19 09:11:04 2008
@@ -56,4 +56,11 @@
      */
     public static final String CHECKED_EXCEPTION =
         "org.apache.axis2.jaxws.checkedException";
+    
+    /**
+     * If an exception is thrown by the JAXWS webservice's webmethod, the 
+     * Throwable object is placed in the service outbound response context.
+     */
+    public static final String JAXWS_WEBMETHOD_EXCEPTION = 
+        org.apache.axis2.Constants.JAXWS_WEBMETHOD_EXCEPTION;
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java?rev=697141&r1=697140&r2=697141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaBeanDispatcher.java Fri Sep 19 09:11:04 2008
@@ -107,7 +107,7 @@
             return null;
         } else if (faultThrown) {
             response = createFaultResponse(mc, mc.getMessage().getProtocol(), fault);
-            setCheckedExceptionProperty(response, target, fault);
+            setExceptionProperties(response, target, fault);
         } else {
             response = createResponse(mc, mc.getMessage().getProtocol(), methodInputParams, output);
         }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaDispatcher.java?rev=697141&r1=697140&r2=697141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/JavaDispatcher.java Fri Sep 19 09:11:04 2008
@@ -158,7 +158,7 @@
                     // If a fault was thrown, we need to create a slightly different
                     // MessageContext, than in the response path.
                     response = createFaultResponse(request, fault);
-                    setCheckedExceptionProperty(response, method, fault);
+                    setExceptionProperties(response, method, fault);
                 } else {
                     if (log.isDebugEnabled()) {
                         log.debug("Async invocation of the endpoint was successful.  Creating response message.");
@@ -259,4 +259,35 @@
         }
     }
     
+    /**
+     * Store the actual exception on the response context
+     * @param response MessageContext
+     * @param t Throwable
+     */
+    protected static void setWebMethodExceptionProperty(MessageContext response, 
+                                                        Throwable t) {
+        // Get the root of the exception
+        if (t instanceof InvocationTargetException) {
+            t = ((InvocationTargetException) t).getTargetException();
+        }
+        
+        // Add the property
+        if (t != null) {
+            response.setProperty(Constants.JAXWS_WEBMETHOD_EXCEPTION, t);
+        }
+    }
+    
+    /**
+     * Information about the exception is stored on the outbound response context
+     * @param response MessageContext
+     * @param m Method
+     * @param t Throwable
+     */
+    protected static void setExceptionProperties(MessageContext response, 
+                                                 Method m, 
+                                                 Throwable t) {
+        setCheckedExceptionProperty(response, m, t);
+        setWebMethodExceptionProperty(response, t);
+    }
+    
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java?rev=697141&r1=697140&r2=697141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/server/dispatcher/ProviderDispatcher.java Fri Sep 19 09:11:04 2008
@@ -140,7 +140,7 @@
             // If a fault was thrown, we need to create a slightly different
             // MessageContext, than in the response path.
             responseMsgCtx = createFaultResponse(request, fault);
-            setCheckedExceptionProperty(responseMsgCtx, target, fault);
+            setExceptionProperties(responseMsgCtx, target, fault);
         } else {
             responseMsgCtx = createResponse(request, input, responseParamValue);
         }

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java?rev=697141&r1=697140&r2=697141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/message/MessagePersistanceTests.java Fri Sep 19 09:11:04 2008
@@ -30,6 +30,7 @@
 import org.apache.axiom.om.util.CopyUtils;
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.Constants;
 import org.apache.axis2.Constants.Configuration;
 import org.apache.axis2.datasource.jaxb.JAXBDataSource;
 import org.apache.axis2.jaxws.core.MessageContext;
@@ -122,6 +123,12 @@
         org.apache.axis2.context.MessageContext axisMC = jaxwsMC.getAxisMessageContext();
         MessageUtils.putMessageOnMessageContext(m, jaxwsMC.getAxisMessageContext());
         
+        // Add other properties to the MessageContext
+        axisMC.setProperty(Constants.JAXWS_WEBMETHOD_EXCEPTION, new NullPointerException());
+        axisMC.setProperty("keyString", "valueString");
+        axisMC.setProperty("keyInteger", new Integer(5));
+        
+        
         // Make sure the Axiom structure is intact
         SOAPEnvelope env = axisMC.getEnvelope();
         SOAPBody body = env.getBody();
@@ -205,6 +212,23 @@
         // At this point in time, the restoredMessage will be a full tree.
         // TODO If this changes, please add more assertions here.
         
+        // Check persisted properties
+        
+        // The exception might be persisted....but in the very least it should
+        // not cause an exception.
+        Throwable t = (Throwable) restoredMC.getProperty(Constants.JAXWS_WEBMETHOD_EXCEPTION);
+        assertTrue(t == null || t instanceof NullPointerException);
+        
+        // Make sure the keyString property was persisted
+        String valueString =  (String) restoredMC.getProperty("keyString");
+        assertTrue("valueString".equals(valueString));
+        
+        // Make sure the keyInteger property was persisted.
+        Integer valueInteger =  (Integer) restoredMC.getProperty("keyInteger");
+        assertTrue(valueInteger == 5);
+        
+        axisMC.setProperty("keyInteger", new Integer(5));
+        
         // Simulate transport
         baos = new ByteArrayOutputStream();
         env = restoredMC.getEnvelope();

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java?rev=697141&r1=697140&r2=697141&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/Constants.java Fri Sep 19 09:11:04 2008
@@ -286,6 +286,11 @@
     // Keys to access JAXWS Request and Response SOAP Headers
     public static final String JAXWS_OUTBOUND_SOAP_HEADERS  = "jaxws.binding.soap.headers.outbound";
     public static final String JAXWS_INBOUND_SOAP_HEADERS = "jaxws.binding.soap.headers.inbound";
+    
+    // If the JAXWS WebMethod throws an exception on the server, the exception is
+    // stored on the server outbound MessageContext.  This is the key to access that Throwable object.
+    public static final String JAXWS_WEBMETHOD_EXCEPTION = 
+        "jaxws.outbound.response.webmethod.exception";
 
     /**
      * A MessageContext property or client Option stating the JMS correlation id