httpclient请求

  


Map<字符串,Object>, queryParams=new  HashMap<字符串,Object> ();   queryParams.put (“paramXml”、“传送内容”);      String  str =, doWebservice(“传送url地址”,,queryParams); public , String  doWebservice (String  url, Map<字符串,Object>, params), throws  Exception  {   String  String =,””;   HttpClient  HttpClient =, HttpClients.createDefault ();   HttpPost  HttpPost =, new  HttpPost (url);   Set祝辞,entrySet =, params.entrySet ();   for  (Entry<字符串,Object>, entry :, entrySet), {   httppost.setEntity (new  StringEntity((字符串),entry.getValue (), ContentType.TEXT_PLAIN));   }   try  {   HttpResponse  HttpResponse =, httpclient.execute (httppost);   int  code =, httpResponse.getStatusLine () .getStatusCode ();   if  (code ==, HttpStatus.SC_OK), {   HttpEntity  entity2 =, httpResponse.getEntity ();   时间=string  EntityUtils.toString (entity2);//system.out.println(字符串);   },{else    throw  new 例外(“HTTP  Request  is 失败了,,Response  code  is “+,代码);   }   },catch  (Exception 交货),{   ex.printStackTrace ();   },{finally    httppost.clone ();   }   return 字符串;   }


httpclient请求