Advertisement
IZUMI_SANO

warrock

Feb 4th, 2014
2,636
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public String sendCommand(String message) {
  2.  
  3.     HttpClient httpclient = new DefaultHttpClient();
  4.     HttpPost httppost = new HttpPost(URL);
  5.     try {
  6.         String response;
  7.         StringEntity se = new StringEntity( message, HTTP.UTF_8);
  8.         se.setContentType("text/xml");
  9.         httppost.setEntity(se);
  10.  
  11.         HttpResponse httpresponse = httpclient.execute(httppost);
  12.         HttpEntity resEntity = httpresponse.getEntity();
  13.         response = EntityUtils.toString(resEntity, "UTF-8");
  14.         return response;
  15.  
  16.     } catch (ClientProtocolException e) {
  17.         e.printStackTrace();
  18.     } catch (IOException e) {
  19.         e.printStackTrace();
  20.     }
  21.     return "HttpPOST failed.";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement