svn commit: r1090540 - /axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java

2011-04-09 Thread veithen
Author: veithen
Date: Sat Apr  9 08:18:17 2011
New Revision: 1090540

URL: http://svn.apache.org/viewvc?rev=1090540&view=rev
Log:
Fixed an issue that occurs in the outflow when the Axiom implementation also 
supports DOM.

Modified:

axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java

Modified: 
axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java?rev=1090540&r1=1090539&r2=1090540&view=diff
==
--- 
axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java
 (original)
+++ 
axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java
 Sat Apr  9 08:18:17 2011
@@ -90,7 +90,18 @@ public class Axis2Util {
throws WSSecurityException {
try {
 if(env instanceof Element) {
-return ((Element)env).getOwnerDocument();
+Element element = (Element)env;
+Document document = element.getOwnerDocument();
+// For outgoing messages, Axis2 only creates the SOAPEnvelope, 
but no document. If
+// the Axiom implementation also supports DOM, then the 
envelope (seen as a DOM
+// element) will have an owner document, but the document and 
the envelope have no
+// parent-child relationship. On the other hand, the input 
expected by WSS4J is
+// a document with the envelope as document element. Therefore 
we need to set the
+// envelope as document element on the owner document.
+if (element.getParentNode() != document) {
+document.appendChild(element);
+}
+return document;
 }
 
 if (useDoom) {




svn commit: r1090570 - /axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java

2011-04-09 Thread veithen
Author: veithen
Date: Sat Apr  9 11:33:05 2011
New Revision: 1090570

URL: http://svn.apache.org/viewvc?rev=1090570&view=rev
Log:
Avoid the DOM->Axiom conversion if the underlying Axiom implementation supports 
DOM. Note that this doesn't apply to DOOM (because DOOM is an incomplete 
implementation of the Axiom API), but to implementations such as DDOM 
[http://code.google.com/p/ddom/].

Modified:

axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java

Modified: 
axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java?rev=1090570&r1=1090569&r2=1090570&view=diff
==
--- 
axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java
 (original)
+++ 
axis/axis2/java/rampart/trunk/modules/rampart-core/src/main/java/org/apache/rampart/util/Axis2Util.java
 Sat Apr  9 11:33:05 2011
@@ -185,6 +185,17 @@ public class Axis2Util {
public static SOAPEnvelope getSOAPEnvelopeFromDOMDocument(Document doc, 
boolean useDoom)
 throws WSSecurityException {
 
+   Element documentElement = doc.getDocumentElement();
+   if (documentElement instanceof SOAPEnvelope) {
+   SOAPEnvelope env = (SOAPEnvelope)documentElement;
+   // If the DOM tree already implements the Axiom API and is not 
DOOM, then just return
+   // the SOAPEnvelope directly, i.e. we assume that any Axiom+DOM 
implementation other
+   // than DOOM implements enough of the Axiom API to support the 
Axis2 runtime.
+   if (!(env.getOMFactory() instanceof DOMSOAPFactory)) {
+   return env;
+   }
+   }
+   
 if(useDoom) {
 try {
 //Get processed headers