我有两个REST服务,它们返回一些简单的JSON。我使用克隆中介调用每个服务,然后将聚合消息返回给客户端。
问题是,每次调用API时,ESB输出上都会出现以下错误:
ERROR - OMSourcedElementImpl Could not get parser from data source for element jsonObject
我已经单独测试了相同的REST服务,没有克隆中介,而且没有问题。
下面是API序列:
<api xmlns="http://ws.apache.org/ns/synapse" name="PolicyQuery" context="/policy/query">
<resource methods="POST">
<inSequence>
<property name="ROOT" scope="default">
<root:rootelement xmlns:root="www.wso2esb.com"/>
</property>
<log level="full"/>
<clone continueParent="true" id="test" sequential="true">
<target>
<sequence>
<send>
<endpoint>
<address uri="http://ip.jsontest.com/" format="rest"/>
</endpoint>
</send>
</sequence>
</target>
<target>
<sequence>
<send>
<endpoint>
<address uri="http://ip.jsontest.com/" format="rest"/>
</endpoint>
</send>
</sequence>
</target>
</clone>
</inSequence>
<outSequence>
<log level="full"/>
<aggregate>
<completeCondition>
<messageCount min="-1" max="-1"/>
</completeCondition>
<onComplete expression="//return" enclosingElementProperty="ROOT">
<property name="messageType" value="application/json" scope="axis2" type="STRING"/>
<send/>
</onComplete>
</aggregate>
</outSequence>
</resource>
</api>
我做错什么了吗?我使用的是WSO2 5.0.0 (我也用4.9.0进行了测试,也遇到了同样的问题)。
我要发送的请求有效负载是:
{
IdNumber : "8008185315088",
LastName : null
}
发布于 2016-08-23 03:33:08
在像这样更新了序列之后,这对我来说很好。你能试试这个吗?
<outSequence>
<log level="full"/>
<aggregate>
<completeCondition>
<messageCount min="2" max="2"/>
</completeCondition>
<onComplete expression="//ip" enclosingElementProperty="ROOT">
<property name="messageType" value="application/json" scope="axis2" type="STRING"/>
<send/>
</onComplete>
</aggregate>
</outSequence>
注意:如果您得到的json格式错误,则可能会出现错误。但是用这个样本,我看不出这样的问题。
编辑
问题在于json格式。应该是这样修的。
{
"IdNumber" : "8008185315088",
"LastName" : null
}
https://stackoverflow.com/questions/39095407
复制