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 he...@apache.org on 2005/07/27 07:26:23 UTC

svn commit: r225456 - in /webservices/axis/trunk/java/modules: core/src/org/apache/axis2/clientapi/ core/src/org/apache/axis2/engine/ xml/src/org/apache/axis2/soap/impl/llom/soap11/ xml/src/org/apache/axis2/soap/impl/llom/soap12/

Author: hemapani
Date: Tue Jul 26 22:25:56 2005
New Revision: 225456

URL: http://svn.apache.org/viewcvs?rev=225456&view=rev
Log:
checking in the soap processing model and fixes for http://issues.apache.org/jira/browse/AXIS2-96

Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/clientapi/InOutMEPClient.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/clientapi/MEPClient.java
    webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/SOAPProcessingModelChecker.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap11/SOAP11Constants.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap12/SOAP12Constants.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/clientapi/InOutMEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/clientapi/InOutMEPClient.java?rev=225456&r1=225455&r2=225456&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/clientapi/InOutMEPClient.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/clientapi/InOutMEPClient.java Tue Jul 26 22:25:56 2005
@@ -18,6 +18,7 @@
 package org.apache.axis2.clientapi;
 
 import java.io.IOException;
+import java.util.Iterator;
 
 import javax.xml.namespace.QName;
 
@@ -34,8 +35,12 @@
 import org.apache.axis2.engine.AxisEngine;
 import org.apache.axis2.engine.AxisFault;
 import org.apache.axis2.i18n.Messages;
+import org.apache.axis2.om.OMElement;
 import org.apache.axis2.om.OMException;
 import org.apache.axis2.soap.SOAPEnvelope;
+import org.apache.axis2.soap.SOAPFault;
+import org.apache.axis2.soap.SOAPFaultDetail;
+import org.apache.axis2.soap.impl.llom.SOAPConstants;
 import org.apache.axis2.transport.TransportListener;
 import org.apache.axis2.util.threadpool.AxisWorker;
 import org.apache.wsdl.WSDLConstants;
@@ -182,8 +187,21 @@
             //check for a fault and return the result
             SOAPEnvelope resenvelope = response.getEnvelope();
             if (resenvelope.getBody().hasFault()) {
-                throw new AxisFault(
-                    resenvelope.getBody().getFault().getException());
+                SOAPFault soapFault = resenvelope.getBody().getFault();
+                SOAPFaultDetail faultDetail = soapFault.getDetail();
+                //if there is exception throw it
+                if(faultDetail != null){
+                    Iterator it = faultDetail.getAllDetailEntries();
+                    while(it.hasNext()){
+                        OMElement detailElement = (OMElement)it.next();
+                        if(SOAPConstants.SOAP_FAULT_DETAIL_EXCEPTION_ENTRY.equals(detailElement.getLocalName())){
+                            throw new AxisFault(soapFault.getException());
+                        }
+                    }
+                }
+                //throw new exception with reason
+                throw new AxisFault(soapFault.getReason().getText());
+                
             }
             return response;
         }

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/clientapi/MEPClient.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/clientapi/MEPClient.java?rev=225456&r1=225455&r2=225456&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/clientapi/MEPClient.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/clientapi/MEPClient.java Tue Jul 26 22:25:56 2005
@@ -24,6 +24,7 @@
 import org.apache.axis2.context.ServiceContext;
 import org.apache.axis2.description.OperationDescription;
 import org.apache.axis2.description.TransportOutDescription;
+import org.apache.axis2.engine.AxisConfiguration;
 import org.apache.axis2.engine.AxisFault;
 import org.apache.axis2.i18n.Messages;
 import org.apache.axis2.om.OMAbstractFactory;
@@ -54,7 +55,6 @@
         doREST = b;
     }
 
-
     public String getSoapAction() {
         return soapAction;
     }
@@ -68,19 +68,21 @@
      * prepare the message context for invocation, here the properties kept in the 
      * MEPClient copied to the MessageContext
      */
-    protected void prepareInvocation(OperationDescription axisop,
-                                    MessageContext msgCtx) throws AxisFault {
+    protected void prepareInvocation(OperationDescription axisop, MessageContext msgCtx)
+        throws AxisFault {
         if (axisop == null) {
             throw new AxisFault(Messages.getMessage("cannotBeNullOperationDescription"));
         }
         //make sure operation is type right MEP
         if (mep.equals(axisop.getMessageExchangePattern())) {
-            throw new AxisFault(Messages.getMessage("mepClientSupportOnly",
-                mep,axisop.getMessageExchangePattern()));
+            throw new AxisFault(
+                Messages.getMessage(
+                    "mepClientSupportOnly",
+                    mep,
+                    axisop.getMessageExchangePattern()));
         }
         //if operation not alrady added, add it
-        if (serviceContext.getServiceConfig().getOperation(axisop.getName()) ==
-                null) {
+        if (serviceContext.getServiceConfig().getOperation(axisop.getName()) == null) {
             serviceContext.getServiceConfig().addOperation(axisop);
         }
         msgCtx.setDoingREST(doREST);
@@ -98,15 +100,14 @@
      * @throws AxisFault
      */
     protected MessageContext prepareTheSOAPEnvelope(OMElement toSend) throws AxisFault {
-        MessageContext msgctx = new MessageContext(
-                serviceContext.getEngineContext());
+        MessageContext msgctx = new MessageContext(serviceContext.getEngineContext());
 
         SOAPEnvelope envelope = createDefaultSOAPEnvelope();
         envelope.getBody().addChild(toSend);
         msgctx.setEnvelope(envelope);
         return msgctx;
     }
-    
+
     /**
      * try to infer the transport looking at the URL, the URL can be http:// 
      * tcp:// mail:// local://. The method will look for the trnasport name as the 
@@ -126,8 +127,8 @@
         }
 
         if (transport != null) {
-            return serviceContext.getEngineContext().getAxisConfiguration()
-                    .getTransportOut(new QName(transport));
+            return serviceContext.getEngineContext().getAxisConfiguration().getTransportOut(
+                new QName(transport));
 
         } else {
             throw new AxisFault(Messages.getMessage("cannotInferTransport"));
@@ -143,15 +144,14 @@
         SOAPFactory fac = null;
         if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapVersionURI)) {
             fac = OMAbstractFactory.getSOAP12Factory();
-        } else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(
-                soapVersionURI)) {
+        } else if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(soapVersionURI)) {
             fac = OMAbstractFactory.getSOAP11Factory();
         } else {
             throw new AxisFault(Messages.getMessage("invaidSOAPversion"));
         }
         return fac.getDefaultEnvelope();
     }
-    
+
     /**
      * Engage a given Module to the current invocation. But to call this method the 
      * Module *MUST* be enable (picked up by the deployment and known to Axis2) else
@@ -160,10 +160,12 @@
      * @throws AxisFault
      */
     public void engageModule(QName name) throws AxisFault {
-        serviceContext.getEngineContext().getAxisConfiguration().engageModule(
-                name);
+        AxisConfiguration axisConf = serviceContext.getEngineContext().getAxisConfiguration();
+        //if it is already engeged do not engege it agaien
+        if (!axisConf.isEngaged(name)) {
+            axisConf.engageModule(name);
+        }
     }
-
 
     /**
      * @param string

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/SOAPProcessingModelChecker.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/SOAPProcessingModelChecker.java?rev=225456&r1=225455&r2=225456&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/SOAPProcessingModelChecker.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis2/engine/SOAPProcessingModelChecker.java Tue Jul 26 22:25:56 2005
@@ -23,6 +23,8 @@
 import org.apache.axis2.handlers.AbstractHandler;
 import org.apache.axis2.soap.SOAPEnvelope;
 import org.apache.axis2.soap.SOAPHeaderBlock;
+import org.apache.axis2.soap.impl.llom.soap11.SOAP11Constants;
+import org.apache.axis2.soap.impl.llom.soap12.SOAP12Constants;
 
 /**
  * This handler checks that the SOAP processing model rules have been followed
@@ -30,31 +32,49 @@
  */
 public class SOAPProcessingModelChecker extends AbstractHandler {
 
-public void invoke(MessageContext msgContext) throws AxisFault {
-    // determine SOAP version of message (waiting for Chinthaka's
-    // method)
-//  	boolean isSOAP12 = true;
-//   
-//       SOAPEnvelope se = msgContext.getEnvelope();
-//        if (se.getHeader() == null) {
-//            return;
-//        }
-//        Iterator hbs = se.getHeader().examineAllHeaderBlocks();
-//        while (hbs.hasNext()) {
-//            SOAPHeaderBlock hb = (SOAPHeaderBlock) hbs.next();
-//
-//            // if this header block has been processed or mustUnderstand isn't
-//            // turned on then its cool
-//            if (hb.isProcessed() || !hb.getMustUnderstand())
-//                continue;
-//            }
-//
-//            // if this header block is not targetted to me then its not my
-//            // problem. Currently this code only supports the "next" role; we
-//            // need to fix this to allow the engine/service to be in one or more
-//            // additional roles and then to check that any headers targetted for
-//            // that role too have been dealt with.
-//        	if there's no role or if the role is NEXT then throw fault
-//        }
+    public void invoke(MessageContext msgContext) throws AxisFault {
+        SOAPEnvelope se = msgContext.getEnvelope();
+        if (se.getHeader() == null) {
+            return;
+        }
+        Iterator hbs = se.getHeader().examineAllHeaderBlocks();
+        while (hbs.hasNext()) {
+            SOAPHeaderBlock hb = (SOAPHeaderBlock) hbs.next();
+
+            // if this header block has been processed or mustUnderstand isn't
+            // turned on then its cool
+            if (hb.isProcessed() || !hb.getMustUnderstand()) {
+                continue;
+            }
+            // if this header block is not targetted to me then its not my
+            // problem. Currently this code only supports the "next" role; we
+            // need to fix this to allow the engine/service to be in one or more
+            // additional roles and then to check that any headers targetted for
+            // that role too have been dealt with.
+
+            boolean isSOAP12 =
+                SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(msgContext.getSOAPVersion());
+            String role = hb.getRole();
+
+            if (isSOAP12) {
+                //if must understand and soap 1.2 the Role should be NEXT , if it is null we considerr
+                // it to be NEXT
+                if (role != null && !SOAP12Constants.SOAP_ROLE_NEXT.equals(role)) {
+                    throw new AxisFault("Must Understand check failed");
+                }
+                
+                //TODO what should be do with the Ulitmate Receiver? Axis2 is ultimate Receiver most of the time
+                //should we support that as well
+            } else {
+                //if must understand and soap 1.1 the actor should be NEXT , if it is null we considerr
+                // it to be NEXT
+                if (role != null && !SOAP11Constants.SOAP_ACTOR_NEXT.equals(role)) {
+                    throw new AxisFault("Must Understand check failed");
+                }
+            }
+
+        }
+
     }
+
 }

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap11/SOAP11Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap11/SOAP11Constants.java?rev=225456&r1=225455&r2=225456&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap11/SOAP11Constants.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap11/SOAP11Constants.java Tue Jul 26 22:25:56 2005
@@ -46,4 +46,6 @@
 
     //SOAP 1.2 Content Type
     public static final String SOAP_11_CONTENT_TYPE = "text/xml";
+    
+    public static final String SOAP_ACTOR_NEXT = "http://schemas.xmlsoap.org/soap/actor/next";
 }

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap12/SOAP12Constants.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap12/SOAP12Constants.java?rev=225456&r1=225455&r2=225456&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap12/SOAP12Constants.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis2/soap/impl/llom/soap12/SOAP12Constants.java Tue Jul 26 22:25:56 2005
@@ -59,4 +59,9 @@
 
     //SOAP 1.2 Content Type
     public static final String SOAP_12_CONTENT_TYPE = "application/soap+xml";
+    
+    public static final String SOAP_ROLE_NEXT = "http://www.w3.org/2003/05/soap-envelope/role/next";
+    public static final String SOAP_ROLE_NONE = "http://www.w3.org/2003/05/soap-envelope/role/next";
+    public static final String SOAP_ROLE_ULTIMATE_RECEIVER = "http://www.w3.org/2003/05/soap-envelope/role/ultimateReceiver";
+    
 }