WSO2 ESB/EI Send XML content to backend

When sending XML content inside the payload to the backend via WSO2 ESB,  we have to encode it and send it. In my usecase,  I have a Data Service which is accepting XML content as a parameter.

To implement this requirement, we can't directly define CDATA(blocks of text that are not parsed by XML parser) inside the payload factory mediator. So we have two option to do so.

The first option is that Encode XML content using Script mediator and use encoded value inside the payload factory mediator. You can read Hasitha's blog on this topic.

The second option is storing the format section of the payload factory mediator, in the registry. There you can directly define the CDATA tags inside the XML content stored in the registry. This allows you to define  CDATA inside payload factory mediator.

An example usecase is as below:

PayloadFacroy Mediator:

<?xml version="1.0" encoding="UTF-8"?>
<payloadFactory media-type="xml">
   <format key="conf:/format/Common_Error_Message.xml" />
      <arg evaluator="xml" expression="$ctx:ORIGINAL_MESSAGE" />
      <arg expression="$axis2:HTTP_SC" />

Registry Content:

<?xml version="1.0" encoding="UTF-8"?>
<xs:logError xmlns:xs="">

Post a Comment

Popular posts from this blog

Secure Spring Boot REST API using Basic Authentication

Yield Price Sri Lanka - Android Application

Integrating Swagger with Spring Boot REST API