Search code examples
wso2xqueryapache-axisapache-synapsewso2-esb

How to send string content as the response from WSO2 ESB Proxy?


We need to send a combination of XML and a string to a JMS server by concatenating, the payload which we constructed is not xml and ended up being a plain string in mixed format(obviously, ESB will not allow, but is there a way to deal).

Added sample request below,

Data1 = <?PCM LEID_POOLNAME="HOST" HOST_LEID_POOL_NAME="S1PMAPPM" ONE_OFF="no" TransactionName="RESPNRBLDQ" Timeout="30" OnError_getMessage="yes"?>

and

Data2 =

<PLAINUDI>
      <LREC DID="D7E3" DataLength="102">NMM2LXFPAWMJ</LREC>
      <LREC DID="D9D3" DataLength="200">NMM2LXFPAWMJ</LREC>
   </PLAINUDI>

the expected request to be sent to endpoint is like

     **<?PCM LEID_POOLNAME="HOST" 
HOST_LEID_POOL_NAME="S1PMAPPM" ONE_OFF="no" 
TransactionName="RESPNRBLDQ" Timeout="30" OnError_getMessage="yes"?>

    <PLAINUDI>
              <LREC DID="D7E3" DataLength="102">NMM2LXFPAWMJ</LREC>
              <LREC DID="D9D3" DataLength="200">NMM2LXFPAWMJ</LREC>
           </PLAINUDI>**

I tried setting the Content-Type and messageType as text/plain,text/csv but while concatenating the two data (Data1&Data2), the ESB is unable to recognize the format.

Is it achievable?

Please comment if question needs clarification. Thanks in advance.


Solution

  • When you want to send text content with WSO2 ESB, you must create a SOAP Message with the text content as the value for a node <text xmlns="http://ws.apache.org/commons/ns/payload"> in your soap body

    Define the messageType so that the ESB choose the appropriate message formatter :

    <property name="messageType" value="text/plain" scope="axis2"/>
    

    If there is xml content in your text, you must use a CDATA section