You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by bi...@apache.org on 2020/04/15 16:08:46 UTC

[axis-axis2-java-rampart] 03/18: Committing the patch provided by AmilaJ for RAMPART-336.

This is an automated email from the ASF dual-hosted git repository.

billblough pushed a commit to branch 1_5_x
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-rampart.git

commit c3c59c88d62831488757e58930e8a5666c68b053
Author: Thilina Mahesh Buddhika <th...@apache.org>
AuthorDate: Thu Sep 29 11:12:10 2011 +0000

    Committing the patch provided by AmilaJ for RAMPART-336.
---
 .../src/main/java/org/apache/rampart/util/Axis2Util.java  | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java b/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java
index 2de1406..7874475 100644
--- a/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java
+++ b/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java
@@ -194,6 +194,10 @@ public class Axis2Util {
                         // it is a header we have added in rampart eg. EncryptedHeader and should
                         // be converted to SOAPHeaderBlock for processing
                     	} else {
+                            // First detach element from soap header
+                            element.detach();
+
+                            // add new element
                     		header = soapHeader.addHeaderBlock(element.getLocalName(), element.getNamespace());
                     		Iterator attrIter = element.getAllAttributes();
                     		while (attrIter.hasNext()) {
@@ -206,14 +210,17 @@ public class Axis2Util {
                     			header.declareNamespace(ns);
                     		}
                     		Iterator children = element.getChildElements();
-                    		while (children.hasNext()) {
+
+                            // Element is a composite element, in which it has many siblings.
+                            // All siblings will be added when we add a single node.
+                            // See ParentNode.insertBefore(Node newChild, Node refChild) for
+                            // more information.
+                    		if (children.hasNext()) {
                     			OMNode child = (OMNode)children.next();
                     			children.remove();
                     			header.addChild(child);
                     		}
-                    		
-                    		element.detach();
-                    		
+
                     		soapHeader.build();
                     		
                     		header.setProcessed();