CDATA in factory payload in WSO2 ESB

I am trying to write a sequence to an ESB and populate my payload data using the factory payload, as I said below.

<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> 

Since my string is formatted as xml, when I send this payload to the service, the service tries to parse my xml parameter and (I don’t understand what the reason is), my web service method is not called. this link says that if I use cdata, the parser will not parse my formatted xml string and there will be no problems.

But the problem is that the Payload factory intermediary does not accept Cdata in its content. When I write the factory payload configuration as follows, it removes the CDATA keywords from it and the problem is.

  <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 will be the solution to this problem? Any other intermediary to establish a payload or any workaround will be appreciated.

+4
source share
3 answers

You can use the XSLT broker to do this (the factory media server does not support CDATA). But if you use it. And you also need to complete the following configuration to save CDATA in the mediation stream. [1]

This will also be useful. 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

+3
source

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

Below is a sample. In this example, I use the answer of my previous call as input for the message that I am preparing using the factory broker.

  <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 contents of the registry resource are 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> 

That way you can use the CDATA middleware inside the factory payload.

+4
source

if you want to transfer CDATA, you can use the XSLT broker to create such messages. Factory payload, AFAIK does not support the CDATA argument.

0
source

Source: https://habr.com/ru/post/1482129/


All Articles