Tuesday, 2 July 2013
complex web
public static String LogoutWebservice(String logid,String latitude,String longitude,String logmode,String reason) throws IllegalStateException, ClientProtocolException, IOException {
try{
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(postURL);
System.out.println("reached in webservice class for login");
List<NameValuePair> params = new ArrayList<NameValuePair>();
str=jsonEncodinggetLogout(logid,latitude,longitude,logmode,reason).toString();
System.out.println("json="+str);
params.add(new BasicNameValuePair("Data",str));
params.add(new BasicNameValuePair("reubro_debug","1"));
UrlEncodedFormEntity ent = new UrlEncodedFormEntity(params,HTTP.UTF_8);
post.setEntity(ent);
System.out.println("rrrrrrrr= ==" +postURL+ params);
System.out.println("PARAM= " + params);
HttpResponse responsePOST = client.execute(post);
HttpEntity resEntity = responsePOST.getEntity();
str=EntityUtils.toString(resEntity);
str=str.trim();
int res = responsePOST.getStatusLine().getStatusCode();
System.out.println("res in LogoutWebservice webservice====="+res);
}
catch (Exception e) {
e.printStackTrace();
}
System.out.println("RESPONSE in LogoutWebservice webservice = ===" + str);
return str;
}
public static JSONObject jsonEncodinggetLogout(String logid,String latitude,String longitude,String logmode,String reason){
/** Called when the activity is first created. */
JSONObject obj=new JSONObject();
try{
int v=Integer.parseInt(logid);
JSONArray argsArray = new JSONArray();
JSONObject objnew=new JSONObject();
objnew.put("login_id",v);
objnew.put("lat",latitude);
objnew.put("lon",longitude);
objnew.put("login_mode",1);
objnew.put("clk_out_note",reason);
argsArray.put(0,objnew);
obj.put("argsArray",argsArray);
obj.put("methodName","userLogout");
}
catch(Exception e){
}
return(obj);
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment