web services - Post webservice is not working in Android -
i new android webservices. have never used post webservice. tried below neither showing success nor failure.
if use advanced rest client chrome extension, able test , webservice working takes time.
when trying run code, shows - after calling webservices - toast msg --> indicates did not call webservice.
spent 2 days in no luck. suggestions?
public void borrowbook(string barcode, string patronid) { final int default_timeout = 200000 * 1000000000; // make restful webservice call using asynchttpclient object asynchttpclient client = new asynchttpclient(); client.settimeout(default_timeout); progress.setmessage("please wait..."); progress.setindeterminate(false); progress.setcancelable(false); progress.show(); requestparams params = new requestparams(); toast.maketext(getactivity().getapplicationcontext(), "b4 calling webservice", toast.length_long).show(); client.post("http://43.555.6.111:8081/sipservices/sic.svc/checkout?barcode=b12&patron=thi", new texthttpresponsehandler() { @override public void onsuccess(int i, header[] headers, string response) { toast.maketext(getactivity().getapplicationcontext(), "response: " + response, toast.length_long).show(); log.d("tag", "success"); } @override public void onfailure(int statuscode, header[] headers, string response, throwable error) { toast.maketext(getactivity().getapplicationcontext(), "status code :" + statuscode + "errmsg : " + error.getmessage(), toast.length_long).show(); toast.maketext(getactivity().getapplicationcontext(), "unexpected error occcured! [most common error: device might not connected internet or remote server not , running]", toast.length_long).show(); log.d("tag", "failure"); } } ); progress.dismiss(); toast.maketext(getactivity().getapplicationcontext(), "after calling webservice", toast.length_long).show(); }
you don't set parameters anything, , don't send them. plus you're trying post call, url parameters: "http://43.555.6.111:8081/sipservices/sic.svc/checkout?barcode=b12&patron=thi"
also consider implementing onstart method , log it, see if starts.
Comments
Post a Comment