tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rineh...@apache.org
Subject svn commit: r511272 - /incubator/tuscany/branches/sca-java-integration/sca/extensions/axis2/binding/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
Date Sat, 24 Feb 2007 13:51:20 GMT
Author: rineholt
Date: Sat Feb 24 05:51:20 2007
New Revision: 511272

URL: http://svn.apache.org/viewvc?view=rev&rev=511272
Log:
Business exceptions to be sent as soapfaults not in a Axis fautl

Modified:
    incubator/tuscany/branches/sca-java-integration/sca/extensions/axis2/binding/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java

Modified: incubator/tuscany/branches/sca-java-integration/sca/extensions/axis2/binding/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/extensions/axis2/binding/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java?view=diff&rev=511272&r1=511271&r2=511272
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/extensions/axis2/binding/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
(original)
+++ incubator/tuscany/branches/sca-java-integration/sca/extensions/axis2/binding/src/main/java/org/apache/tuscany/binding/axis2/Axis2ServiceInOutSyncMessageReceiver.java
Sat Feb 24 05:51:20 2007
@@ -20,12 +20,15 @@
 
 import java.lang.reflect.InvocationTargetException;
 
+import javax.xml.namespace.QName;
+
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.receivers.AbstractInOutSyncMessageReceiver;
+import org.apache.tuscany.spi.idl.ServiceFaultException;
 import org.apache.tuscany.spi.model.Operation;
 import org.apache.tuscany.spi.wire.InvocationRuntimeException;
 
@@ -46,7 +49,9 @@
 
     @Override
     public void invokeBusinessLogic(MessageContext inMC, MessageContext outMC) throws AxisFault
{
+        QName envQName = null;
         try {
+            envQName= inMC.getEnvelope().getQName();
             OMElement requestOM = inMC.getEnvelope().getBody().getFirstElement();
             Object[] args = new Object[] {requestOM};
             
@@ -64,15 +69,49 @@
 
         } catch (InvocationTargetException e) {
             e.printStackTrace();
-            Throwable t = e.getCause();
-            if (t instanceof Exception) {
-                throw AxisFault.makeFault((Exception)t);
+            throw processMessageFault(envQName.getNamespaceURI(), e.getCause());
+         } catch(InvocationRuntimeException e){
+             e.printStackTrace();
+             throw processMessageFault(envQName.getNamespaceURI(), e.getCause());
+         } catch (AxisFault e) {
+             e.printStackTrace();
+             throw e;
+         } catch (Exception e) {
+             e.printStackTrace();
+             throw AxisFault.makeFault(e);
+         }
+    }
+
+    /**
+     * @param envQName
+     * @param e
+     * @throws AxisFault
+     */
+    private AxisFault processMessageFault(String nsURI, Throwable t)  {
+        
+        if (t instanceof ServiceFaultException) { //Business fault.
+            OMElement faultdetail = null;
+            String reason = "";
+
+            ServiceFaultException sfe = (ServiceFaultException)t;
+            reason= sfe.getMessage(); 
+            reason = reason == null ? "" : reason;
+            Object finfo = sfe.getFaultInfo();
+
+            if (finfo instanceof OMElement) {
+                faultdetail = (OMElement)finfo;
+
             }
-            throw new InvocationRuntimeException(e);
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw AxisFault.makeFault(e);
+            QName faultCode= new QName(nsURI ,
+                                       org.apache.axiom.soap.SOAP12Constants.SOAP_FAULT_VALUE_SENDER);
+            return new AxisFault(faultCode, reason, null, null, faultdetail);
+
+
+        } else if ( t instanceof Exception) {
+            return  AxisFault.makeFault((Exception) t);
         }
+        
 
+        return new AxisFault(t);
     }
 }



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


Mime
View raw message