ode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r583213 - in /ode/branches/APACHE_ODE_1.1: axis2/src/main/java/org/apache/ode/axis2/ axis2/src/main/java/org/apache/ode/axis2/hooks/ axis2/src/main/java/org/apache/ode/axis2/util/ utils/src/main/java/org/apache/ode/utils/
Date Tue, 09 Oct 2007 16:29:30 GMT
Author: mriou
Date: Tue Oct  9 09:29:23 2007
New Revision: 583213

URL: http://svn.apache.org/viewvc?rev=583213&view=rev
Log:
Soap faults extravaganza, made sure we got them properly, transmit them properly and return
them properly. Should comply a bit more with the profile as well.

Modified:
    ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
    ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEService.java
    ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEMessageReceiver.java
    ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
    ode/branches/APACHE_ODE_1.1/utils/src/main/java/org/apache/ode/utils/Namespaces.java

Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java?rev=583213&r1=583212&r2=583213&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
(original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ExternalService.java
Tue Oct  9 09:29:23 2007
@@ -112,6 +112,7 @@
             options.setAction(mctx.getSoapAction());
             options.setTo(axisEPR);
             options.setTimeOutInMilliSeconds(60000);
+            options.setExceptionToBeThrownOnSOAPFault(false);
 
             AuthenticationHelper.setHttpAuthentication(odeMex, options);
 
@@ -150,10 +151,13 @@
                                     operationClient.execute(true);
                                     MessageContext response = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
                                     MessageContext flt = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_FAULT_VALUE);
+                                    if (response != null && __log.isDebugEnabled())
+                                        __log.debug("Got service response: " + response.getEnvelope().toString());
+
                                     if (flt != null) {
                                         reply(mexId, operation, flt, true);
                                     } else {
-                                        reply(mexId, operation, response, false);
+                                        reply(mexId, operation, response, response.isFault());
                                     }
                                 } catch (Throwable t) {
                                     String errmsg = "Error sending message (mex=" + odeMex
+ "): " + t.getMessage();
@@ -306,11 +310,13 @@
         try {
             if (fault) {
                 faultType = _converter.parseSoapFault(odeMsgEl, reply.getEnvelope(), operation);
+                if (__log.isDebugEnabled()) __log.debug("Reply is a fault, found type: "
+ faultType);
             } else {
                 faultType = null;
                 _converter.parseSoapResponse(odeMsgEl, reply.getEnvelope(), operation);
             }
         } catch (AxisFault af) {
+            __log.warn("Message format error, failing.", af);
             replyWithFailure(odeMexId, FailureType.FORMAT_ERROR, af.getMessage(), null);
             return;
         }
@@ -320,8 +326,9 @@
             _sched.execIsolatedTransaction(new Callable<Void>() {
                 public Void call() throws Exception {
                     PartnerRoleMessageExchange odeMex = (PartnerRoleMessageExchange)  _server.getEngine().getMessageExchange(odeMexId);
+                    QName nonNullFT = faultType != null ? faultType : new QName(Namespaces.ODE_EXTENSION_NS,
"unknownFault");
                     Message response = fault ? odeMex.createMessage(odeMex.getOperation().getFault(
-                            faultType.getLocalPart()).getMessage().getQName()) : odeMex.createMessage(odeMex
+                            nonNullFT.getLocalPart()).getMessage().getQName()) : odeMex.createMessage(odeMex
                             .getOperation().getOutput().getMessage().getQName());
                     try {
                         if (__log.isDebugEnabled()) {

Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEService.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEService.java?rev=583213&r1=583212&r2=583213&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEService.java (original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/ODEService.java Tue
Oct  9 09:29:23 2007
@@ -20,8 +20,7 @@
 package org.apache.ode.axis2;
 
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.*;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.description.AxisService;
@@ -173,7 +172,7 @@
                     onResponse(odeMex, outMsgContext);
                     commit = true;
                 } catch (AxisFault af) {
-                    __log.error("Error processing response for MEX " + odeMex, af);
+                    __log.warn("MEX produced a fault " + odeMex, af);
                     commit = true;
                     throw af;
                 } catch (Exception e) {
@@ -216,9 +215,12 @@
             case FAULT:
                 if (__log.isDebugEnabled())
                     __log.debug("Fault response message: " + mex.getFault());
-                OMElement detail = _converter.createSoapFault(mex.getFaultResponse().getMessage(),
mex.getFault(), mex.getOperation());
-                String reason = mex.getFault()+" "+mex.getFaultExplanation();
-                throw new AxisFault(mex.getFault(), reason, null, null, detail);
+                SOAPFault fault = _converter.createSoapFault(mex.getFaultResponse().getMessage(),
mex.getFault(), mex.getOperation());
+                msgContext.getEnvelope().getBody().addFault(fault);
+
+                if (__log.isDebugEnabled())
+                    __log.debug("Returning fault: " + msgContext.getEnvelope().toString());
+                break;
             case ASYNC:
             case RESPONSE:
                 _converter.createSoapResponse(msgContext, mex.getResponse().getMessage(),
mex.getOperation());

Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEMessageReceiver.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEMessageReceiver.java?rev=583213&r1=583212&r2=583213&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEMessageReceiver.java
(original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/hooks/ODEMessageReceiver.java
Tue Oct  9 09:29:23 2007
@@ -35,56 +35,57 @@
  */
 public class ODEMessageReceiver extends AbstractMessageReceiver {
 
-  private static final Log __log = LogFactory.getLog(ODEMessageReceiver.class);
+    private static final Log __log = LogFactory.getLog(ODEMessageReceiver.class);
 
-  private ODEService _service;
+    private ODEService _service;
 
-  public final void invokeBusinessLogic(final MessageContext msgContext) throws AxisFault
{
-    if (hasResponse(msgContext.getAxisOperation())) {
+    public final void invokeBusinessLogic(final MessageContext msgContext) throws AxisFault
{
+        if (hasResponse(msgContext.getAxisOperation())) {
             if (__log.isDebugEnabled())
                 __log.debug("Received request message for " + msgContext.getAxisService().getName()
+ "."
                         + msgContext.getAxisOperation().getName());
-      // Client is expecting a response, running in the same thread
-      MessageContext outMsgContext = Utils.createOutMessageContext(msgContext);
-      outMsgContext.getOperationContext().addMessageContext(outMsgContext);
-      invokeBusinessLogic(msgContext, outMsgContext);
-      if (__log.isDebugEnabled()) {
+            // Client is expecting a response, running in the same thread
+            MessageContext outMsgContext = Utils.createOutMessageContext(msgContext);
+            outMsgContext.getOperationContext().addMessageContext(outMsgContext);
+            invokeBusinessLogic(msgContext, outMsgContext);
+            if (__log.isDebugEnabled()) {
                 __log.debug("Reply for " + msgContext.getAxisService().getName() + "."
                         + msgContext.getAxisOperation().getName());
-        __log.debug("Reply message " + outMsgContext.getEnvelope());
-      }
+                __log.debug("Reply message " + outMsgContext.getEnvelope());
+            }
             AxisEngine engine = new AxisEngine(msgContext.getOperationContext().getServiceContext()
                     .getConfigurationContext());
-      engine.send(outMsgContext);
-    } else {
+            engine.send(outMsgContext);
+        } else {
             if (__log.isDebugEnabled())
                 __log.debug("Received one-way message for " + msgContext.getAxisService().getName()
+ "."
                         + msgContext.getAxisOperation().getName());
             invokeBusinessLogic(msgContext, null);
+        }
     }
-  }
 
-  private void invokeBusinessLogic(MessageContext msgContext, MessageContext outMsgContext)
-          throws AxisFault {
-    _service.onAxisMessageExchange(msgContext, outMsgContext, getSOAPFactory(msgContext));
-  }
-
-  public void setService(ODEService service) {
-    _service = service;
-  }
+    private void invokeBusinessLogic(MessageContext msgContext, MessageContext outMsgContext)
+            throws AxisFault {
+        _service.onAxisMessageExchange(msgContext, outMsgContext, getSOAPFactory(msgContext));
 
-  private boolean hasResponse(AxisOperation op) {
+    }
+
+    public void setService(ODEService service) {
+        _service = service;
+    }
+
+    private boolean hasResponse(AxisOperation op) {
         switch (op.getAxisSpecificMEPConstant()) {
-        case WSDLConstants.MEP_CONSTANT_IN_OUT:
-            return true;
-        case WSDLConstants.MEP_CONSTANT_OUT_ONLY:
-            return true;
-        case WSDLConstants.MEP_CONSTANT_OUT_OPTIONAL_IN:
-            return true;
-        case WSDLConstants.MEP_CONSTANT_ROBUST_OUT_ONLY:
-            return true;
-        default:
-            return false;
+            case WSDLConstants.MEP_CONSTANT_IN_OUT:
+                return true;
+            case WSDLConstants.MEP_CONSTANT_OUT_ONLY:
+                return true;
+            case WSDLConstants.MEP_CONSTANT_OUT_OPTIONAL_IN:
+                return true;
+            case WSDLConstants.MEP_CONSTANT_ROBUST_OUT_ONLY:
+                return true;
+            default:
+                return false;
+        }
     }
-  }
 }

Modified: ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java?rev=583213&r1=583212&r2=583213&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
(original)
+++ ode/branches/APACHE_ODE_1.1/axis2/src/main/java/org/apache/ode/axis2/util/SoapMessageConverter.java
Tue Oct  9 09:29:23 2007
@@ -22,10 +22,7 @@
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAPFactory;
-import org.apache.axiom.soap.SOAPFault;
-import org.apache.axiom.soap.SOAPFaultDetail;
+import org.apache.axiom.soap.*;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.namespace.Constants;
@@ -258,7 +255,20 @@
 
     }
 
-    public OMElement createSoapFault(Element message, QName faultName, Operation op) throws
AxisFault {
+    public SOAPFault createSoapFault(Element message, QName faultName, Operation op) throws
AxisFault {
+        OMElement detail = buildSoapDetail(message, faultName, op);
+
+        SOAPFault fault = _soapFactory.createSOAPFault();
+        SOAPFaultCode code = _soapFactory.createSOAPFaultCode(fault);
+        code.setText(new QName(Namespaces.SOAP_ENV_NS, "Server"));
+        SOAPFaultReason reason = _soapFactory.createSOAPFaultReason(fault);
+        reason.setText(faultName);
+        SOAPFaultDetail soapDetail = _soapFactory.createSOAPFaultDetail(fault);
+        soapDetail.addDetailEntry(detail.getFirstElement());
+        return fault;
+    }
+
+    private OMElement buildSoapDetail(Element message, QName faultName, Operation op) throws
AxisFault {
         if (faultName.getNamespaceURI() == null || !faultName.getNamespaceURI().equals(_def.getTargetNamespace()))
             return toFaultDetail(faultName, message);
         Fault f = op.getFault(faultName.getLocalPart());
@@ -519,7 +529,8 @@
         if (flt.getDetail() == null)
             return null;
 
-        QName elName = flt.getDetail().getQName();
+        // The detail is a dummy <detail> node containing the interesting fault element
+        QName elName = flt.getDetail().getFirstElement().getQName();
         for (Fault f : (Collection<Fault>)operation.getFaults().values()) {
             if (f.getMessage() == null)
                 continue;  // should have checked in ctor
@@ -533,7 +544,6 @@
 
             if (p.getElementName().equals(elName))
                 return f;
-
         }
 
         return null;

Modified: ode/branches/APACHE_ODE_1.1/utils/src/main/java/org/apache/ode/utils/Namespaces.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.1/utils/src/main/java/org/apache/ode/utils/Namespaces.java?rev=583213&r1=583212&r2=583213&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/utils/src/main/java/org/apache/ode/utils/Namespaces.java (original)
+++ ode/branches/APACHE_ODE_1.1/utils/src/main/java/org/apache/ode/utils/Namespaces.java Tue
Oct  9 09:29:23 2007
@@ -44,6 +44,7 @@
     public static final String WS_ADDRESSING_WSDL_NS = "http://www.w3.org/2006/05/addressing/wsdl";
     public static final String WS_ADDRESSING_ANON_URI = "http://www.w3.org/2005/08/addressing/anonymous";
     public static final String SOAP_NS = "http://schemas.xmlsoap.org/wsdl/soap/";
+    public static final String SOAP_ENV_NS = "http://schemas.xmlsoap.org/soap/envelope/";
   
     public static final String WSDL_11 = "http://schemas.xmlsoap.org/wsdl/";
     public static final String WSDL_20 = "http://www.w3.org/2006/01/wsdl";
     public static final String XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";



Mime
View raw message