php - How to send request to https webservice in Android? -
i trying send request https webservice
returns 404 not found
(request url not found on server) works in browser.it returns response in xml
format. please guys.
here code
try { schemeregistry schemeregistry = new schemeregistry(); schemeregistry.register(new scheme("https", sslsocketfactory .getsocketfactory(), 443)); httpparams param = new basichttpparams(); singleclientconnmanager mgr = new singleclientconnmanager(param, schemeregistry); httpclient client = new defaulthttpclient(mgr, param); httppost post = new httppost(global.card_api_url); list<namevaluepair> parameters = new arraylist<namevaluepair>(); parameters.add(new basicnamevaluepair("user", "xxx")); parameters.add(new basicnamevaluepair("pass", "xxxxxxxx")); parameters.add(new basicnamevaluepair("cardnumber", "xxxxxxxxxxxxxxxx")); parameters.add(new basicnamevaluepair("expirydate", "0515")); parameters.add(new basicnamevaluepair("cvc", "123")); post.setentity(new urlencodedformentity(parameters)); httpresponse response = client.execute(post); string res = entityutils.tostring(response.getentity()); log.d("card details", res); } catch (exception e) { e.printstacktrace(); }
try code may out...
sslcontext ctx; try { ctx = sslcontext.getinstance("tls"); ctx.init(null, new trustmanager[] { new x509trustmanager() { public void checkclienttrusted(x509certificate[] chain, string authtype) {} public void checkservertrusted(x509certificate[] chain, string authtype) {} public x509certificate[] getacceptedissuers() { return new x509certificate[]{}; } } }, null); httpsurlconnection.setdefaultsslsocketfactory(ctx.getsocketfactory()); } catch (nosuchalgorithmexception e) { e.printstacktrace(); } catch (keymanagementexception e) { e.printstacktrace(); }
Comments
Post a Comment