axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ngalla...@apache.org
Subject svn commit: r503847 - in /webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2: AxisFault.java description/OutInAxisOperation.java util/Utils.java
Date Mon, 05 Feb 2007 19:57:46 GMT
Author: ngallardo
Date: Mon Feb  5 11:57:45 2007
New Revision: 503847

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

Faults throw to async callback client should include a MessageContext to allow for
further processing of the message.

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

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/AxisFault.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/AxisFault.java?view=diff&rev=503847&r1=503846&r2=503847
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/AxisFault.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/AxisFault.java Mon Feb
 5 11:57:45 2007
@@ -20,6 +20,7 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPConstants;
+import org.apache.axiom.soap.SOAPFault;
 import org.apache.axiom.soap.SOAPFaultCode;
 import org.apache.axiom.soap.SOAPFaultDetail;
 import org.apache.axiom.soap.SOAPFaultNode;
@@ -146,7 +147,30 @@
      */
     public AxisFault(SOAPFaultCode soapFaultCode, SOAPFaultReason soapFaultReason,
                      SOAPFaultNode soapFaultNode, SOAPFaultRole soapFaultRole, SOAPFaultDetail
soapFaultDetail) {
+        initializeValues(soapFaultCode, soapFaultReason, soapFaultNode, soapFaultRole, soapFaultDetail);
+    }
+    
+    public AxisFault(SOAPFault fault) { 
+        initializeValues(fault);
+    }
+    
+    public AxisFault(SOAPFault fault, MessageContext faultCtx) {
+        initializeValues(fault);
+        faultMessageContext = faultCtx;
+    }
+    
+    private void initializeValues(SOAPFault fault) {
+        if (fault != null) {
+            initializeValues(fault.getCode(), fault.getReason(), fault.getNode(), 
+                    fault.getRole(), fault.getDetail());
+        }        
+    }
 
+    private void initializeValues(SOAPFaultCode soapFaultCode, 
+                                  SOAPFaultReason soapFaultReason, 
+                                  SOAPFaultNode soapFaultNode, 
+                                  SOAPFaultRole soapFaultRole,
+                                  SOAPFaultDetail soapFaultDetail) {
         if (faultElements == null) {
             // assuming that most of the times fault code, fault string and fault details
are set
             faultElements = new HashMap(3);
@@ -177,7 +201,7 @@
             faultCode = soapFaultCode.getValue().getTextAsQName();
         }
     }
-
+     
     private void setToElementsListIfNotNull(String soapFaultElementName, OMElement soapFaultElement)
{
         if (soapFaultElement != null) {
             faultElements.put(soapFaultElementName, soapFaultElement);

Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java?view=diff&rev=503847&r1=503846&r2=503847
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java
(original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/OutInAxisOperation.java
Mon Feb  5 11:57:45 2007
@@ -379,17 +379,12 @@
                     SOAPEnvelope resenvelope = response.getEnvelope();
                     SOAPBody body = resenvelope.getBody();
                     if (body.hasFault()) {
-                        Exception ex = body.getFault().getException();
-
-                        if (ex != null) {
-                            callback.onError(ex);
-                        } else {
-                            callback.onError(new Exception(body.getFault()
-                                    .getReason().getText()));
-                        }
+                        // If a fault was found, create an AxisFault with a MessageContext
so that
+                        // other programming models can deserialize the fault to an alternative
form.
+                        AxisFault fault = new AxisFault(body.getFault(), response);
+                        callback.onError(fault);
                     } else {
                         AsyncResult asyncResult = new AsyncResult(response);
-
                         callback.onComplete(asyncResult);
                     }
                 }

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?view=diff&rev=503847&r1=503846&r2=503847
==============================================================================
--- 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 Mon Feb
 5 11:57:45 2007
@@ -379,8 +379,11 @@
                 throw new IllegalArgumentException("The MessageContext does not have an associated
SOAPFault.");
             }
             SOAPFault soapFault = envelope.getBody().getFault();
-            result = new AxisFault(soapFault.getCode(), soapFault.getReason(),
-                soapFault.getNode(), soapFault.getRole(), soapFault.getDetail());
+            
+            // 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);
         }
         return result;
     }



---------------------------------------------------------------------
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