rest - Call HTTPS web service from android device with header to validate -
i want call https web service android device.which contain header validate data on server.i don't know how call https web service writen in java.if 1 explain steps me.thanl !
please check method:
private static header[] headers; private string executerequest(httpget request) throws sockettimeoutexception { string responce = null; try { httpparams httpparameters = new basichttpparams(); // set timeout in milliseconds until connection // established. int timeoutconnection = 120000; httpconnectionparams.setconnectiontimeout(httpparameters, timeoutconnection); // set default socket timeout (so_timeout) // in milliseconds timeout waiting data. int timeoutsocket = 120000; httpconnectionparams.setsotimeout(httpparameters, timeoutsocket); httpclient httpclient = new defaulthttpclient(httpparameters); httpresponse httpresponse = httpclient.execute(request); // obtain , set headers when login headers = null; headers = httpresponse.getallheaders(); responsecode = httpresponse.getstatusline().getstatuscode(); responce = entityutils.tostring(httpresponse.getentity()); } catch (parseexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } return responce; } header previousheader; // used add headers manually got response // done automatically @suppresswarnings("unused") private httpurirequest addheaders(httpurirequest request) { (int = 0; headers != null && < headers.length; i++) { request.setheader(headers[i].getname(), headers[i].getvalue()); } // request.addheader("content-length", ""); return request; }
Comments
Post a Comment