|
本帖最后由 new_lio 于 2013-7-18 15:30 编辑
首先介绍下,我这边项目是安卓APK,然后我想用loadrunner模拟安卓apk向服务器发送json请求
然后我分别抓取了apk一个动作的请求包
电脑上面,sdk模拟器里面的apk(pc上面http抓包)
http://192.168.1.183:8080/AIO/VisitorService.json
{"id":-1046118514,"method":"signIn","params":["{\"data\":\"{\\\"phoneNo\\\":\\\"321\\\",\\\"visitorName\\\":\\\"??\\\",\\\"email\\\":\\\"mct@mct\\\",\\\"visitorId\\\":\\\"412326198503153952\\\"}\"}"]}
http://192.168.1.183:8080/AIO/ComplainService.json
{"id":976873371,"method":"saveComplain","params":["{\"data\":\"%7B%5C%22content%5C%22%3A%5C%22xx%5C%22%2C%5C%22title%5C%22%3A%5C%22xx%5C%22%2C%5C%22addresseeName%5C%22%3A%5C%22%E5%85%AC%E5%AE%89%E5%B1%80%5C%22%2C%5C%22addresserName%5C%22%3A%5C%22%E9%87%91%E6%B0%B8%5C%22%2C%5C%22sendTime%5C%22%3A%5C%222013-06-14+03%3A35%3A13%5C%22%2C%5C%22addressee%5C%22%3A%5C%22ff8080813e8b1861013e8b1c51bc0003%5C%22%2C%5C%22contentType%5C%22%3A%5C%221%5C%22%2C%5C%22addresser%5C%22%3A%5C%22ff8080813e866bd6013e8a9d52b90007%5C%22%7D\"}"]}
真正平板上面的apk启动真实操作后,服务器后台日志
signIn: {"data":"{\"phoneNo\":\"321\",\"visitorName\":\"??\",\"email\":\"mct@mct\",\"visitorId\":\"412326198503153952\"}"}
2013-07-17 23:18:12,669 DEBUG [cn.org.coral.biz.complain.service.jsonif.impl.ComplainJsonServiceImpl.saveComplain]>>>
saveComplain: {"data":"{\"content\":\"test\",\"title\":\"test\",\"addresseeName\":\"公安局\",\"addresserName\":\"金永\",\"sendTime\":\"2010-01-01 09:12:08\",\"addressee\":\"ff8080813e8b1861013e8b1c51bc0003\",\"contentType\":\"1\",\"addresser\":\"ff8080813e866bd6013e8a9d52b90007\"}"}
然后对这个json请求用lr来模拟,lr代码
Action()
{
web_reg_save_param("json",
"LB=",
"RB=",
LAST);
web_custom_request("web_custom_request",
"URL=http://192.168.1.183:8080/AIO/VisitorService.json",
"Method=POST",
"TargetFrame=",
"Resource=0",
"RecContentType=application/x-www-form-urlencoded charset=utf-8",
//application/x-www-form-urlencoded charset=utf-8
"Referer=",
"Body=[\"{\"data\":\"{\\\"phoneNo\\\":\\\"321\\\",\\\"visitorName\\\":\\\"??\\\",\\\"email\\\":\\\"mct@mct\\\",\\\"visitorId\\\":\\\"412326198503153952\\\"}\"}\"]",
LAST);
web_custom_request("web_custom_request",
"URL=http://192.168.1.183:8080/AIO/ComplainService.json",
"Method=POST",
"TargetFrame=",
"Resource=0",
"RecContentType=application/x-www-form-urlencoded charset=union",
//application/x-www-form-urlencoded charset=utf-8
"Referer=",
"Body=[\"{\"data\":\"%7B%5C%22content%5C%22%3A%5C%22xx%5C%22%2C%5C%22title%5C%22%3A%5C%22xx%5C%22%2C%5C%22addresseeName%5C%22%3A%5C%22%E5%85%AC%E5%AE%89%E5%B1%80%5C%22%2C%5C%22addresserName%5C%22%3A%5C%22%E9%87%91%E6%B0%B8%5C%22%2C%5C%22sendTime%5C%22%3A%5C%222013-06-14+03%3A35%3A13%5C%22%2C%5C%22addressee%5C%22%3A%5C%22ff8080813e8b1861013e8b1c51bc0003%5C%22%2C%5C%22contentType%5C%22%3A%5C%221%5C%22%2C%5C%22addresser%5C%22%3A%5C%22ff8080813e866bd6013e8a9d52b90007%5C%22%7D\"}\"]",
LAST);
lr_output_message("返回捕获:%s",lr_eval_string("{json}"));
return 0;
}
问题:
1.通过这2个方式的抓包,我发现json请求代码不一样,这个没关系,2个json串我都试了,都是同样的错误
错误如下,截取部分错误,如附件图片所示
2013-07-17 23:26:19,551 ERROR [/AIO/VisitorService.json._jspService]>>> No content to map due to end-of-input
at [Source: com.googlecode.jsonrpc4j.NoCloseInputStream@2a402b0e; line: 1, column: 1]
com.fasterxml.jackson.databind.JsonMappingException: No content to map due to end-of-input
at [Source: com.googlecode.jsonrpc4j.NoCloseInputStream@2a402b0e; line: 1, column: 1]
at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:164) [jackson-databind-2.1.1.jar:2.1.1]
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:2839) [jackson-databind-2.1.1.jar:2.1.1]
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:2781) [jackson-databind-2.1.1.jar:2.1.1]
at com.fasterxml.jackson.databind.ObjectMapper.readTree(ObjectMapper.java:1627) [jackson-databind-2.1.1.jar:2.1.1]
at com.googlecode.jsonrpc4j.JsonRpcServer.handle(JsonRpcServer.java:220) [jsonrpc4j-0.26.jar:na]
如果加上这个后"EncType=utf-8",后台又会报这个utf-8的错误,如附件所示 |
|