1、GET方式
HttpGet httpGet = new HttpGet("http://localhost:8080/randomCode/getSouthUuid");
String sourceId = "100001";
String appkey = "34";
List<NameValuePair> arrayList = new ArrayList<NameValuePair>();
arrayList.add(new BasicNameValuePair("clientId", sourceId));
arrayList.add(new BasicNameValuePair("appkey", appkey));
// 设置参数
String string = EntityUtils.toString(new UrlEncodedFormEntity(arrayList, "utf-8"));
httpGet.setURI(new URI(httpGet.getURI().toString() + "?" + string));
String str = httpInvoker.invoke(httpGet, HttpInvoker.STRING_ENTITY_HANDLER);
2、POST方式
HttpPost post = new HttpPost(url);
logger.debug("testpath --------->"+TESTPATH)
// 创建参数列表
List<NameValuePair> arrayList = new ArrayList<NameValuePair>();
arrayList.add(new BasicNameValuePair("code", "xxx"));
arrayList.add(new BasicNameValuePair("redirect_uri", "xxx"));
arrayList.add(new BasicNameValuePair("grant_type", "xxx"));
// url格式编码
UrlEncodedFormEntity uefEntity = new UrlEncodedFormEntity(arrayList, "UTF-8");
post.setEntity(uefEntity);
String str = httpInvoker.invoke(post, HttpInvoker.STRING_ENTITY_HANDLER);
JSONObject json = JSONObject.parseObject(str);
String values = json.get("xxx").toString();