在 WSO2 中传递 CDATA [英] Passing CDATA in WSO2

查看:13
本文介绍了在 WSO2 中传递 CDATA的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WSO2 4.8.1 在 XML 消息中传递 CDATA 部分时存在一个众所周知的问题.这些部分总是被它们以 XML 转义字符串形式的内容替换.

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.

与此同时,我找到了一个页面,介绍了一些用于此目的的补丁 (patch0514):
http://www.yenlo.com/en/how-to-preserve-a-cdata-in-xml-that-is-circulating-in-a-wso2-enterprise-service-bus/

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?

推荐答案

所以,最后我发现了 2 个问题:

So, finally I found 2 issues there:

  1. SOAP Builder 的配置,不保留 CDATA.

我必须从 Axiom 包中更改 org.apache.axiom.om.OMXMLBuilderFactory,以使用 StAXParserConfiguration.PRESERVE_CDATA_SECTIONS 而不是 StAXParserConfiguration.SOAP,如下:

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. XSLT 介体的行为不正确.即使您在信封内正确定义了 CDATA 节点,这些节点也会在通过 XSLT 中介后转换为转义字符串.事实上,我没有 XSLT 的解决方案,我现在的选择是避免使用它,因为它有很多问题.

这篇关于在 WSO2 中传递 CDATA的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆