Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Invalid
-
3.1.7
-
None
-
windows 7/ linux centos 6
-
Unknown
-
Important
Description
HI,
When implementing a CDATA interceptor in order to include a signed XML file in a SOAP envelope, we are getting several CDATA sections in the XML that makes the service reject the envelope:
import java.util.regex.Pattern; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamWriter; import org.apache.cxf.staxutils.DelegatingXMLStreamWriter; /** * Simple CDATA XML Stream Writer that exports some items as CDATA */ public class CDataXMLStreamWriter extends DelegatingXMLStreamWriter { private static final Pattern XML_CHARS = Pattern.compile( "[&<>]" ); private static final String CDataOpen = "<![CDATA["; private static final String CDataClose = "]]>"; public CDataXMLStreamWriter(XMLStreamWriter del) { super(del); } @Override public void writeCharacters(String text) throws XMLStreamException { boolean useCData = XML_CHARS.matcher( text ).find(); if (useCData) { //super.writeCharacters(CDataOpen); System.out.println("text" + text); //super.writeCharacters(text); //super.writeCharacters(CDataClose); super.writeCData(text); }else { super.writeCharacters(text); } } public void writeStartElement(String local) throws XMLStreamException { super.writeStartElement(local); } }
That's urgent to solve this for us.
This is an example of the unwanted output:
EwJVWTErMCkGA1UECgwiQURNSU5JU1RSQUNJT04gTkFDSU9OQUwgREUgQ09SUk]]><![CDATA[VPUzEfMB0GA1UE]]><![CDATA[
CwwWU0VSVklDSU9TIEVMRUNUUk9OSUNPUzEdMBsGA1UEAwwUQ29ycmVvIFVydWd1YXlvIC0gQ0Ew
HhcNMTUxMTI3MTk0NzE4WhcNMTYxMTI3MTk0NzE4WjCBmzEmMCQGCSqGSIb3DQEJARYXdml0YW1p
bmljby4wNUBnbWFpbC5jb20xEzARBgNVBAoMClZJVEFNSU5JQ08xEzARBgNVBAgMCk1vbnRldmlk
ZW8xCzAJBgNVBAYTAlVZMRgwFgYDVQQFEw9SVUMyMTUyMTcxOTAwMTUxIDAeBgNVBAMMF1ZJTkFM
UyBJVkFOSUNIIExFT05BUkRPMIGfMA0GCSqGSIb3DQEBAQUAA4GN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