[jbossws-commits] JBossWS SVN: r13432 - in stack/native/trunk/modules: testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap and 1 other directory.
jbossws-commits at lists.jboss.org
jbossws-commits at lists.jboss.org
Wed Dec 8 13:48:38 EST 2010
Author: darran.lofthouse at jboss.com
Date: 2010-12-08 13:48:37 -0500 (Wed, 08 Dec 2010)
New Revision: 13432
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPBodyImpl.java
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java
Log:
[JBWS-3170] SAAJ Where an Element is added to the SOAPBody this should be converted to a SOAPElement
Modified: stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPBodyImpl.java
===================================================================
--- stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPBodyImpl.java 2010-12-08 16:52:32 UTC (rev 13431)
+++ stack/native/trunk/modules/core/src/main/java/org/jboss/ws/core/soap/SOAPBodyImpl.java 2010-12-08 18:48:37 UTC (rev 13432)
@@ -269,8 +269,21 @@
return validChild == false;
}
- private static SOAPBodyElementDoc convertToBodyElement(Node node)
+ private static SOAPBodyElementDoc convertToBodyElement(Node node) throws DOMException
{
+ if (!(node instanceof SOAPElementImpl) && (node instanceof Element))
+ {
+ try
+ {
+ SOAPFactoryImpl soapFactory = new SOAPFactoryImpl();
+ node = (SOAPElementImpl)soapFactory.createElement((Element)node);
+ }
+ catch (SOAPException ex)
+ {
+ throw new DOMException(DOMException.INVALID_STATE_ERR, "Could not convert Element to a SOAPElement");
+ }
+ }
+
if (!(node instanceof SOAPElementImpl))
throw new IllegalArgumentException("SOAPElement expected");
Modified: stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java
===================================================================
--- stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java 2010-12-08 16:52:32 UTC (rev 13431)
+++ stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/common/soap/SOAPElementTestCase.java 2010-12-08 18:48:37 UTC (rev 13432)
@@ -22,7 +22,6 @@
package org.jboss.test.ws.common.soap;
import java.io.ByteArrayInputStream;
-import java.io.File;
import java.io.InputStream;
import java.util.Iterator;
@@ -38,6 +37,7 @@
import org.jboss.wsf.test.JBossWSTest;
import org.w3c.dom.Document;
+import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@@ -97,6 +97,24 @@
assertEquals(se, se2);
}
+ // JBWS-3170
+ public void testAppendNonSoapElement() throws Exception
+ {
+ MessageFactory msgFactory = MessageFactory.newInstance();
+ SOAPMessage soapMessage = msgFactory.createMessage();
+ SOAPEnvelope env = soapMessage.getSOAPPart().getEnvelope();
+ SOAPBody body = env.getBody();
+
+ Element e = body.getOwnerDocument().createElement("MyChild1");
+ SOAPElement se = (SOAPElement)body.appendChild(e);
+ assertNotNull("Expected an element", se);
+
+ assertEquals("Expected 1 child element", 1, getIteratorCount(body.getChildElements()));
+
+ SOAPElement se2 = (SOAPElement)body.getChildElements().next();
+ assertEquals(se, se2);
+ }
+
//JBWS-2346
public void testGetElementByTagNameNS() throws Exception
{
More information about the jbossws-commits
mailing list