axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r545504 - in /webservices/axis2/trunk/java/modules/jaxws: src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java test-resources/log4j.properties
Date Fri, 08 Jun 2007 13:49:00 GMT
Author: dims
Date: Fri Jun  8 06:49:00 2007
New Revision: 545504

URL: http://svn.apache.org/viewvc?view=rev&rev=545504
Log:
Fix for AXIS2-2784 - When exception arises from createMessageFromValue, create Protocol specific
exception instead of the generic WebserviceException / Also switched the logs from INFO to
ERROR to make it less verbose

Modified:
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
    webservices/axis2/trunk/java/modules/jaxws/test-resources/log4j.properties

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java?view=diff&rev=545504&r1=545503&r2=545504
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
(original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/client/dispatch/BaseDispatch.java
Fri Jun  8 06:49:00 2007
@@ -18,10 +18,29 @@
  */
 package org.apache.axis2.jaxws.client.dispatch;
 
+import java.net.HttpURLConnection;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Future;
+
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPFactory;
+import javax.xml.soap.SOAPFault;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Binding;
+import javax.xml.ws.ProtocolException;
+import javax.xml.ws.Response;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.Service.Mode;
+import javax.xml.ws.http.HTTPBinding;
+import javax.xml.ws.http.HTTPException;
+import javax.xml.ws.soap.SOAPBinding;
+import javax.xml.ws.soap.SOAPFaultException;
+
 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;
@@ -29,26 +48,18 @@
 import org.apache.axis2.jaxws.core.controller.AxisInvocationController;
 import org.apache.axis2.jaxws.core.controller.InvocationController;
 import org.apache.axis2.jaxws.description.EndpointDescription;
+import org.apache.axis2.jaxws.i18n.Messages;
 import org.apache.axis2.jaxws.marshaller.impl.alt.MethodMarshallerUtils;
 import org.apache.axis2.jaxws.message.Message;
+import org.apache.axis2.jaxws.message.Protocol;
+import org.apache.axis2.jaxws.message.util.XMLFaultUtils;
 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.axis2.jaxws.utility.SAAJFactory;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.ws.AsyncHandler;
-import javax.xml.ws.Binding;
-import javax.xml.ws.ProtocolException;
-import javax.xml.ws.Response;
-import javax.xml.ws.Service.Mode;
-import javax.xml.ws.WebServiceException;
-import javax.xml.ws.http.HTTPBinding;
-import javax.xml.ws.soap.SOAPBinding;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Future;
-
 public abstract class BaseDispatch<T> extends BindingProvider
         implements javax.xml.ws.Dispatch {
 
@@ -110,10 +121,14 @@
             invocationContext.setRequestMessageContext(requestMsgCtx);
 
             Message requestMsg = null;
-            if (isValidInvocationParam(obj)) {
-                requestMsg = createMessageFromValue(obj);
-            } else {
-                throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchInvalidParam"));
+            try {
+                if (isValidInvocationParam(obj)) {
+                    requestMsg = createMessageFromValue(obj);
+                } else {
+                    throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchInvalidParam"));
+                }
+            } catch (Exception e) {
+                throw getProtocolException(e);
             }
 
             setupMessageProperties(requestMsg);
@@ -181,10 +196,14 @@
             invocationContext.setRequestMessageContext(requestMsgCtx);
 
             Message requestMsg = null;
-            if (isValidInvocationParam(obj)) {
-                requestMsg = createMessageFromValue(obj);
-            } else {
-                throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchInvalidParam"));
+            try {
+                if (isValidInvocationParam(obj)) {
+                    requestMsg = createMessageFromValue(obj);
+                } else {
+                    throw ExceptionFactory.makeWebServiceException(Messages.getMessage("dispatchInvalidParam"));
+                }
+            } catch (Exception e){
+                throw getProtocolException(e);
             }
 
             setupMessageProperties(requestMsg);
@@ -378,6 +397,37 @@
         }
 
         return null;
+    }
+    
+    private ProtocolException getProtocolException(Exception e) {
+        if (getBinding() instanceof SOAPBinding) {
+            // Throw a SOAPFaultException
+            if (log.isDebugEnabled()) {
+                log.debug("Constructing SOAPFaultException for " + e);
+            }
+            try {
+                SOAPFault soapFault = SOAPFactory.newInstance().createFault();
+                soapFault.setFaultString(e.getMessage());
+                return new SOAPFaultException(soapFault);
+            } catch (Exception ex) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Exception occurred during fault processing:", ex);
+                }
+                return ExceptionFactory.makeProtocolException(e.getMessage(), null);
+            }
+        } else if (getBinding() instanceof HTTPBinding) {
+            if (log.isDebugEnabled()) {
+                log.debug("Constructing ProtocolException for " + e);
+            }
+            HTTPException ex = new HTTPException(HttpURLConnection.HTTP_INTERNAL_ERROR);
+            ex.initCause(new Throwable(e.getMessage()));
+            return ex;
+        } else {
+            if (log.isDebugEnabled()) {
+                log.debug("Constructing ProtocolException for " + e);
+            }
+            return ExceptionFactory.makeProtocolException(e.getMessage(), null);
+        }
     }
 
     /**

Modified: webservices/axis2/trunk/java/modules/jaxws/test-resources/log4j.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test-resources/log4j.properties?view=diff&rev=545504&r1=545503&r2=545504
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test-resources/log4j.properties (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test-resources/log4j.properties Fri Jun  8
06:49:00 2007
@@ -17,7 +17,7 @@
 # Set root category priority to INFO and its only appender to CONSOLE.
 #log4j.rootCategory=DEBUG, CONSOLE
 #log4j.rootCategory=INFO, CONSOLE, LOGFILE
-log4j.rootCategory=INFO, CONSOLE
+log4j.rootCategory=ERROR, CONSOLE
 
 # Set the enterprise logger priority to FATAL
 log4j.logger.org.apache.axis2.enterprise=FATAL



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


Mime
View raw message