Return-Path: Delivered-To: apmail-ws-tuscany-commits-archive@locus.apache.org Received: (qmail 91932 invoked from network); 24 Feb 2007 13:51:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 24 Feb 2007 13:51:42 -0000 Received: (qmail 55572 invoked by uid 500); 24 Feb 2007 13:51:50 -0000 Delivered-To: apmail-ws-tuscany-commits-archive@ws.apache.org Received: (qmail 55552 invoked by uid 500); 24 Feb 2007 13:51:50 -0000 Mailing-List: contact tuscany-commits-help@ws.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: tuscany-dev@ws.apache.org Delivered-To: mailing list tuscany-commits@ws.apache.org Received: (qmail 55543 invoked by uid 99); 24 Feb 2007 13:51:50 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Feb 2007 05:51:50 -0800 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 24 Feb 2007 05:51:41 -0800 Received: by eris.apache.org (Postfix, from userid 65534) id 08DB01A981A; Sat, 24 Feb 2007 05:51:21 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: tuscany-commits@ws.apache.org From: rineholt@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070224135121.08DB01A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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