axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ruchi...@apache.org
Subject svn commit: r398988 - in /webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security: WSDoAllReceiver.java util/Axis2Util.java
Date Tue, 02 May 2006 17:54:28 GMT
Author: ruchithf
Date: Tue May  2 10:54:26 2006
New Revision: 398988

URL: http://svn.apache.org/viewcvs?rev=398988&view=rev
Log:
Added a workaround to avoide an OM bug
Added support to set the addressing information if available on a fault within the receiver
handler


Modified:
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/Axis2Util.java

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java?rev=398988&r1=398987&r2=398988&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java
(original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java
Tue May  2 10:54:26 2006
@@ -16,12 +16,15 @@
 
 package org.apache.axis2.security;
 
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.impl.dom.jaxp.DocumentBuilderFactoryImpl;
+import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPHeaderBlock;
 import org.apache.axis2.AxisFault;
 import org.apache.axis2.Constants;
+import org.apache.axis2.addressing.AddressingConstants;
 import org.apache.axis2.context.MessageContext;
 import org.apache.axis2.context.OperationContext;
 import org.apache.axis2.security.handler.WSDoAllHandler;
@@ -43,6 +46,7 @@
 import org.w3c.dom.Document;
 
 import javax.security.auth.callback.CallbackHandler;
+import javax.xml.namespace.QName;
 
 import java.security.cert.X509Certificate;
 import java.util.Iterator;
@@ -328,8 +332,10 @@
             }
             
         } catch (WSSecurityException wssEx) {
+            setAddressingInformationOnFault(msgContext);
             throw new AxisFault(wssEx);
         } catch (AxisFault axisFault) {
+            setAddressingInformationOnFault(msgContext);
             throw axisFault;
         } finally {
             if(reqData != null) {
@@ -345,6 +351,21 @@
             DocumentBuilderFactoryImpl.setDOOMRequired(false);
         }
         
+    }
+
+    private void setAddressingInformationOnFault(MessageContext msgContext) {
+        SOAPEnvelope env = msgContext.getEnvelope();
+        SOAPHeader header = env.getHeader();
+        
+        if(header != null) {
+            OMElement msgIdElem = header.getFirstChildWithName(new QName(AddressingConstants.Final.WSA_NAMESPACE,AddressingConstants.WSA_MESSAGE_ID));
+            if(msgIdElem != null) {
+                msgIdElem = header.getFirstChildWithName(new QName(AddressingConstants.Submission.WSA_NAMESPACE,AddressingConstants.WSA_MESSAGE_ID));
+            }
+            if(msgIdElem != null && msgIdElem.getText() != null) {
+                msgContext.getOptions().setMessageId(msgIdElem.getText());
+            }
+        }
     }
     
     

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/Axis2Util.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/Axis2Util.java?rev=398988&r1=398987&r2=398988&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/Axis2Util.java
(original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/util/Axis2Util.java
Tue May  2 10:54:26 2006
@@ -20,10 +20,10 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
 import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
+import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPEnvelope;
@@ -39,7 +39,6 @@
 
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamReader;
 
 import java.io.ByteArrayInputStream;
@@ -89,6 +88,13 @@
             
             if(!disableDoom) {
     			env.build();
+                
+                //Workaround to prevent a bug in AXIOM where 
+                //there can be an incomplete OMElement as the first child body 
+                OMElement firstElement = env.getBody().getFirstElement();
+                if(firstElement != null) {
+                    firstElement.build();
+                }
     			
     			//Check the namespace and find SOAP version and factory
     			String nsURI = null;



Mime
View raw message