CDATA in payload factory in WSO2 ESB

六月ゝ 毕业季﹏ 提交于 2019-12-03 16:48:46

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]

This will be helpful too. http://tharindumathew.com/2012/05/24/adding-cdata-tags-through-xslt/

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

You can use CDATA inside payload factory mediator. The only thing you need to do is, you need to store the format in registry and use it from there. Registry Resource

Following is a sample. In this sample, I am using the response of my previous call as the input for the message I am preparing with payload factory mediator.

     <property xmlns:ns="http://org.apache.synapse/xsd"
               name="ALLRESULTS"
               expression="$body/child::*[fn:position()=1]"
               scope="default"
               type="STRING"/>

     <payloadFactory media-type="xml">
        <format key="conf:/repository/esb/myPF"/>
        <args>
           <arg evaluator="xml" expression="$ctx:ALLRESULTS"/>
           <arg value="1"/>
        </args>
     </payloadFactory>

The content of the registry resource is as follows.

                       <ns:testMethod xmlns:ns="http://example.com">
                            <xs:xmlBody xmlns:xs="http://example.com"><![CDATA[$1]]></xs:xmlBody>
                            <xs:sessionId xmlns:xs="http://example.com">$2</xs:sessionId>
                        </ns:testMethod>

With this way, you can use CDATA inside payload factory mediator.

if you want to pass CDATA, You can use XSLT mediator to construct such messages. Payload factory, AFAIK doesn't support CDATA argument.

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