You are viewing a plain text version of this content. The canonical link for it is here.
Posted to wss4j-dev@ws.apache.org by we...@apache.org on 2007/04/27 11:24:31 UTC

svn commit: r533031 - /webservices/wss4j/trunk/test/wssec/SOAPUtil.java

Author: werner
Date: Fri Apr 27 02:24:30 2007
New Revision: 533031

URL: http://svn.apache.org/viewvc?view=rev&rev=533031
Log:
Introduce new "toAxisMessage()" to create a Axis message from a DOM
document. Use this new function instead of "toSOAPMessage()". This
resolves a problem in Java 6 which has a built-in xml.SOAPMessage
implementation. This implementation is in conflict with the previous
used Axis implementation. Previously the MessageFactory returned an
Axis message that implements a SOAPMessage interface. The test cases
(TestWS*) used this internal know-how and cast the SOAPMessage into an
Axis message directly. This fails in Java 6 and was bad programming style
anyhow. The TestWS* test cases will be modified to use the new function.

Modified:
    webservices/wss4j/trunk/test/wssec/SOAPUtil.java

Modified: webservices/wss4j/trunk/test/wssec/SOAPUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/SOAPUtil.java?view=diff&rev=533031&r1=533030&r2=533031
==============================================================================
--- webservices/wss4j/trunk/test/wssec/SOAPUtil.java (original)
+++ webservices/wss4j/trunk/test/wssec/SOAPUtil.java Fri Apr 27 02:24:30 2007
@@ -3,6 +3,8 @@
 import org.apache.xml.security.c14n.Canonicalizer;
 import org.w3c.dom.Document;
 
+import org.apache.axis.Message;
+
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.SOAPMessage;
 import javax.xml.transform.dom.DOMSource;
@@ -25,6 +27,22 @@
         ByteArrayInputStream in = new ByteArrayInputStream(canonicalMessage);
         MessageFactory factory = MessageFactory.newInstance();
         return factory.createMessage(null, in);
+    }
+
+    /**
+     * Convert a DOM Document into an Axis message.
+     * <p/>
+     *
+     * @param doc
+     * @return
+     * @throws Exception
+     */
+    public static Message toAxisMessage(Document doc) throws Exception {
+        Canonicalizer c14n =
+                Canonicalizer.getInstance(Canonicalizer.ALGO_ID_C14N_WITH_COMMENTS);
+        byte[] canonicalMessage = c14n.canonicalizeSubtree(doc);
+        ByteArrayInputStream in = new ByteArrayInputStream(canonicalMessage);
+        return new Message(in);
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org