以json为body发送get请求

String url="http://61.161.211.134:9011/tsp/cherry?";
CloseableHttpClient httpclient = null;
httpclient = HttpClients.createDefault();
JSONObject header = new JSONObject();
header.put("fv","0201");
header.put("rs","7");
header.put("v","1.0");
header.put("fn","GW.ECALL.GET_LOCATION");
JSONObject body = new JSONObject();
body.put("woNoOutside","woNoOutside");
body.put("vin","vin");
body.put("msisdn","msisdn");
JSONObject p=new JSONObject();
p.put("header",header);
p.put("body",body);
List params = new ArrayList();
params.add(new BasicNameValuePair("p", p.toString()));
String url1 = url+"" + URLEncodedUtils.format(params, HTTP.UTF_8);
HttpGet get = new HttpGet(url1);
CloseableHttpResponse response = httpclient.execute(get);
HttpEntity entity1 = response.getEntity();
String result = EntityUtils.toString(entity1);
response.close();
System.out.println(":"+result);

你可能感兴趣的:(Java基础)