WSO2 ESB中有效负载工厂中的CDATA

WSO2 ESB中有效负载工厂中的CDATA

问题描述:

我正尝试在ESB中编写一个序列,并使用有效负载工厂填充有效负载数据,如下例所示。

I am trying to write a sequence in ESB and populate my payload data by using payload factory as i stated below example.

  <payloadFactory>
     <format>
        <p:echoInt xmlns:p="http://echo.services.core.carbon.wso2.org">
           <in xmlns="">$1</in>
        </p:echoInt>
     </format>
     <args>
        <arg xmlns:ns="http://org.apache.synapse/xsd" expression="an-xml-formatted-string"/>
     </args>
  </payloadFactory>
 <send>
     <endpoint>
        <address uri="http://noon101:8280/services/echo" format="soap11"/>
     </endpoint>
  </send>

由于当我将此有效载荷发送给服务时,我的字符串被格式化为xml,因此服务尝试解析我的xml参数和(我不明白确切的原因是什么)我的Web服务方法没有被调用。在此链接它表示如果我使用cdata,则解析器将不会解析我的xml格式的字符串,并且不会有问题。

Because my string is formatted as xml when i send this payload to the service, the service tries to parse my xml parameter and (i do not understand what is the exact reason) my web service method is not called. in this link it says that if i use cdata than the parser will not parse my xml formatted string and there will be no problem.

但是问题是Payload Factory中介程序不接受其内容中的Cdata。当我按如下所示编写Payload Factory的配置时,它会从其中删除CDATA关键字,问题就由之构成。

But the problem is Payload Factory mediator do not accept Cdata in its content. When i write the configuration of Payload Factory as indicated below, it deletes CDATA keywords from it and problem consists.

  <payloadFactory>
     <format>
        <p:echoInt xmlns:p="http://echo.services.core.carbon.wso2.org">
           <in xmlns=""> <![CDATA[ $1 ]]> </in>
        </p:echoInt>
     </format>
     <args>
        <arg xmlns:ns="http://org.apache.synapse/xsd" expression="an-xml-formatted-string"/>
     </args>
  </payloadFactory>

该问题的解决方案是什么?

What would be the solution to this problem? Any other mediator to set payload or any workaround will be appreciated.

您可以为此使用XSLT中介程序(有效负载工厂中介程序会这样做)。不支持CDATA)。但是,如果您使用它。另外,您还需要执行以下配置以将CDATA保留在中介流中。 [1]

You can use XSLT mediator to that (Payload factory mediator does not support CDATA). But if you use it. And also you need to do the following configuration to preserve CDATA in the mediation flow. [1]

这也将有所帮助。
http://tharindumathew.com/2012/ 05/24 / adding-cdata-tags-through-xslt /

[1] rel = nofollow> http://blog.shelan.org/2013/03/how-to-send-cdata-inside -your-soap.html