首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在wso2 api管理器的自定义处理程序中获取GET类型rest api的空体

在wso2 api管理器的自定义处理程序中获取GET类型rest api的空体
EN

Stack Overflow用户
提问于 2016-10-05 20:03:01
回答 1查看 476关注 0票数 1

我在soap主体中的响应有效负载是empty.Below,它是在api manager中配置的自定义处理程序代码。我打印了正文,它显示了empty.My rest api应该返回的数据列表。

代码语言:javascript
复制
public boolean handleResponse(MessageContext messageContext)
 {
try {

            RelayUtils.buildMessage(((Axis2MessageContext) messageContext).getAxis2MessageContext());
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (XMLStreamException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

 log.info("Response Body:"+messageContext.getEnvelope().getBody());
}

如果API的响应状态为OK,但如果为ACCEPT状态,则响应正文为空。

代码语言:javascript
复制
This is my logs after enabling the wire. Please help. Thanks in advance.

    In Case of @ResponseStatus(value=HttpStatus.OK) wire log
=================================================================
"GET /customer/list HTTP/1.1[\r][\n]"   
[2016-10-07 13:48:58,643] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "Accept-Language: en-US,en;q=0.8[\r][\n]"  
[2016-10-07 13:48:58,643] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "Accept-Encoding: gzip, deflate, sdch, br[\r][\n]"  
[2016-10-07 13:48:58,644] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "Postman-Token: 780f0eac-254b-d93e-9801-93fe8bac79a6[\r][\n]"  
[2016-10-07 13:48:58,644] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "Accept: */*[\r][\n]"   
[2016-10-07 13:48:58,644] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "Cache-Control: no-cache[\r][\n]"  
[2016-10-07 13:48:58,644] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "Host: localhost:8088[\r][\n]"  
[2016-10-07 13:48:58,644] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "Connection: Keep-Alive[\r][\n]"
[2016-10-07 13:48:58,644] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"  
[2016-10-07 13:48:58,644] DEBUG - wire HTTP-Sender I/O dispatcher-1 << "[\r][\n]"
[2016-10-07 13:48:58,646] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "HTTP/1.1 200 OK[\r][\n]"   
[2016-10-07 13:48:58,646] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "Server: Apache-Coyote/1.1[\r][\n]"  
[2016-10-07 13:48:58,646] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "Content-Type: application/json;charset=UTF-8[\r][\n]"  
[2016-10-07 13:48:58,646] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "Transfer-Encoding: chunked[\r][\n]"   
[2016-10-07 13:48:58,646] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "Date: Fri, 07 Oct 2016 08:18:58 GMT[\r][\n]"   
[2016-10-07 13:48:58,647] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "[\r][\n]"   
[2016-10-07 13:48:58,647] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "5a[\r][\n]"   
[2016-10-07 13:48:58,647] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "[{"id":"1","name":"abc"},{"id":"2","name":"bcd"},{"id":"3","name":"cde"}]"    
[2016-10-07 13:48:58,652] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "[\r][\n]"  
[2016-10-07 13:48:58,652] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "0[\r][\n]"  
[2016-10-07 13:48:58,652] DEBUG - wire HTTP-Sender I/O dispatcher-1 >> "[\r][\n]"  
[2016-10-07 13:48:58,700]  INFO - MessageBuilderHandler Response body:   `<soapenv:Body xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">  <jsonArray><?xml-multiple  jsonElement?>
<jsonElement>
<id>1</id>
<name>abc</name>
</jsonElement>
<jsonElement><id>2</id>
<name>bcd</name>
</jsonElement>
<jsonElement>
<id>3</id>
<name>cde</name>
</jsonElement>
</jsonArray>
</soapenv:Body> `   
[2016-10-07 13:48:58,868] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "HTTP/1.1 200 OK[\r][\n]"  
[2016-10-07 13:48:58,869] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type,SOAPAction[\r][\n]"   
[2016-10-07 13:48:58,869] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Access-Control-Allow-Origin: *[\r][\n]"  
[2016-10-07 13:48:58,869] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Access-Control-Allow-Methods: GET[\r][\n]"  
[2016-10-07 13:48:58,869] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Content-Type: application/json;charset=UTF-8[\r][\n]"   
[2016-10-07 13:48:58,869] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Date: Fri, 07 Oct 2016 08:18:58 GMT[\r][\n]"  
[2016-10-07 13:48:58,869] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Transfer-Encoding: chunked[\r][\n]"   
[2016-10-07 13:48:58,869] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "Connection: keep-alive[\r][\n]"  
[2016-10-07 13:48:58,870] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "[\r][\n]"  
[2016-10-07 13:48:58,870] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "54[\r][\n]"  
[2016-10-07 13:48:58,870] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "[
{"id":1,"name":"abc"}, 
{"id":2,"name":"bcd"},
{"id":3,"name":"cde"}
][\r][\n]"
[2016-10-07 13:48:58,870] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "0[\r][\n]"   
[2016-10-07 13:48:58,870] DEBUG - wire HTTPS-Listener I/O dispatcher-2 << "[\r][\n]"     


In Case of @ResponseStatus(value=HttpStatus.ACCEPTED) wire log
===================================================================

DEBUG - wire HTTPS-Listener I/O dispatcher-4 >> "GET /GetCustomerList/1.0.0/customer/list HTTP/1.1[\r][\n]"   
[2016-10-07 13:52:37,060] DEBUG - wire HTTPS-Listener I/O dispatcher-4 >> "Host: localhost:8243[\r][\n]"  
[2016-10-07 13:52:37,060] DEBUG - wire HTTPS-Listener I/O dispatcher-4 >> "Connection: keep-alive[\r][\n]"  
[2016-10-07 13:52:37,060] DEBUG - wire HTTPS-Listener I/O dispatcher-4 >> "Authorization: Bearer 93cdc897-f75b-351e-ab4e-e4bd347bc742[\r][\n]"  
[2016-10-07 13:52:37,060] DEBUG - wire HTTPS-Listener I/O dispatcher-4 >> "Cache-Control: no-cache[\r][\n]"  
[2016-10-07 13:52:37,060] DEBUG - wire HTTPS-Listener I/O dispatcher-4 >> "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36[\r][\n]"   
[2016-10-07 13:52:37,060] DEBUG - wire HTTPS-Listener I/O dispatcher-4 >> "Postman-Token: 6c341e45-3d95-10af-d3b8-1e1f25360d18[\r][\n]"  
[2016-10-07 13:52:37,060] DEBUG - wire HTTPS-Listener I/O dispatcher-4 >> "Accept: */*[\r][\n]"  
[2016-10-07 13:52:37,061] DEBUG - wire HTTPS-Listener I/O dispatcher-4 >> "Accept-Encoding: gzip, deflate, sdch, br[\r][\n]"  
[2016-10-07 13:52:37,061] DEBUG - wire HTTPS-Listener I/O dispatcher-4 >> "Accept-Language: en-US,en;q=0.8[\r][\n]"  
[2016-10-07 13:52:37,061] DEBUG - wire HTTPS-Listener I/O dispatcher-4 >> "[\r][\n]"  
[2016-10-07 13:52:37,070]  INFO - MessageBuilderHandler Reqest body:
<soapenv:Body xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"/>
[2016-10-07 13:52:37,081] DEBUG - wire HTTP-Sender I/O dispatcher-2 << "GET /customer/list HTTP/1.1[\r][\n]"  
[2016-10-07 13:52:37,082] DEBUG - wire HTTP-Sender I/O dispatcher-2 << "Accept-Language: en-US,en;q=0.8[\r][\n]"  
[2016-10-07 13:52:37,082] DEBUG - wire HTTP-Sender I/O dispatcher-2 << "Accept-Encoding: gzip, deflate, sdch, br[\r][\n]"  
[2016-10-07 13:52:37,082] DEBUG - wire HTTP-Sender I/O dispatcher-2 << "Postman-Token: 6c341e45-3d95-10af-d3b8-1e1f25360d18[\r][\n]"  
[2016-10-07 13:52:37,082] DEBUG - wire HTTP-Sender I/O dispatcher-2 << "Accept: */*[\r][\n]"  
[2016-10-07 13:52:37,083] DEBUG - wire HTTP-Sender I/O dispatcher-2 << "Cache-Control: no-cache[\r][\n]"  
[2016-10-07 13:52:37,083] DEBUG - wire HTTP-Sender I/O dispatcher-2 << "Host: localhost:8088[\r][\n]"  
[2016-10-07 13:52:37,083] DEBUG - wire HTTP-Sender I/O dispatcher-2 << "Connection: Keep-Alive[\r][\n]"  
[2016-10-07 13:52:37,083] DEBUG - wire HTTP-Sender I/O dispatcher-2 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]" 
[2016-10-07 13:52:37,083] DEBUG - wire HTTP-Sender I/O dispatcher-2 << "[\r][\n]"  
[2016-10-07 13:52:37,309] DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "HTTP/1.1 202 Accepted[\r][\n]"  
[2016-10-07 13:52:37,309] DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "Server: Apache-Coyote/1.1[\r][\n]"  
[2016-10-07 13:52:37,309] DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "Content-Type: application/json;charset=UTF-8[\r][\n]"  
[2016-10-07 13:52:37,310] DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "Transfer-Encoding: chunked[\r][\n]"  
[2016-10-07 13:52:37,310] DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "Date: Fri, 07 Oct 2016 08:22:37 GMT[\r][\n]"  
[2016-10-07 13:52:37,310] DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "[\r][\n]"  
[2016-10-07 13:52:37,311] DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "5a[\r][\n]"  
[2016-10-07 13:52:37,311] DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "[{"id":"1","name":"abc"},{"id":"2","name":"bcd"},{"id":"3","name":"cde"}][\r][\n]"  
[2016-10-07 13:52:37,312] DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "0[\r][\n]"  
[2016-10-07 13:52:37,312] DEBUG - wire HTTP-Sender I/O dispatcher-2 >> "[\r][\n]"  
[2016-10-07 13:52:37,317]  INFO - MessageBuilderHandler Response body:`<soapenv:Body xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"/>`  
[2016-10-07 13:52:37,320] DEBUG - wire HTTPS-Listener I/O dispatcher-4 << "HTTP/1.1 202 Accepted[\r][\n]"  
[2016-10-07 13:52:37,321] DEBUG - wire HTTPS-Listener I/O dispatcher-4 << "Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type,SOAPAction[\r][\n]"  
[2016-10-07 13:52:37,321] DEBUG - wire HTTPS-Listener I/O dispatcher-4 << "Access-Control-Allow-Origin: *[\r][\n]"  
[2016-10-07 13:52:37,321] DEBUG - wire HTTPS-Listener I/O dispatcher-4 << "Access-Control-Allow-Methods: GET[\r][\n]"  
[2016-10-07 13:52:37,321] DEBUG - wire HTTPS-Listener I/O dispatcher-4 << "Content-Type: application/json;charset=UTF-8[\r][\n]"  
[2016-10-07 13:52:37,321] DEBUG - wire HTTPS-Listener I/O dispatcher-4 << "Date: Fri, 07 Oct 2016 08:22:37 GMT[\r][\n]"  
[2016-10-07 13:52:37,322] DEBUG - wire HTTPS-Listener I/O dispatcher-4 << "Transfer-Encoding: chunked[\r][\n]"  
[2016-10-07 13:52:37,322] DEBUG - wire HTTPS-Listener I/O dispatcher-4 << "Connection: keep-alive[\r][\n]"  
[2016-10-07 13:52:37,322] DEBUG - wire HTTPS-Listener I/O dispatcher-4 << "[\r][\n]"  
[2016-10-07 13:52:37,322] DEBUG - wire HTTPS-Listener I/O dispatcher-4 << "0[\r][\n]"  
[2016-10-07 13:52:37,322] DEBUG - wire HTTPS-Listener I/O dispatcher-4 << "[\r][\n]
EN

回答 1

Stack Overflow用户

发布于 2016-10-07 14:52:11

根据您的问题,您是说当后台响应202代码时,响应body为空,当后台响应代码为200时,您可以从上面的代码逻辑访问后台响应。首先,当http代码为202时,您必须检查响应正文是否来自后端。为此,您可以为wso2 apimanager启用连接日志,如1所示,并检查后端响应。

1

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39873437

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档