HttpClient测试接口Test
2017-10-11 21:43
337 查看
用于流传输的数据接口HttpClient jar包
public static void main(String[] args) throws HttpException,IOException{
DefaultHttpClient httpClient=new DefaultHttpClient();
HttpPost httpPost=new HttpPost("http://234.84.123.56:10001/sqjz/exchange/exchangeLocation?TOKEN=dc3bc9f6484a835cad6bea1db62b48e2");
Map<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("ID","IlwqkLBiflj");
paramsMap.put("JD", "121.5074441");
paramsMap.put("WD", "31.2536434");
paramsMap.put("DWHM", "88006542");
paramsMap.put("DWDDWZMC", "上海市 虹口区 东长治路 靠近提篮桥(地铁站)");
paramsMap.put("FWS", "1");
paramsMap.put("DWZT", "1");
paramsMap.put("DWSJ", "2017-10-11 20:50:58");
// JSONObject jsonObject=(JSONObject) JSONObject.toJSON(paramsMap);
JSONArray jsonArray=JSONArray.fromObject(paramsMap);
List list = new ArrayList ();
list.add(new BasicNameValuePair("exLocationArr", jsonArray.toString()));
httpPost.setEntity(new UrlEncodedFormEntity((list),"gbk"));
//
// httpclient.executeMethod(post);
// String info = new String(post.getResponseBody(),"utf-8");
HttpResponse httpResponse;
httpResponse=httpClient.execute(httpPost);
HttpEntity entity=httpResponse.getEntity();
System.out.println(EntityUtils.toString(entity, "utf-8"));
}
public static void main(String[] args) throws HttpException,IOException{
DefaultHttpClient httpClient=new DefaultHttpClient();
HttpPost httpPost=new HttpPost("http://234.84.123.56:10001/sqjz/exchange/exchangeLocation?TOKEN=dc3bc9f6484a835cad6bea1db62b48e2");
Map<String, String> paramsMap = new HashMap<String, String>();
paramsMap.put("ID","IlwqkLBiflj");
paramsMap.put("JD", "121.5074441");
paramsMap.put("WD", "31.2536434");
paramsMap.put("DWHM", "88006542");
paramsMap.put("DWDDWZMC", "上海市 虹口区 东长治路 靠近提篮桥(地铁站)");
paramsMap.put("FWS", "1");
paramsMap.put("DWZT", "1");
paramsMap.put("DWSJ", "2017-10-11 20:50:58");
// JSONObject jsonObject=(JSONObject) JSONObject.toJSON(paramsMap);
JSONArray jsonArray=JSONArray.fromObject(paramsMap);
List list = new ArrayList ();
list.add(new BasicNameValuePair("exLocationArr", jsonArray.toString()));
httpPost.setEntity(new UrlEncodedFormEntity((list),"gbk"));
//
// httpclient.executeMethod(post);
// String info = new String(post.getResponseBody(),"utf-8");
HttpResponse httpResponse;
httpResponse=httpClient.execute(httpPost);
HttpEntity entity=httpResponse.getEntity();
System.out.println(EntityUtils.toString(entity, "utf-8"));
}
相关文章推荐
- 启动thrift接口后,在这个服务上写一个test方法去测试,获取thrift中常量方法中的静态变量
- 使用HttpClient配置代理服务器模拟浏览器发送请求调用接口测试
- 使用pytest+requests进行接口测试实践——测试post请求
- 使用简单的unittest编写接口测试脚本
- 使用HttpClient进行远程接口测试
- 基于HttpClient的Http接口测试用例
- C#进阶系列——WebApi 接口测试工具:WebApiTestClient
- springtest-junit-jidi--测试接口
- HttpClient做接口测试时自定义参数长度
- python 使用unittest 测试接口
- python接口自动化测试(八)-unittest-生成测试报告
- 详解C# WebApi 接口测试工具:WebApiTestClient
- WebApi 接口测试工具:WebApiTestClient
- java使用Test测试接口类
- C#进阶系列——WebApi 接口测试工具:WebApiTestClient
- Test an interface(测试接口)
- WebApi(一)【接口测试工具:WebApiTestClient】
- 使用httpClient进行接口测试
- 性能测试--接口测试之PerfTest