HttpUtil;
public static String postWithParamsForString(String url, List<NameValuePair> params){
HttpClient client = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(url);
String msg = "";
try {
httpPost.setEntity(new UrlEncodedFormEntity(params,"UTF-8"));
httpPost.setHeader("Content-type", "application/x-www-form-urlencoded");
HttpResponse response = client.execute(httpPost);
int statusCode = response.getStatusLine().getStatusCode();
if(statusCode==200){
HttpEntity entity = response.getEntity();
msg = EntityUtils.toString(entity);
System.out.println(msg);
// String conStrValue=response.get
}
} catch (IOException e) {
e.printStackTrace();
}
return msg;
}
NameValuePair Pair1=new BasicNameValuePair("mertId",mertId);
NameValuePair Pair2=new BasicNameValuePair("outNo",outNo);
NameValuePair Pair3=new BasicNameValuePair("pId",pId);
NameValuePair Pair4=new BasicNameValuePair("version","1.0");
NameValuePair Pair5=new BasicNameValuePair("fname",fname);
NameValuePair Pair6=new BasicNameValuePair("aType",aType);
NameValuePair Pair7=new BasicNameValuePair("number","1");
NameValuePair Pair8=new BasicNameValuePair("nfUrl","http://127.0.0.1/d22");
NameValuePair Pair9=new BasicNameValuePair("timeStamp",""+date);
NameValuePair Pair10=new BasicNameValuePair("sign",sign);
pairList.add(Pair1);
pairList.add(Pair2);
pairList.add(Pair3);
pairList.add(Pair4);
pairList.add(Pair5);
pairList.add(Pair6);
pairList.add(Pair7);
pairList.add(Pair8);
pairList.add(Pair9);
pairList.add(Pair10);
String json= HttpUtils.postWithParamsForString(SEVER_URL,pairList);