Javier Irazazábal created CXF-7064:
--------------------------------------

             Summary: DelegatingXMLStreamWriter.writeCData(text) writes several 
CDATA sections for a signed XML file
                 Key: CXF-7064
                 URL: https://issues.apache.org/jira/browse/CXF-7064
             Project: CXF
          Issue Type: Bug
          Components: JAX-WS Runtime
    Affects Versions: 3.1.7
         Environment: windows 7/ linux centos 6
            Reporter: Javier Irazazábal


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 message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to