Author: thomas.diesler(a)jboss.com
Date: 2006-11-21 05:46:14 -0500 (Tue, 21 Nov 2006)
New Revision: 1483
Modified:
trunk/src/main/java/org/jboss/ws/addressing/EndpointReferenceImpl.java
trunk/src/main/java/org/jboss/ws/soap/SOAPContentElement.java
trunk/src/main/java/org/jboss/ws/soap/SOAPHeaderElementImpl.java
trunk/src/main/java/org/jboss/ws/utils/DOMWriter.java
trunk/src/test/java/org/jboss/test/ws/common/soap/SOAPHeaderElementTestCase.java
trunk/src/test/java/org/jboss/test/ws/common/utils/DOMWriterTestCase.java
trunk/src/test/java/org/jboss/test/ws/jaxrpc/wsse/MicrosoftInteropTestCase.java
trunk/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/EndpointReferenceTestCase.java
trunk/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/SOAPAddressingPropertiesTestCase.java
Log:
[JBWS-1130] Consolidate namespace declarations
Modified: trunk/src/main/java/org/jboss/ws/addressing/EndpointReferenceImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/addressing/EndpointReferenceImpl.java 2006-11-21
10:44:00 UTC (rev 1482)
+++ trunk/src/main/java/org/jboss/ws/addressing/EndpointReferenceImpl.java 2006-11-21
10:46:14 UTC (rev 1483)
@@ -24,6 +24,7 @@
//$Id$
import java.io.IOException;
+import java.io.StringWriter;
import java.net.URI;
import java.util.Iterator;
import java.util.List;
@@ -38,10 +39,10 @@
import javax.xml.ws.addressing.ReferenceParameters;
import javax.xml.ws.addressing.soap.SOAPAddressingBuilder;
+import org.jboss.ws.WSException;
+import org.jboss.ws.addressing.soap.SOAPAddressingBuilderImpl;
import org.jboss.ws.utils.DOMUtils;
import org.jboss.ws.utils.DOMWriter;
-import org.jboss.ws.WSException;
-import org.jboss.ws.addressing.soap.SOAPAddressingBuilderImpl;
import org.w3c.dom.Element;
/**
@@ -267,7 +268,10 @@
{
if (obj instanceof Element)
{
- String xmlFragment = DOMWriter.printNode((Element)obj, false);
+ StringWriter strwr = new StringWriter();
+ DOMWriter domWriter = new DOMWriter(strwr).setCompleteNamespaces(false);
+ domWriter.print((Element)obj);
+ String xmlFragment = strwr.toString();
xmlBuffer.append(xmlFragment);
}
else if (obj instanceof String)
Modified: trunk/src/main/java/org/jboss/ws/soap/SOAPContentElement.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/soap/SOAPContentElement.java 2006-11-21 10:44:00 UTC
(rev 1482)
+++ trunk/src/main/java/org/jboss/ws/soap/SOAPContentElement.java 2006-11-21 10:46:14 UTC
(rev 1483)
@@ -23,6 +23,18 @@
// $Id$
+import java.io.IOException;
+import java.io.Writer;
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.util.Iterator;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+import javax.xml.soap.Name;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+
import org.jboss.logging.Logger;
import org.jboss.ws.Constants;
import org.jboss.ws.WSException;
@@ -41,19 +53,14 @@
import org.jboss.ws.utils.DOMWriter;
import org.jboss.ws.utils.JavaUtils;
import org.jboss.ws.xop.XOPContext;
-import org.w3c.dom.*;
+import org.w3c.dom.Attr;
+import org.w3c.dom.DOMException;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.TypeInfo;
-import javax.activation.DataHandler;
-import javax.xml.namespace.QName;
-import javax.xml.soap.Name;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPException;
-import java.io.IOException;
-import java.io.Writer;
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
-import java.util.Iterator;
-
/**
* A SOAPElement that gives access to its content as XML fragment or Java object.
*
@@ -126,7 +133,7 @@
{
return getParamMetaData().getJavaType();
}
-
+
public boolean isDOMValid()
{
return isDOMValid;
@@ -965,24 +972,17 @@
}
}
- public void writeElement(Writer writer) {
- try
+ public void writeElement(Writer writer) throws IOException
+ {
+ handleMTOMTransitions();
+
+ if (isDOMValid)
{
- handleMTOMTransitions();
-
- if(isDOMValid)
- {
- new DOMWriter(writer).print(this);
- }
- else
- {
- writer.write( getXMLFragment() );
- }
-
+ new DOMWriter(writer).print(this);
}
- catch (Exception e)
+ else
{
- throw new WSException("Failed to write SOAPContentElement ", e);
+ writer.write(getXMLFragment());
}
}
@@ -998,11 +998,12 @@
* it's needs to be decided wether or not the <code>xop:Include</code>
should be restored.
* This as well depends upon the message context property.
*/
- public void handleMTOMTransitions() {
+ public void handleMTOMTransitions()
+ {
boolean mtomEnabled = isXOPParameter() && XOPContext.isMTOMEnabled();
- if( paramMetaData != null && mtomEnabled == false )
+ if (paramMetaData != null && mtomEnabled == false)
{
// If MTOM is disabled, we force dom expansion.
// This will inline any XOP include element
@@ -1014,7 +1015,7 @@
msgContext.setProperty(CommonMessageContext.ALLOW_EXPAND_TO_DOM, Boolean.TRUE);
expandToDOM();
}
- else if(isDOMValid && mtomEnabled )
+ else if (isDOMValid && mtomEnabled)
{
// When the DOM representation is valid,
// and MTOM is enabled we need to convert the inlined
@@ -1030,7 +1031,9 @@
{
return paramMetaData != null && paramMetaData.isXOP();
}
- public void accept(SAAJVisitor visitor) {
+
+ public void accept(SAAJVisitor visitor)
+ {
visitor.visitSOAPContentElement(this);
}
}
Modified: trunk/src/main/java/org/jboss/ws/soap/SOAPHeaderElementImpl.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/soap/SOAPHeaderElementImpl.java 2006-11-21 10:44:00
UTC (rev 1482)
+++ trunk/src/main/java/org/jboss/ws/soap/SOAPHeaderElementImpl.java 2006-11-21 10:46:14
UTC (rev 1483)
@@ -21,8 +21,16 @@
*/
package org.jboss.ws.soap;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
import javax.xml.soap.Name;
import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.soap.SOAPHeader;
import javax.xml.soap.SOAPHeaderElement;
@@ -87,4 +95,48 @@
super.setParentElement(parent);
}
+
+ @Override
+ public void writeElement(Writer writer) throws IOException
+ {
+ StringWriter strwr = new StringWriter(256);
+ super.writeElement(strwr);
+
+ SOAPHeader soapHeader = (SOAPHeader)getParentElement();
+ SOAPEnvelope soapEnvelope = (SOAPEnvelope)soapHeader.getParentElement();
+
+ // Find known namespace declarations
+ List<String> knownNamespaces = new ArrayList<String>();
+ Iterator prefixes = soapEnvelope.getNamespacePrefixes();
+ while (prefixes.hasNext())
+ {
+ String prefix = (String)prefixes.next();
+ String nsURI = soapEnvelope.getNamespaceURI(prefix);
+ String xmlns = " xmlns:" + prefix + "='" + nsURI +
"'";
+ knownNamespaces.add(xmlns);
+ }
+ prefixes = soapHeader.getNamespacePrefixes();
+ while (prefixes.hasNext())
+ {
+ String prefix = (String)prefixes.next();
+ String nsURI = soapHeader.getNamespaceURI(prefix);
+ String xmlns = " xmlns:" + prefix + "='" + nsURI +
"'";
+ knownNamespaces.add(xmlns);
+ }
+
+ // Remove known namespace declarations
+ String xmlFragment = strwr.toString();
+ for (String xmlns : knownNamespaces)
+ {
+ int start = xmlFragment.indexOf(xmlns);
+ while (start > 0)
+ {
+ int end = start + xmlns.length();
+ xmlFragment = xmlFragment.substring(0, start) + xmlFragment.substring(end);
+ start = xmlFragment.indexOf(xmlns);
+ }
+ }
+
+ writer.write(xmlFragment);
+ }
}
Modified: trunk/src/main/java/org/jboss/ws/utils/DOMWriter.java
===================================================================
--- trunk/src/main/java/org/jboss/ws/utils/DOMWriter.java 2006-11-21 10:44:00 UTC (rev
1482)
+++ trunk/src/main/java/org/jboss/ws/utils/DOMWriter.java 2006-11-21 10:46:14 UTC (rev
1483)
@@ -98,7 +98,9 @@
private boolean wroteXMLDeclaration;
// The node that started the write
private Node rootNode;
-
+ // True if we want namespace completion
+ private boolean completeNamespaces = true;
+
public DOMWriter(Writer w)
{
this.out = new PrintWriter(w);
@@ -157,6 +159,17 @@
return this;
}
+ /**
+ * Set wheter subelements should have their namespaces completed.
+ * Setting this to false may lead to invalid XML fragments.
+ * The default is true.
+ */
+ public DOMWriter setCompleteNamespaces(boolean complete)
+ {
+ this.completeNamespaces = complete;
+ return this;
+ }
+
public boolean isPrettyprint()
{
return prettyprint;
@@ -232,7 +245,7 @@
break;
}
- // print element with attributes
+ // print element with attributes
case Node.ELEMENT_NODE:
{
Element element = (Element)node;
@@ -247,7 +260,7 @@
out.print('<');
out.print(nodeName);
-
+
Map nsMap = new HashMap();
String elPrefix = node.getPrefix();
if (elPrefix != null)
@@ -255,7 +268,7 @@
String nsURI = getNamespaceURI(elPrefix, element, rootNode);
nsMap.put(elPrefix, nsURI);
}
-
+
Attr attrs[] = sortAttributes(node.getAttributes());
for (int i = 0; i < attrs.length; i++)
{
@@ -263,7 +276,7 @@
String atPrefix = attr.getPrefix();
String atName = attr.getNodeName();
String atValue = normalize(attr.getNodeValue());
-
+
if (atPrefix != null && !atPrefix.equals("xmlns")
&& !atPrefix.equals("xml"))
{
String nsURI = getNamespaceURI(atPrefix, element, rootNode);
@@ -277,20 +290,23 @@
nsMap.put(typePrefix, typeURI);
}
}
-
+
out.print(" " + atName + "='" + atValue +
"'");
}
-
+
// Add missing namespace declaration
- Iterator itPrefix = nsMap.keySet().iterator();
- while (itPrefix.hasNext())
+ if (completeNamespaces)
{
- String prefix = (String)itPrefix.next();
- String nsURI = (String)nsMap.get(prefix);
- if (nsURI == null)
+ Iterator itPrefix = nsMap.keySet().iterator();
+ while (itPrefix.hasNext())
{
- nsURI = getNamespaceURI(prefix, element, null);
- out.print(" xmlns:" + prefix + "='" + nsURI +
"'");
+ String prefix = (String)itPrefix.next();
+ String nsURI = (String)nsMap.get(prefix);
+ if (nsURI == null)
+ {
+ nsURI = getNamespaceURI(prefix, element, null);
+ out.print(" xmlns:" + prefix + "='" + nsURI
+ "'");
+ }
}
}
Modified:
trunk/src/test/java/org/jboss/test/ws/common/soap/SOAPHeaderElementTestCase.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/common/soap/SOAPHeaderElementTestCase.java 2006-11-21
10:44:00 UTC (rev 1482)
+++
trunk/src/test/java/org/jboss/test/ws/common/soap/SOAPHeaderElementTestCase.java 2006-11-21
10:46:14 UTC (rev 1483)
@@ -22,6 +22,7 @@
package org.jboss.test.ws.common.soap;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import javax.xml.soap.MessageFactory;
import javax.xml.soap.Name;
@@ -33,6 +34,7 @@
import org.jboss.test.ws.JBossWSTest;
import org.jboss.ws.soap.MessageFactoryImpl;
import org.jboss.ws.soap.NameImpl;
+import org.jboss.ws.utils.DOMUtils;
/**
* Test the SOAPHeaderElement
@@ -97,18 +99,15 @@
*/
public void testSetMustUnderstand() throws Exception
{
- String envStr =
+ String expEnv =
"<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>" +
- " <env:Header>" +
- " <ns2:Bar xmlns:ns2='http://org.jboss.ws/header2'
env:mustUnderstand='1'>SomeOtherValue</ns2:Bar>" +
- " </env:Header>" +
- " <env:Body/>" +
+ "<env:Header>" +
+ "<ns2:Bar xmlns:ns2='http://org.jboss.ws/header2'
env:mustUnderstand='1'>SomeOtherValue</ns2:Bar>" +
+ "</env:Header>" +
+ "<env:Body/>" +
"</env:Envelope>";
MessageFactory factory = new MessageFactoryImpl();
- SOAPMessage expSoapMessage = factory.createMessage(null, new
ByteArrayInputStream(envStr.getBytes()));
- SOAPEnvelope expSoapEnv = expSoapMessage.getSOAPPart().getEnvelope();
-
SOAPMessage soapMessage = factory.createMessage();
SOAPEnvelope soapEnv = soapMessage.getSOAPPart().getEnvelope();
SOAPHeader soapHeader = soapEnv.getHeader();
@@ -118,7 +117,10 @@
soapHeaderElement.setMustUnderstand(true);
soapHeaderElement.addTextNode("SomeOtherValue");
- System.out.println("FIXME: [JBWS-1130] Consolidate namespace
declarations");
- // assertEquals(expSoapEnv, soapEnv);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ soapMessage.writeTo(baos);
+ String wasEnv = new String(baos.toByteArray());
+
+ assertEquals(DOMUtils.parse(expEnv), DOMUtils.parse(wasEnv));
}
}
Modified: trunk/src/test/java/org/jboss/test/ws/common/utils/DOMWriterTestCase.java
===================================================================
--- trunk/src/test/java/org/jboss/test/ws/common/utils/DOMWriterTestCase.java 2006-11-21
10:44:00 UTC (rev 1482)
+++ trunk/src/test/java/org/jboss/test/ws/common/utils/DOMWriterTestCase.java 2006-11-21
10:46:14 UTC (rev 1483)
@@ -22,9 +22,9 @@
package org.jboss.test.ws.common.utils;
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import org.jboss.test.ws.JBossWSTest;
@@ -150,7 +150,7 @@
public void testEnvelopeWriter() throws Exception
{
- String xmlEnv = "<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>"
+ String expEnv = "<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>"
+ " <env:Header
xmlns:wsa='http://www.w3.org/2005/08/addressing'>"
+ "
<wsa:To>http://fabrikam123.example/Purchasing</wsa:To>"
+ " <wsa:ReplyTo>"
@@ -166,10 +166,12 @@
+ "</env:Envelope>";
MessageFactory factory = MessageFactory.newInstance();
- SOAPMessage msgOut = factory.createMessage(null, new
ByteArrayInputStream(xmlEnv.getBytes()));
- SOAPEnvelope soapEnv = msgOut.getSOAPPart().getEnvelope();
+ SOAPMessage soapMessage = factory.createMessage(null, new
ByteArrayInputStream(expEnv.getBytes()));
- System.out.println("FIXME: [JBWS-1130] Consolidate namespace
declarations");
- //assertEquals(DOMUtils.parse(xmlEnv), soapEnv);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ soapMessage.writeTo(baos);
+ String wasEnv = new String(baos.toByteArray());
+
+ assertEquals(DOMUtils.parse(expEnv), DOMUtils.parse(wasEnv));
}
}
Modified: trunk/src/test/java/org/jboss/test/ws/jaxrpc/wsse/MicrosoftInteropTestCase.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxrpc/wsse/MicrosoftInteropTestCase.java 2006-11-21
10:44:00 UTC (rev 1482)
+++
trunk/src/test/java/org/jboss/test/ws/jaxrpc/wsse/MicrosoftInteropTestCase.java 2006-11-21
10:46:14 UTC (rev 1483)
@@ -21,6 +21,7 @@
*/
package org.jboss.test.ws.jaxrpc.wsse;
+import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Calendar;
@@ -32,7 +33,7 @@
import org.jboss.test.ws.JBossWSTest;
import org.jboss.ws.soap.MessageFactoryImpl;
-import org.jboss.ws.utils.DOMWriter;
+import org.jboss.ws.utils.DOMUtils;
import org.jboss.ws.wsse.Constants;
import org.jboss.ws.wsse.SecurityDecoder;
import org.jboss.ws.wsse.SecurityStore;
@@ -52,7 +53,7 @@
/** Test that we can build an envelope from InputStream */
public void testMicrosoftRequest() throws Exception
{
- String envStr =
+ String expEnv =
"<?xml version='1.0' encoding='UTF-8'?>" +
"<soap:Envelope" +
"
xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'" +
@@ -65,7 +66,7 @@
" <wsa:ReplyTo>" +
"
<
wsa:Address>http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anon...
+
" </wsa:ReplyTo>" +
- "
<wsa:To>http://draught:8081/jaxrpc-jaxrpc-jse</wsa:To>" +
+ "
<wsa:To>http://draught:8081/jbossws-jaxrpc-jse</wsa:To>" +
" </soap:Header>" +
" <soap:Body>" +
" <echoString
xmlns='http://org.jboss.ws/jaxrpc/types'>" +
@@ -79,8 +80,7 @@
MessageFactory factory = new MessageFactoryImpl();
SOAPMessage soapMsg = factory.createMessage(null, inputStream);
- SOAPEnvelope env = soapMsg.getSOAPPart().getEnvelope();
- Document doc = env.getOwnerDocument();
+ SOAPEnvelope soapEnv = soapMsg.getSOAPPart().getEnvelope();
// The Microsoft WSE message is timestamp protected like so:
// <wsu:Timestamp
wsu:Id="Timestamp-9e3e6632-f2a1-4b26-a682-9301a75003a7">
@@ -97,16 +97,16 @@
cal.set(Calendar.SECOND, 25);
SecurityDecoder decoder = new SecurityDecoder(new SecurityStore(), cal);
- decoder.decode(doc);
+ decoder.decode(soapEnv.getOwnerDocument());
decoder.complete();
- cleanupWsuIds(doc.getDocumentElement());
+ cleanupWsuIds(soapEnv);
- String decodedString = DOMWriter.printNode(doc, true);
- log.debug("Decoded message:" + decodedString);
-
- System.out.println("FIXME: [JBWS-1130] Consolidate namespace
declarations");
- // assertEquals(DOMUtils.parse(envStr), doc.getDocumentElement());
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ soapMsg.writeTo(baos);
+ String wasEnv = new String(baos.toByteArray());
+
+ assertEquals(DOMUtils.parse(expEnv), DOMUtils.parse(wasEnv));
}
// WS-Security leaves wsu:id attributes arround on elements which are not cleaned
Modified:
trunk/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/EndpointReferenceTestCase.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/EndpointReferenceTestCase.java 2006-11-21
10:44:00 UTC (rev 1482)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/EndpointReferenceTestCase.java 2006-11-21
10:46:14 UTC (rev 1483)
@@ -63,7 +63,6 @@
EndpointReferenceImpl epr = new EndpointReferenceImpl(inElement);
Element outElement = epr.toElement();
- System.out.println("FIXME: [JBWS-1130] Consolidate namespace
declarations");
- //assertEquals(inElement, outElement);
+ assertEquals(inElement, outElement);
}
}
Modified:
trunk/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/SOAPAddressingPropertiesTestCase.java
===================================================================
---
trunk/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/SOAPAddressingPropertiesTestCase.java 2006-11-21
10:44:00 UTC (rev 1482)
+++
trunk/src/test/java/org/jboss/test/ws/jaxws/wsaddressing/SOAPAddressingPropertiesTestCase.java 2006-11-21
10:46:14 UTC (rev 1483)
@@ -25,16 +25,17 @@
// Exp $
import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.net.URI;
import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPMessage;
import javax.xml.ws.addressing.AddressingBuilder;
import javax.xml.ws.addressing.soap.SOAPAddressingBuilder;
import javax.xml.ws.addressing.soap.SOAPAddressingProperties;
import org.jboss.test.ws.JBossWSTest;
+import org.jboss.util.xml.DOMUtils;
/**
* Test the SOAPAddressingProperties
@@ -94,15 +95,19 @@
public void testWriteHeaders() throws Exception
{
MessageFactory factory = MessageFactory.newInstance();
- SOAPMessage soapMessage = factory.createMessage();
- addrProps.writeHeaders(soapMessage);
- SOAPEnvelope wasEnv = soapMessage.getSOAPPart().getEnvelope();
+ SOAPMessage wasMsg = factory.createMessage();
+ addrProps.writeHeaders(wasMsg);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ wasMsg.writeTo(baos);
+ String wasEnv = new String(baos.toByteArray());
- SOAPMessage msgOut = factory.createMessage(null, new
ByteArrayInputStream(reqEnvStr.getBytes()));
- SOAPEnvelope expEnv = msgOut.getSOAPPart().getEnvelope();
+ SOAPMessage expMsg = factory.createMessage(null, new
ByteArrayInputStream(reqEnvStr.getBytes()));
+ baos = new ByteArrayOutputStream();
+ expMsg.writeTo(baos);
+ String expEnv = new String(baos.toByteArray());
- System.out.println("FIXME: [JBWS-1130] Consolidate namespace
declarations");
- //assertEquals(expEnv, wasEnv);
+ assertEquals(DOMUtils.parse(expEnv), DOMUtils.parse(wasEnv));
}
public void testReplyToHeaders() throws Exception
@@ -113,14 +118,18 @@
replyProps.setAction(addrBuilder.newURI("http://fabrikam123.example/ReplyPO"));
MessageFactory factory = MessageFactory.newInstance();
- SOAPMessage soapMessage = factory.createMessage();
- replyProps.writeHeaders(soapMessage);
- SOAPEnvelope wasEnv = soapMessage.getSOAPPart().getEnvelope();
+ SOAPMessage wasMsg = factory.createMessage();
+ replyProps.writeHeaders(wasMsg);
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ wasMsg.writeTo(baos);
+ String wasEnv = new String(baos.toByteArray());
- SOAPMessage msgOut = factory.createMessage(null, new
ByteArrayInputStream(resEnvStr.getBytes()));
- SOAPEnvelope expEnv = msgOut.getSOAPPart().getEnvelope();
-
- System.out.println("FIXME: [JBWS-1130] Consolidate namespace
declarations");
- //assertEquals(expEnv, wasEnv);
+ SOAPMessage expMsg = factory.createMessage(null, new
ByteArrayInputStream(resEnvStr.getBytes()));
+ baos = new ByteArrayOutputStream();
+ expMsg.writeTo(baos);
+ String expEnv = new String(baos.toByteArray());
+
+ assertEquals(DOMUtils.parse(expEnv), DOMUtils.parse(wasEnv));
}
}