Advertisement
athacks

Untitled

Jun 23rd, 2015
646
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1.      HttpPost request = new HttpPost(SERVICE_URI + "/LoginUser");
  2.                     request.setHeader("Accept", "application/json");
  3.                     request.setHeader("Content-type", "application/json");
  4.                     // Build JSON string
  5.                     JSONStringer loginData = new JSONStringer()
  6.                             .object()
  7.                             .key("userName").value("TEST001")
  8.                             .key("SecurityKeyCode").value("PKEY0001")
  9.                             .endObject();
  10.                     StringEntity entity = new StringEntity(loginData.toString());
  11.                     Toast toastB = Toast.makeText(getApplicationContext(),
  12.                             loginData.toString() + "\n",
  13.                             Toast.LENGTH_SHORT);
  14.                     toastB.show();
  15.                     request.setEntity(entity);
  16.                     // Send request to WCF service
  17.                     DefaultHttpClient httpClient = new DefaultHttpClient();
  18.                     HttpResponse response = httpClient.execute(request);
  19.                     Toast toastA = Toast.makeText(getApplicationContext(),
  20.                             response.getStatusLine().getStatusCode() + "\n" + request.toString() + "\n",
  21.                             Toast.LENGTH_SHORT);
  22.                     toastA.show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement