问题
WSO2 4.8.1 has a well-known problem with passing CDATA sections in XML messages. Such sections are always replaced with their contents in the form of XML-escaped string.
Any solution to this problem would be appreciated.
Meanwhile, I have found a page telling about some patch (patch0514) for this purpose:
http://www.yenlo.com/en/how-to-preserve-a-cdata-in-xml-that-is-circulating-in-a-wso2-enterprise-service-bus/
But I have no idea where can I get this patch. Any clue?
回答1:
So, finally I found 2 issues there:
- Configuration of SOAP Builder, that does not preserve CDATA.
I had to change org.apache.axiom.om.OMXMLBuilderFactory
from Axiom package, to make it using StAXParserConfiguration.PRESERVE_CDATA_SECTIONS
instead of StAXParserConfiguration.SOAP
, as follows:
public static OMXMLParserWrapper createSOAPModelBuilder(InputStream in, String encoding){
InputSource is = new InputSource(in);
is.setEncoding(encoding);
return OMAbstractFactory.getMetaFactory().createSOAPModelBuilder(StAXParserConfiguration.PRESERVE_CDATA_SECTIONS, is);
}
- Incorrect behaviour of XSLT mediator. Even if you have correctly defined CDATA nodes inside your envelope, these will be converted into escaped strings after passing XSLT mediator. I have no solution for XSLT in fact, my choice for now is to avoid using it, because of its numerous problems.
来源:https://stackoverflow.com/questions/27647332/passing-cdata-in-wso2