Passing CDATA in WSO2

别来无恙 提交于 2019-12-12 21:27:44

问题


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:

  1. 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);
}
  1. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!