[英]An API in WSO2 ESB only returns the first node of an JSON?
我已经在WSO2企业服务总线中创建了REST API。 该API调用SoapUI上的模拟服务,该服务返回具有2个节点的JSON:
{
"customer" : {
"value1": "2312",
"value2": "3214",
"value3": "4214"
},
"msg" : "error"
}
ESB应该返回此JSON,但始终忽略第二个节点(“ msg”),而仅返回第一个节点。
我已经更改了位置,类似这样,但是不起作用:
{
"msg" : "error",
"customer" : {
"value1": "2312",
"value2": "3214",
"value3": "4214"
}
}
该API非常简单,类似于:
<?xml version="1.0" encoding="UTF-8"?>
<api context="/test1" name="test" xmlns="http://ws.apache.org/ns/synapse">
<resource methods="POST" protocol="http">
<inSequence>
<send>
<endpoint key="conf:/endpoint.xml"/>
</send>
</inSequence>
<outSequence/>
<faultSequence/>
</resource>
</api>
我已经检查过模拟了,它对ESB的回答正确
为什么我的API仅返回第一个节点?
我的电汇记录:
[2016-08-03 14:04:14,343] DEBUG - wire >> "POST /CustomerHSF/retrieveCustomerHSF HTTP/1.1[\r][\n]"
[2016-08-03 14:04:14,344] DEBUG - wire >> "HOST: localhost:8283[\r][\n]"
[2016-08-03 14:04:14,345] DEBUG - wire >> "content-type: application/json[\r][\n]"
[2016-08-03 14:04:14,345] DEBUG - wire >> "content-length: 100[\r][\n]"
[2016-08-03 14:04:14,345] DEBUG - wire >> "[\r][\n]"
[2016-08-03 14:04:14,345] DEBUG - wire >> "{[\r][\n]"
[2016-08-03 14:04:14,345] DEBUG - wire >> ""nomCliente": "SILVA",[\r][\n]"
[2016-08-03 14:04:14,345] DEBUG - wire >> ""tipoPessoa": "FIS",[\r][\n]"
[2016-08-03 14:04:14,345] DEBUG - wire >> ""dscEmail": "google@google.com"[\r][\n]"
[2016-08-03 14:04:14,346] DEBUG - wire >> "}[\r][\n]"
[2016-08-03 14:04:14,347] INFO - LogMediator Starting inSequence retrieveCustomerHSF = Starting inSequence retrieveCustomerHSF
[2016-08-03 14:04:14,349] DEBUG - wire << "POST /integradorhsf/clientes/ HTTP/1.1[\r][\n]"
[2016-08-03 14:04:14,349] DEBUG - wire << "Content-Type: application/json; charset=UTF-8[\r][\n]"
[2016-08-03 14:04:14,349] DEBUG - wire << "Transfer-Encoding: chunked[\r][\n]"
[2016-08-03 14:04:14,349] DEBUG - wire << "Host: localhost:8082[\r][\n]"
[2016-08-03 14:04:14,349] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"
[2016-08-03 14:04:14,349] DEBUG - wire << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
[2016-08-03 14:04:14,349] DEBUG - wire << "[\r][\n]"
[2016-08-03 14:04:14,349] DEBUG - wire << "64[\r][\n]"
[2016-08-03 14:04:14,350] DEBUG - wire << "{[\r][\n]"
[2016-08-03 14:04:14,350] DEBUG - wire << ""nomCliente": "SILVA",[\r][\n]"
[2016-08-03 14:04:14,350] DEBUG - wire << ""tipoPessoa": "FIS",[\r][\n]"
[2016-08-03 14:04:14,350] DEBUG - wire << ""dscEmail": "google@google.com.br"[\r][\n]"
[2016-08-03 14:04:14,350] DEBUG - wire << "}[\r][\n]"
[2016-08-03 14:04:14,350] DEBUG - wire << "[\r][\n]"
[2016-08-03 14:04:14,350] DEBUG - wire << "0[\r][\n]"
[2016-08-03 14:04:14,350] DEBUG - wire << "[\r][\n]"
[2016-08-03 14:04:14,356] DEBUG - wire >> "HTTP/1.1 200 OK[\r][\n]"
[2016-08-03 14:04:14,356] DEBUG - wire >> "Content-Type: application/json[\r][\n]"
[2016-08-03 14:04:14,356] DEBUG - wire >> "Content-Length: 47[\r][\n]"
[2016-08-03 14:04:14,356] DEBUG - wire >> "Server: Jetty(6.1.26)[\r][\n]"
[2016-08-03 14:04:14,356] DEBUG - wire >> "[\r][\n]"
[2016-08-03 14:04:14,356] DEBUG - wire >> "{[\n]"
[2016-08-03 14:04:14,356] DEBUG - wire >> ""retorno": "dados cliente",[\n]"
[2016-08-03 14:04:14,356] DEBUG - wire >> ""msg": "error"[\n]"
[2016-08-03 14:04:14,356] DEBUG - wire >> "}[\n]"
[2016-08-03 14:04:14,360] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:117c7eb8-c4f2-40a4-b26d-73f64863303a, Direction: response, Starting outSequence retrieveCustomerHSF = Starting outSequence retrieveCustomerHSF, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><retorno>dados cliente</retorno></soapenv:Body></soapenv:Envelope>
[2016-08-03 14:04:14,369] DEBUG - wire << "HTTP/1.1 200 OK[\r][\n]"
[2016-08-03 14:04:14,369] DEBUG - wire << "Content-Type: application/json; charset=UTF-8[\r][\n]"
[2016-08-03 14:04:14,369] DEBUG - wire << "Date: Wed, 03 Aug 2016 17:04:14 GMT[\r][\n]"
[2016-08-03 14:04:14,369] DEBUG - wire << "Transfer-Encoding: chunked[\r][\n]"
[2016-08-03 14:04:14,369] DEBUG - wire << "[\r][\n]"
[2016-08-03 14:04:14,369] DEBUG - wire << "1b[\r][\n]"
[2016-08-03 14:04:14,369] DEBUG - wire << "{"retorno":"dados cliente"}[\r][\n]"
[2016-08-03 14:04:14,369] DEBUG - wire << "0[\r][\n]"
[2016-08-03 14:04:14,369] DEBUG - wire << "[\r][\n]"
理想情况下,它不能返回任何东西。 在<outSequence/>
添加<send/>
介体应该可以解决此问题。 您可以启用电汇日志,否则进行检查。
我猜想,消息流可能无法正确识别json格式。 请按以下步骤更改顺序并尝试:
<outSequence xmlns="http://ws.apache.org/ns/synapse">
<property name="messageType" value="application/json" scope="axis2" type="STRING"></property>
<send/>
</outSequence>
对于复杂的JSON响应,您可以使用:
<outSequence xmlns="http://ws.apache.org/ns/synapse">
<property name="messageType" value="application/json/badgerfish" scope="axis2" type="STRING"></property>
<send/>
</outSequence>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.