Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String makeWebCall(String url, String uname, String pass) {
- System.out
- .println("@#$@#@$#$@#$@$##$-----FOR LOGIN-------->>>>>>>>>>>>> ---------->");
- HttpPost post = new HttpPost(url);
- List<NameValuePair> params = new ArrayList<NameValuePair>();
- params.add(new BasicNameValuePair("username", uname));
- params.add(new BasicNameValuePair("password", pass));
- UrlEncodedFormEntity formEntity = null;
- try {
- formEntity = new UrlEncodedFormEntity(params);
- } catch (UnsupportedEncodingException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- }
- post.setEntity(formEntity);
- try {
- // post.setEntity(new StringEntity(requestString));
- HttpResponse response = client.execute(post);
- System.out.println("=========> Responsehello login ========> " + response);
- int statusCode = response.getStatusLine().getStatusCode();
- System.out.println("=========> statusCode login => " + statusCode);
- if (statusCode == HttpStatus.SC_OK) {
- HttpEntity entity = response.getEntity();
- InputStream is = entity.getContent();
- String StreamValue = iStream_to_String(is);
- if (entity != null) {
- //post.abort();
- EntityUtils.consume(entity);
- is.close();
- //response.getEntity().consumeContent();
- }
- return StreamValue;
- } else {
- return "Hello This is LOGIN status ==> :"
- + String.valueOf(statusCode);
- }
- } catch (UnsupportedEncodingException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (ClientProtocolException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- return null;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement