Search code examples
jsonwso2esbapache-synapsewso2-esb

Parse JSON response in WSO2 ESB 4.6.0


I'm calling a webservice using WSO2 ESB 4.6.0 and I'm getting this raw response:

HTTP/1.0 200 OK
Content-Type: application/json;charset=ISO-8859-1
X-Powered-By: Servlet 2.5; JBoss-5.0/JBossWeb-2.1
Server: Apache-Coyote/1.1
Date: Mon, 19 Oct 2015 18:08:48 GMT
Connection: Close

"OK"

The possible answers are "OK" and "ERROR".

The problem is, in the outSequence, I want to put the "OK" value in some property or use it as input for XSLT Mediator.
Adding <property name="messageType" value="application/xml" scope="axis2" type="STRING"/> to the sequence simply makes the value be replaced by an empty soap body.
I know the ESB 4.8.1 have the json-eval() method, but the 4.6.0 doesn't.

There's a way to do that in this version?


Solution

  • There is no any direct way to obtain the message content unless you receive it over text/plain content type (opposed to application/json) or register the text/plain message builder for application/json content type. This is because your web service response does not look like valid JSON.