Skip to content
Permalink
Browse files
[CXF-5493] DOMUtils isn't handling CDATASections when grabbing text c…
…ontent

git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1559173 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
dkulp committed Jan 17, 2014
1 parent 7fd02d1 commit 1a0c4aad7f0360c30539e49a98eb4f16fa554512
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
@@ -150,7 +150,7 @@ public static String getRawContent(Node n) {
String s = null;
Node n1 = n.getFirstChild();
while (n1 != null) {
if (n1.getNodeType() == Node.TEXT_NODE) {
if (n1.getNodeType() == Node.TEXT_NODE || n1.getNodeType() == Node.CDATA_SECTION_NODE) {
if (b != null) {
b.append(((Text)n1).getNodeValue());
} else if (s == null) {
@@ -159,7 +159,7 @@ public static String getRawContent(Node n) {
b = new StringBuilder(s).append(((Text)n1).getNodeValue());
s = null;
}
}
}
n1 = n1.getNextSibling();
}
if (b != null) {
@@ -336,4 +336,48 @@ public void testCXF4181() throws Exception {
assertEquals(new QName("http://schemas.xmlsoap.org/ws/2005/02/trust", "FailedAuthentication"),
fault2.getSubCode());
}


@Test
public void testCXF5493() throws Exception {

SoapMessage m = new SoapMessage(new MessageImpl());
m.setVersion(Soap11.getInstance());


XMLStreamReader reader = StaxUtils.createXMLStreamReader(this.getClass()
.getResourceAsStream("cxf5493.xml"));
m.setContent(XMLStreamReader.class, reader);
reader.nextTag(); //env
reader.nextTag(); //body
reader.nextTag(); //fault

Soap11FaultInInterceptor inInterceptor = new Soap11FaultInInterceptor();
inInterceptor.handleMessage(m);

SoapFault fault2 = (SoapFault)m.getContent(Exception.class);
assertNotNull(fault2);
assertEquals(Soap11.getInstance().getReceiver(), fault2.getFaultCode());
assertEquals("some text containing a xml tag <xml-tag>", fault2.getMessage());



m = new SoapMessage(new MessageImpl());
m.put(Message.HTTP_REQUEST_METHOD, "POST");
m.setVersion(Soap11.getInstance());
reader = StaxUtils.createXMLStreamReader(this.getClass().getResourceAsStream("cxf5493.xml"));

m.setContent(XMLStreamReader.class, reader);

new SAAJPreInInterceptor().handleMessage(m);
new ReadHeadersInterceptor(null).handleMessage(m);
new StartBodyInterceptor().handleMessage(m);
new SAAJInInterceptor().handleMessage(m);
new Soap11FaultInInterceptor().handleMessage(m);

fault2 = (SoapFault)m.getContent(Exception.class);
assertNotNull(fault2);
assertEquals(Soap11.getInstance().getReceiver(), fault2.getFaultCode());
assertEquals("some text containing a xml tag <xml-tag>", fault2.getMessage());
}
}
@@ -0,0 +1,8 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring><![CDATA[some text containing a xml tag <xml-tag>]]></faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>

0 comments on commit 1a0c4aa

Please sign in to comment.