Author: jim.ma
Date: 2010-12-24 01:37:23 -0500 (Fri, 24 Dec 2010)
New Revision: 13528
Added:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/saaj/
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/saaj/EnvelopBuilderTestCase.java
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java
Log:
[JBPAPP-5700]:Fixed SAAJimpl does not set the correct NS prefix in SOAP header and body
elements
Modified:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java 2010-12-24
02:53:16 UTC (rev 13527)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/main/java/org/jboss/ws/core/soap/EnvelopeBuilderDOM.java 2010-12-24
06:37:23 UTC (rev 13528)
@@ -158,7 +158,12 @@
soapHeader = soapEnv.addHeader();
DOMUtils.copyAttributes(soapHeader, domHeader);
-
+
+ if (!soapHeader.getPrefix().equals(domHeader.getPrefix()))
+ {
+ soapHeader.setPrefix(domHeader.getPrefix());
+ }
+
NodeList headerChildNodes = domHeader.getChildNodes();
for (int i = 0; i < headerChildNodes.getLength(); i++)
{
@@ -194,6 +199,11 @@
soapBody = (SOAPBodyImpl)soapEnv.addBody();
DOMUtils.copyAttributes(soapBody, domBody);
+
+ if (!soapBody.getPrefix().equals(domBody.getPrefix()))
+ {
+ soapBody.setPrefix(domBody.getPrefix());
+ }
SOAPBodyElement soapBodyElement = null;
boolean attachHRefElements =
Constants.URI_SOAP11_ENC.equals(soapEnv.getAttributeNS(envNS,
"encodingStyle"));
Added:
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/saaj/EnvelopBuilderTestCase.java
===================================================================
---
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/saaj/EnvelopBuilderTestCase.java
(rev 0)
+++
stack/native/branches/jbossws-native-2.0.1.SP2_CP/src/test/java/org/jboss/test/ws/jaxws/saaj/EnvelopBuilderTestCase.java 2010-12-24
06:37:23 UTC (rev 13528)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.jaxws.saaj;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.transform.stream.StreamSource;
+
+import junit.framework.TestCase;
+
+import org.jboss.ws.core.soap.EnvelopeBuilderDOM;
+import org.jboss.ws.core.soap.MessageFactoryImpl;
+import org.jboss.ws.core.soap.SOAPMessageImpl;
+
+public class EnvelopBuilderTestCase extends TestCase
+{
+
+ EnvelopeBuilderDOM domBuilder = new EnvelopeBuilderDOM();
+
+ MessageFactoryImpl factory = new MessageFactoryImpl();
+
+ //JBWS3159
+ public void testDifferentNSPrefix() throws Exception
+ {
+ String soapMsg = "<env:Envelope
xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'>"
+ + "<S:Header
xmlns:S='http://schemas.xmlsoap.org/soap/envelope/'/>"
+ + "<S:Body
xmlns:S='http://schemas.xmlsoap.org/soap/envelope/'>"
+ + "<ns1:addItemResponse
xmlns:ns1='http://org.jboss.ws/addressing/replyto'>"
+ + "<result>Mars
Bar</result></ns1:addItemResponse></S:Body></env:Envelope>";
+ SOAPMessageImpl soapMessage = (SOAPMessageImpl) factory.createMessage();
+ StringReader strReader = new java.io.StringReader(soapMsg);
+ StreamSource streamSource2 = new StreamSource(strReader);
+ soapMessage.getSOAPPart().setContent(streamSource2);
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ soapMessage.writeTo(bout);
+ assertTrue(new String(bout.toByteArray()).indexOf("S:Header") > -1);
+ assertTrue(new String(bout.toByteArray()).indexOf("S:Body") > -1);
+ }
+
+}