axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chinth...@apache.org
Subject svn commit: r202333 - in /webservices/axis/trunk/java/modules: core/src/org/apache/axis/engine/ xml/src/org/apache/axis/om/impl/llom/ xml/src/org/apache/axis/soap/ xml/src/org/apache/axis/soap/impl/llom/ xml/src/org/apache/axis/soap/impl/llom/factory/ ...
Date Wed, 29 Jun 2005 08:14:35 GMT
Author: chinthaka
Date: Wed Jun 29 01:14:34 2005
New Revision: 202333

URL: http://svn.apache.org/viewcvs?rev=202333&view=rev
Log:
- Fixing OM namespace bug
- Adding correct SOAP fault handling to AxisEngine

Modified:
    webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisEngine.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/OMElementImpl.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/SOAPFactory.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/SOAPFault.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultImpl.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/factory/SOAPLinkedListImplFactory.java
    webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/soap11/SOAP11Factory.java

Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisEngine.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisEngine.java?rev=202333&r1=202332&r2=202333&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisEngine.java (original)
+++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/engine/AxisEngine.java Wed
Jun 29 01:14:34 2005
@@ -22,9 +22,10 @@
 import org.apache.axis.description.TransportOutDescription;
 import org.apache.axis.om.OMAbstractFactory;
 import org.apache.axis.om.OMOutput;
-import org.apache.axis.soap.SOAPBody;
-import org.apache.axis.soap.SOAPEnvelope;
+import org.apache.axis.soap.*;
 import org.apache.axis.soap.impl.llom.SOAPProcessingException;
+import org.apache.axis.soap.impl.llom.SOAPConstants;
+import org.apache.axis.soap.impl.llom.soap12.SOAP12Constants;
 import org.apache.axis.transport.TransportSender;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -45,8 +46,6 @@
 
     /**
      * Constructor AxisEngine
-     *
-     *
      */
     public AxisEngine(ConfigurationContext engineContext) {
         log.info("Axis Engine Started");
@@ -103,7 +102,7 @@
         try {
             ConfigurationContext sysCtx = msgContext.getSystemContext();
             ArrayList phases =
-                sysCtx.getAxisConfiguration().getInPhasesUptoAndIncludingPostDispatch();
+                    sysCtx.getAxisConfiguration().getInPhasesUptoAndIncludingPostDispatch();
 
             if (paused) {
                 resumeInvocationPhases(phases, msgContext);
@@ -148,11 +147,10 @@
 
             // create a SOAP envelope with the Fault
             MessageContext faultContext =
-                new MessageContext(
-                    engineContext,
-                    context.getSessionContext(),
-                    context.getTransportIn(),
-                    context.getTransportOut());
+                    new MessageContext(engineContext,
+                            context.getSessionContext(),
+                            context.getTransportIn(),
+                            context.getTransportOut());
 
             if (context.getFaultTo() != null) {
                 faultContext.setFaultTo(context.getFaultTo());
@@ -171,8 +169,14 @@
             faultContext.setProcessingFault(true);
             faultContext.setServerSide(true);
             SOAPEnvelope envelope = null;
+
             try {
-                envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
+
+                if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(context.getEnvelope().getNamespace().getName()))
{
+                    envelope = OMAbstractFactory.getSOAP12Factory().getDefaultFaultEnvelope();
+                } else {
+                    envelope = OMAbstractFactory.getSOAP11Factory().getDefaultFaultEnvelope();
+                }
             } catch (SOAPProcessingException e1) {
                 throw new AxisFault(e1);
             }
@@ -180,7 +184,10 @@
             // TODO do we need to set old Headers back?
             SOAPBody body = envelope.getBody();
             e.printStackTrace();
-            body.addFault(new AxisFault(e.getMessage(), e));
+            
+//            body.addFault(new AxisFault(e.getMessage(), e));
+            body.getFault().setException(new AxisFault(e.getMessage(), e));
+            extractFaultInformationFromMessageContext(context, envelope.getBody().getFault());
 
             faultContext.setEnvelope(envelope);
 
@@ -202,6 +209,33 @@
         }
     }
 
+    private void extractFaultInformationFromMessageContext(MessageContext context, SOAPFault
fault) {
+        Object faultCode = context.getProperty(SOAP12Constants.SOAP_FAULT_CODE_LOCAL_NAME);
+        if (faultCode != null) {
+            fault.setCode((SOAPFaultCode) faultCode);
+        }
+
+        Object faultReason = context.getProperty(SOAP12Constants.SOAP_FAULT_REASON_LOCAL_NAME);
+        if (faultReason != null) {
+            fault.setReason((SOAPFaultReason) faultReason);
+        }
+
+        Object faultRole = context.getProperty(SOAP12Constants.SOAP_FAULT_ROLE_LOCAL_NAME);
+        if (faultRole != null) {
+            fault.getRole().setText((String) faultRole);
+        }
+
+        Object faultNode = context.getProperty(SOAP12Constants.SOAP_FAULT_NODE_LOCAL_NAME);
+        if (faultNode != null) {
+            fault.getNode().setText((String) faultNode);
+        }
+
+        Object faultDetail = context.getProperty(SOAP12Constants.SOAP_FAULT_DETAIL_LOCAL_NAME);
+        if (faultDetail != null) {
+            fault.setDetail((SOAPFaultDetail) faultDetail);
+        }
+    }
+
     private void verifyContextBuilt(MessageContext msgctx) throws AxisFault {
         if (msgctx.getSystemContext() == null) {
             throw new AxisFault("ConfigurationContext can not be null");
@@ -245,8 +279,9 @@
     /* -----------------   Methods related to storage ----------------------------------------------*/
     /**
      * Stores an object in the underlying storage
+     *
      * @param context The relevant engine context
-     * @param obj the object to be stored
+     * @param obj     the object to be stored
      * @return the storage key
      */
     public Object store(ConfigurationContext context, Object obj) {
@@ -255,10 +290,11 @@
 
     /**
      * retrieves an object from the underlying storage
-     * @see #store(org.apache.axis.context.EngineContext, Object)
+     *
      * @param context
      * @param key
      * @return
+     * @see #store(org.apache.axis.context.EngineContext, Object)
      */
     public Object retrieve(ConfigurationContext context, Object key) {
         return context.getStorage().get(key);
@@ -266,9 +302,10 @@
 
     /**
      * removes an object from the underlying storage
+     *
      * @param context
      * @param key
-     * @return  the object removed
+     * @return the object removed
      */
     public Object remove(ConfigurationContext context, Object key) {
         return context.getStorage().remove(key);
@@ -276,6 +313,7 @@
 
     /**
      * Clears the underlying storage
+     *
      * @param context
      * @return
      */

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/OMElementImpl.java?rev=202333&r1=202332&r2=202333&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/OMElementImpl.java
(original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/om/impl/llom/OMElementImpl.java
Wed Jun 29 01:14:34 2005
@@ -183,7 +183,7 @@
             if (ns != null) {
                 this.setNamespace(ns);
 //            throw new OMException("Element can not be declared without a namespaceURI.
Every Element should be namespace qualified");
-                  
+
             }
         }
     }
@@ -338,17 +338,17 @@
 
         // go up to check with ancestors
         if (parent != null) {
-        	//Comment by Jaya:
-        	//For the OMDocument there won't be any explicit namespace
-        	//declarations, so going up the parent chain till the document
-        	//element should be enough.
-        	//If at a later point community decides that some standard 
-        	//namespaces, like 'xml' which every XML w/ namespaces document
-        	//is supposed to contain implicitly, should go into OMDocument then
-        	//this 'if' block needs to be revisited.
-        	if( parent instanceof OMElement) {
-        		return ((OMElementImpl)parent).findNamespace(uri, prefix);
-        	}
+            //Comment by Jaya:
+            //For the OMDocument there won't be any explicit namespace
+            //declarations, so going up the parent chain till the document
+            //element should be enough.
+            //If at a later point community decides that some standard
+            //namespaces, like 'xml' which every XML w/ namespaces document
+            //is supposed to contain implicitly, should go into OMDocument then
+            //this 'if' block needs to be revisited.
+            if (parent instanceof OMElement) {
+                return ((OMElementImpl) parent).findNamespace(uri, prefix);
+            }
         }
         return null;
     }
@@ -632,14 +632,14 @@
      * @param writer
      * @throws XMLStreamException
      */
-    public void serializeWithCache(OMOutput omOutput)  throws XMLStreamException {
-        serialize(omOutput,true);
+    public void serializeWithCache(OMOutput omOutput) throws XMLStreamException {
+        serialize(omOutput, true);
     }
 
     ///////////////////////////////////////////////////////////////////////////////////////////////
     //////////////////////////////////////////////////////////////////////////////////////////////
 
-    protected void serialize(OMOutput omOutput,boolean cache)throws XMLStreamException {
+    protected void serialize(OMOutput omOutput, boolean cache) throws XMLStreamException
{
 
         // select the builder
         short builderType = PULL_TYPE_BUILDER;    // default is pull type
@@ -648,28 +648,27 @@
         }
         if ((builderType == PUSH_TYPE_BUILDER)
                 && (builder.getRegisteredContentHandler() == null)) {
-            builder.registerExternalContentHandler(
-                    new StreamWriterToContentHandlerConverter(omOutput));
+            builder.registerExternalContentHandler(new StreamWriterToContentHandlerConverter(omOutput));
         }
 
 
         if (!cache) {
             //No caching
-            if (this.firstChild!=null){
-                OMSerializerUtil.serializeStartpart(this,omOutput);
+            if (this.firstChild != null) {
+                OMSerializerUtil.serializeStartpart(this, omOutput);
                 firstChild.serialize(omOutput);
                 OMSerializerUtil.serializeEndpart(omOutput);
-            }else if (!this.done){
-                if (builderType==PULL_TYPE_BUILDER){
-                    OMSerializerUtil.serializeByPullStream(this,omOutput);
-                }else{
-                    OMSerializerUtil.serializeStartpart(this,omOutput);
+            } else if (!this.done) {
+                if (builderType == PULL_TYPE_BUILDER) {
+                    OMSerializerUtil.serializeByPullStream(this, omOutput);
+                } else {
+                    OMSerializerUtil.serializeStartpart(this, omOutput);
                     builder.setCache(cache);
                     builder.next();
                     OMSerializerUtil.serializeEndpart(omOutput);
                 }
-            }else{
-                OMSerializerUtil.serializeNormal(this,omOutput, cache);
+            } else {
+                OMSerializerUtil.serializeNormal(this, omOutput, cache);
             }
 
             //serilize siblings
@@ -683,7 +682,7 @@
             }
         } else {
             //Cached
-            OMSerializerUtil.serializeNormal(this,omOutput, cache);
+            OMSerializerUtil.serializeNormal(this, omOutput, cache);
             // serialize the siblings
             OMNode nextSibling = this.getNextSibling();
             if (nextSibling != null) {
@@ -705,7 +704,7 @@
      * @throws XMLStreamException
      */
     public void serialize(OMOutput omOutput) throws XMLStreamException {
-        this. serialize(omOutput,false);
+        this.serialize(omOutput, false);
     }
 
 
@@ -785,9 +784,11 @@
      * @param namespace
      */
     public void setNamespace(OMNamespace namespace) {
-        OMNamespace ns = this.findNamespace(namespace.getName(), namespace.getPrefix());
-        if (ns == null) {
-            ns = this.declareNamespace(namespace);
+        if (ns != null) {
+            OMNamespace ns = this.findNamespace(namespace.getName(), namespace.getPrefix());
+            if (ns == null) {
+                ns = this.declareNamespace(namespace);
+            }
         }
         this.ns = namespace;
     }
@@ -798,13 +799,13 @@
      * @return
      */
     public QName getQName() {
-         QName qName = null;
+        QName qName = null;
 
         if (ns != null) {
             if (ns.getPrefix() != null) {
                 qName = new QName(ns.getName(), localName, ns.getPrefix());
-            }else{
-               qName = new QName(ns.getName(), localName);
+            } else {
+                qName = new QName(ns.getName(), localName);
             }
         } else {
             qName = new QName(localName);

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/SOAPFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/SOAPFactory.java?rev=202333&r1=202332&r2=202333&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/SOAPFactory.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/SOAPFactory.java Wed
Jun 29 01:14:34 2005
@@ -274,4 +274,5 @@
      * @return
      */
     public SOAPEnvelope getDefaultEnvelope() throws SOAPProcessingException;
+    public SOAPEnvelope getDefaultFaultEnvelope() throws SOAPProcessingException;
 }

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/SOAPFault.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/SOAPFault.java?rev=202333&r1=202332&r2=202333&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/SOAPFault.java (original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/SOAPFault.java Wed Jun
29 01:14:34 2005
@@ -90,5 +90,6 @@
      * @return
      * @throws org.apache.axis.om.OMException
      */
-    public abstract Exception getException() throws OMException;
+    public Exception getException() throws OMException;
+    public void setException(Exception e) throws OMException;
 }

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultImpl.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultImpl.java?rev=202333&r1=202332&r2=202333&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultImpl.java
(original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/SOAPFaultImpl.java
Wed Jun 29 01:14:34 2005
@@ -54,6 +54,10 @@
      */
     public SOAPFaultImpl(SOAPBody parent, Exception e) throws SOAPProcessingException {
         super(parent, SOAPConstants.SOAPFAULT_LOCAL_NAME, true);
+        setException(e);
+    }
+
+    public void setException(Exception e) {
         this.e = e;
         putExceptionToSOAPFault(e);
     }

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/factory/SOAPLinkedListImplFactory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/factory/SOAPLinkedListImplFactory.java?rev=202333&r1=202332&r2=202333&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/factory/SOAPLinkedListImplFactory.java
(original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/factory/SOAPLinkedListImplFactory.java
Wed Jun 29 01:14:34 2005
@@ -171,4 +171,21 @@
     public SOAPEnvelope getDefaultEnvelope() throws SOAPProcessingException {
         throw new UnsupportedOperationException();
     }
+
+    public SOAPEnvelope getDefaultFaultEnvelope() throws SOAPProcessingException {
+        SOAPEnvelope defaultEnvelope = getDefaultEnvelope();
+        SOAPFault fault = createSOAPFault(defaultEnvelope.getBody());
+
+        SOAPFaultCode faultCode = createSOAPFaultCode(fault);
+        SOAPFaultValue value = createSOAPFaultValue(faultCode);
+
+        SOAPFaultReason reason = createSOAPFaultReason(fault);
+        SOAPFaultText faultText = createSOAPFaultText(reason);
+
+        SOAPFaultNode faultNode = createSOAPFaultNode(fault);
+        SOAPFaultRole faultRole = createSOAPFaultRole(fault);
+        SOAPFaultDetail faultDetail = createSOAPFaultDetail(fault);
+
+        return defaultEnvelope;
+    }
 }

Modified: webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/soap11/SOAP11Factory.java
URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/soap11/SOAP11Factory.java?rev=202333&r1=202332&r2=202333&view=diff
==============================================================================
--- webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/soap11/SOAP11Factory.java
(original)
+++ webservices/axis/trunk/java/modules/xml/src/org/apache/axis/soap/impl/llom/soap11/SOAP11Factory.java
Wed Jun 29 01:14:34 2005
@@ -154,15 +154,11 @@
 
     public SOAPEnvelope getDefaultEnvelope() throws SOAPProcessingException {
         OMNamespace ns =
-        new OMNamespaceImpl(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
-                SOAP11Constants.SOAP_DEFAULT_NAMESPACE_PREFIX);
+                new OMNamespaceImpl(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
+                        SOAP11Constants.SOAP_DEFAULT_NAMESPACE_PREFIX);
         SOAPEnvelopeImpl env = new SOAPEnvelopeImpl(ns);
-
-
         SOAPHeader headerImpl = createSOAPHeader(env);
-
         SOAPBody bodyImpl = createSOAPBody(env);
-
         return env;
     }
 



Mime
View raw message