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 ke...@apache.org on 2007/12/19 05:17:30 UTC

svn commit: r605417 - /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java

Author: keithc
Date: Tue Dec 18 20:17:30 2007
New Revision: 605417

URL: http://svn.apache.org/viewvc?rev=605417&view=rev
Log:
Fixing Fault building when the response if application/xml


Modified:
    webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java?rev=605417&r1=605416&r2=605417&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Utils.java Tue Dec 18 20:17:30 2007
@@ -21,6 +21,7 @@
 package org.apache.axis2.util;
 
 import org.apache.axiom.om.util.UUIDGenerator;
+import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFault;
 import org.apache.axis2.AxisFault;
@@ -471,19 +472,22 @@
         // Else, extract it from the SOAPBody
         if (result == null) {
             SOAPEnvelope envelope = messageContext.getEnvelope();
-            if (envelope == null || envelope.getBody() == null ||
-                envelope.getBody().getFault() == null) {
-                // Not going to be able to 
-                throw new IllegalArgumentException(
-                        "The MessageContext does not have an associated SOAPFault.");
+            SOAPFault soapFault;
+            SOAPBody soapBody;
+            if (envelope != null && (soapBody = envelope.getBody()) != null) {
+                if ((soapFault = soapBody.getFault()) != null) {
+                    return new AxisFault(soapFault, messageContext);
+                }
+                // If its a REST response the content is not a SOAP envelop and hence we will
+                // Have use the soap body as the exception
+                if (messageContext.isDoingREST() && soapBody.getFirstElement() != null) {
+                    return new AxisFault(soapBody.getFirstElement().toString());
+                }
             }
-            SOAPFault soapFault = envelope.getBody().getFault();
-
-            // The AxisFault returned needs to have the MessageContext set on it so that 
-            // other programming models can potentially handle the fault with an 
-            // alternate deserialization.
-            result = new AxisFault(soapFault, messageContext);
+            // Not going to be able to
+            throw new IllegalArgumentException(
+                    "The MessageContext does not have an associated SOAPFault.");
         }
         return result;
-    }    
+    }
 }



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