I'm implementing an API in WSO2 ESB 5.0 that is supposed to accept a POST with an XML body then forward it to another webservice with a JSON body containing the original XML body as an attribute.
Example:
I post the following body to my ESB API:
<?xml version="1.0" encoding="utf-8"?>
<workorder id="foobar">
<foo/>
</workorder>
I expect something like the following to be posted to my webservice:
{
"key1": "value1",
"key2": "value2",
"input" : "<?xml version=\"1.0\" encoding=\"utf-8\"?><workorder id=\"foobar\"><foo/></workorder>"
}
For now by inSequence looks like:
<inSequence>
<property name="messageType" value="application/xml" scope="axis2"/>
<log level="full"/>
<enrich description="Store workorder">
<source type="body" clone="true"/>
<target type="property" property="SENT_WORKORDER"/>
</enrich>
<payloadFactory media-type="json" description="">
<format>{"key1": "value1", "key2": "value2", "input": "$ctx:SENT_WORKORDER"}</format>
<args/>
</payloadFactory>
<log level="full"/>
<property name="REST_URL_POSTFIX" value="/my/service" scope="axis2" type="STRING" description="Set URL"/>
<send>
<endpoint key="conf:/endpoints/my_endpoint"/>
</send>
</inSequence>
It returns this:
{
"key1": "value1",
"key2": "value2",
"input" : "[<workorder id="foobar"><foo/></workorder>]"
}
I have no idea how to proceed. All I want is to retrieve the raw text that I posted (and escape double quotes so that it can be included in JSON).