I want to create an API resource in WSO2 ESB 4.9.0 where it send back a payload with javascript content. This resource must return response with Content-type:text/javascript.
For this purpose, I use a payloadFactory mediator where I set a simple comment line. Because, there is no a payloadFactory with media-type text-plain or text-javascript, I use media-type="json".
And, I get response well. But, when I set messageType like "text/javascript" I get 202 http code in the response and the payload is empty.
I can see a nullPointerException in logs when it call PlainTextFormatter because I set org.apache.axis2.format.PlainTextFormatter and org.apache.axis2.format.PlainTextBuilder in axis2.xml.
My resource is as given below:
<resource methods="GET" uri-template="/js">
<inSequence>
<log>
<property name="*** IN" value="[API] /test/v1/jsEcho/js"/>
</log>
<payloadFactory media-type="json">
<format>//tealium universal tag - utag.sync ut4.0.201604181647, Copyright 2016 Tealium.com Inc. All Rights Reserved.</format>
<args></args>
</payloadFactory>
<property name="messageType" value="application/json" scope="axis2" type="STRING"/>
<loopback/>
</inSequence>
<outSequence>
<log>
<property name="*** OUT" value="[API] /test/v1/jsEcho/js"/>
</log>
<property name="messageType" value="text/javascript" scope="axis2" type="STRING"/>
<send/>
</outSequence>
<faultSequence></faultSequence>
</resource>
And, the error in log is as given here.
Is there anyway to do this?