1
我在WSO2 ESB 5.0中实现了一个应接受带有XML主体的POST的API,然后将其转发给另一个带有包含原始XML主体的JSON主体的webservice属性。WSO2 ESB:将原始XML正文包含到JSON负载中
例子:
我发布了以下机身到我的ESB API:
<?xml version="1.0" encoding="utf-8"?>
<workorder id="foobar">
<foo/>
</workorder>
我希望类似以下内容被张贴到我的web服务:现在
{
"key1": "value1",
"key2": "value2",
"input" : "<?xml version=\"1.0\" encoding=\"utf-8\"?><workorder id=\"foobar\"><foo/></workorder>"
}
对于inSequence的样子:
<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>
它返回:
{
"key1": "value1",
"key2": "value2",
"input" : "[<workorder id="foobar"><foo/></workorder>]"
}
我不知道如何着手。我想要的只是检索我发布的原始文本(并且转义双引号以便它可以包含在JSON中)。