我遇到有效载荷问题。我跟着https://docs.wso2.com/display/ESB500/Exposing+Several+Services+as+a+Single+Service
但无法创建适当的有效负载
<log level="custom">
<property expression="fn:concat('VIN: ',get-property('vin'),' ModelName: ',get-property('modelName'),' Year: ',get-property('modelYear'))" name="vechicle"/>
</log>
<payloadFactory description="VIN message" media-type="json">
<format>{
"VIN":$1,
}</format>
<args>
<arg evaluator="xml" expression="$ctx:vin"/>
</args>
</payloadFactory>
get-property('vin')正在工作因为我在log BUT中看到有效负载没有用实际值替换$ 1,评估出错了
错误讯息:
Could not get parser from data source for element jsonObject
TID[-1234] [ESB] [2017-03-07 23:46:37,611] ERROR {org.apache.axiom.om.impl.llom.OMSourcedElementImpl} - Could not get parser from data source for element jsonObject org.apache.synapse.commons.staxon.core.base.AbstractXMLStreamReader.initialize(AbstractXMLStreamReader.java:245) org.apache.synapse.commons.staxon.core.json.JsonXMLStreamReader.(JsonXMLStreamReader.java:66) org.apache.synapse.commons.staxon.core.json.JsonXMLInputFactory.createXMLStreamReader(JsonXMLInputFactory.java:165) org.apache.synapse.commons.json.JsonUtil.getReader(JsonUtil.java:302) org.apache.synapse.commons.json.JsonDataSource.getReader(JsonDataSource.java:153) org.apache.axiom.om.impl.llom.OMSourcedElementImpl.getDirectReader(OMSourcedElementImpl.java:225) org.apache.axiom.om.impl.llom.OMSourcedElementImpl.forceExpand(OMSourcedElementImpl.java:254) org.apache.axiom.om.impl.llom.OMSourcedElementImpl.getFirstOMChild(OMSourcedElementImpl.java:867) org.apache.axiom.om.impl.OMNavigator._getFirstChild(OMNavigator.java:196) org.apache.axiom.om.impl.OMNavigator.updateNextNode(OMNavigator.java:140) org.apache.axiom.om.impl.OMNavigator.getNext(OMNavigator.java:112) org.apache.axiom.om.impl.SwitchingWrapper.updateNextNode(SwitchingWrapper.java:1113) org.apache.axiom.om.impl.SwitchingWrapper.(SwitchingWrapper.java:235) org.apache.axiom.om.impl.OMStAXWrapper.(OMStAXWrapper.java:74) org.apache.axiom.om.impl.llom.OMStAXWrapper.(OMStAXWrapper.java:52) org.apache.axiom.om.impl.llom.OMContainerHelper.getXMLStreamReader(OMContainerHelper.java:51) org.apache.axiom.om.impl.llom.OMElementImpl.getXMLStreamReader(OMElementImpl.java:736) org.apache.axiom.om.impl.llom.OMElementImpl.cloneOMElement(OMElementImpl.java:1038) org.apache.synapse.util.MessageHelper.cloneSOAPEnvelope(MessageHelper.java:690)
帮助...
答案 0 :(得分:1)
问题似乎出现在JSON消息中。首先,JSON消息本身的格式化无关紧要,因此回车应该是过时的。然而,这似乎不是问题。其次,在$ 1之后有一个逗号,这表明会有另一个对象但是有一个回车然后是结束括号,这实际上是破解了解析器:我会这样尝试(尽管你可以留下回车,我已经在ESB 5.0.0上进行了测试)
<payloadFactory description="VIN message" media-type="json">
<format>{
"VIN":$1
}</format>
<args>
<arg evaluator="xml" expression="$ctx:vin"/>
</args>
</payloadFactory>
此外,如果vin是一个字符串,那么您可能还需要添加格式的引号。