8186441: Change of behavior in the getMessage () method of the SOAPMessageContextImpl class
Reviewed-by: lancea
This commit is contained in:
parent
47d1a91754
commit
73d033cf9f
@ -505,7 +505,7 @@ public class SaajStaxWriter implements XMLStreamWriter {
|
|||||||
}
|
}
|
||||||
// add namespace declarations
|
// add namespace declarations
|
||||||
for (NamespaceDeclaration namespace : this.namespaceDeclarations) {
|
for (NamespaceDeclaration namespace : this.namespaceDeclarations) {
|
||||||
target.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
|
newElement.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
|
||||||
}
|
}
|
||||||
// add attribute declarations
|
// add attribute declarations
|
||||||
for (AttributeDeclaration attribute : this.attributeDeclarations) {
|
for (AttributeDeclaration attribute : this.attributeDeclarations) {
|
||||||
|
@ -499,7 +499,7 @@ public class SaajStaxWriter implements XMLStreamWriter {
|
|||||||
}
|
}
|
||||||
// add namespace declarations
|
// add namespace declarations
|
||||||
for (NamespaceDeclaration namespace : this.namespaceDeclarations) {
|
for (NamespaceDeclaration namespace : this.namespaceDeclarations) {
|
||||||
target.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
|
newElement.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
|
||||||
}
|
}
|
||||||
// add attribute declarations
|
// add attribute declarations
|
||||||
for (AttributeDeclaration attribute : this.attributeDeclarations) {
|
for (AttributeDeclaration attribute : this.attributeDeclarations) {
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8159058
|
* @bug 8159058 8186441
|
||||||
* @summary Test that empty default namespace declaration clears the
|
* @summary Test that empty default namespace declaration clears the
|
||||||
* default namespace value
|
* default namespace value
|
||||||
* @modules java.xml.ws/com.sun.xml.internal.ws.api
|
* @modules java.xml.ws/com.sun.xml.internal.ws.api
|
||||||
@ -60,6 +60,26 @@ import org.w3c.dom.Node;
|
|||||||
|
|
||||||
public class SaajEmptyNamespaceTest {
|
public class SaajEmptyNamespaceTest {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Test that SOAP reader doesn't move namespaces declarations to SOAP body element
|
||||||
|
* as reported in JDK-8186441
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testPreserveNamespacesPosition() throws Exception {
|
||||||
|
// Create SOAP message from XML string and process it with SAAJ reader
|
||||||
|
XMLStreamReader envelope = XMLInputFactory.newFactory().createXMLStreamReader(
|
||||||
|
new StringReader(INPUT_SOAP_MESSAGE_2));
|
||||||
|
StreamMessage streamMessage = new StreamMessage(SOAPVersion.SOAP_11,
|
||||||
|
envelope, null);
|
||||||
|
SAAJFactory saajFact = new SAAJFactory();
|
||||||
|
SOAPMessage soapMessage = saajFact.readAsSOAPMessage(SOAPVersion.SOAP_11, streamMessage);
|
||||||
|
|
||||||
|
//Get SOAP body and convert it to string representation
|
||||||
|
SOAPBody body = soapMessage.getSOAPBody();
|
||||||
|
String bodyAsString = nodeToText(body);
|
||||||
|
Assert.assertEquals(bodyAsString, PRESERVE_NAMESPACES_EXPECTED_RESULT);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test that SOAP message with default namespace declaration that contains empty
|
* Test that SOAP message with default namespace declaration that contains empty
|
||||||
* string is properly processed by SAAJ reader.
|
* string is properly processed by SAAJ reader.
|
||||||
@ -275,10 +295,28 @@ public class SaajEmptyNamespaceTest {
|
|||||||
|
|
||||||
// Expected body content after SAAJ processing
|
// Expected body content after SAAJ processing
|
||||||
private static String EXPECTED_RESULT = "<SampleServiceRequest"
|
private static String EXPECTED_RESULT = "<SampleServiceRequest"
|
||||||
+" xmlns=\"http://example.org/test\">"
|
+ " xmlns=\"http://example.org/test\""
|
||||||
|
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
|
||||||
+ "<RequestParams xmlns=\"\">"
|
+ "<RequestParams xmlns=\"\">"
|
||||||
+ "<Param1>hogehoge</Param1>"
|
+ "<Param1>hogehoge</Param1>"
|
||||||
+ "<Param2>fugafuga</Param2>"
|
+ "<Param2>fugafuga</Param2>"
|
||||||
+ "</RequestParams>"
|
+ "</RequestParams>"
|
||||||
+ "</SampleServiceRequest>";
|
+ "</SampleServiceRequest>";
|
||||||
|
|
||||||
|
private static String PRESERVE_NAMESPACES_EXPECTED_RESULT =
|
||||||
|
"<s:Body xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"
|
||||||
|
+"<Request xmlns=\"http://example.org/NS_1\">"
|
||||||
|
+"<Item><Contact xmlns=\"http://example.org/NS_2\">Test_Contact</Contact>"
|
||||||
|
+"</Item></Request></s:Body>";
|
||||||
|
|
||||||
|
private static String INPUT_SOAP_MESSAGE_2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||||
|
+ "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">"
|
||||||
|
+ "<s:Body>"
|
||||||
|
+ "<Request xmlns=\"http://example.org/NS_1\">"
|
||||||
|
+ "<Item>"
|
||||||
|
+ "<Contact xmlns=\"http://example.org/NS_2\">Test_Contact</Contact>"
|
||||||
|
+ "</Item>"
|
||||||
|
+ "</Request>"
|
||||||
|
+ "</s:Body>"
|
||||||
|
+ "</s:Envelope>";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user