Android : HTTPCLIENT POST - Cookies Rejected -
i getting below warning while running httpclient example
06-05 17:43:40.568: w/responseprocesscookies(725): cookie rejected: "basicclientcookie[version=1,name=visit,domain=.127.0.0.1,path=/,expiry=tue jun 05 17:53:40 ist 2012]". domain attribute ".127.0.0.1" violates rfc 2965: effective host name not domain-match domain attribute. i trying send data gsoap server. have gone through link1 link2 link3 din't help. here code httpclient post code
public class newa extends activity implements onclicklistener { private static final string tag = "mypost"; private boolean post_is_running = false; private dosomethingdelayed dosth; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); button pushbutton = (button) findviewbyid(r.id.push_button); pushbutton.setonclicklistener(this); } @override protected void onpause() { super.onpause(); if (post_is_running) { // stop async task if it's running if app gets // paused log.v(tag, "stopping async task onpause"); dosth.cancel(true); } } @override protected void onresume() { super.onresume(); if (post_is_running) { // start async task if running // , stopped onpause() log.v(tag, "starting async task onresume"); dosth = (dosomethingdelayed) new dosomethingdelayed().execute(); ((button) findviewbyid(r.id.push_button)).settext("resuming.."); } } public void onclick(view v) { if (post_is_running == false) { post_is_running = true; log.v(tag, "starting async task onclick"); dosth = (dosomethingdelayed) new dosomethingdelayed().execute(); ((button) findviewbyid(r.id.push_button)).settext("starting.."); } else { log.v(tag, "stopping async task onclick"); post_is_running = false; dosth.cancel(true); ((button) findviewbyid(r.id.push_button)).settext("stopping.."); } } private class dosomethingdelayed extends asynctask<void, integer, void> { private int num_runs = 0; @override protected void doinbackground(void... gurk) { while (!this.iscancelled()) { log.v(tag, "going postdata"); long ms_before = systemclock.uptimemillis(); log.v(tag, "time " + ms_before); postdata(); long ms_after = systemclock.uptimemillis(); long time_passed = ms_after - ms_before; log.v(tag, "coming out of postdata"); log.i(tag, "rtt: " + time_passed + " ms"); num_runs++; // publish ui if (!this.iscancelled()) { publishprogress(num_runs, (int) time_passed); } } return null; } @override protected void oncancelled() { context context = getapplicationcontext(); charsequence text = "cancelled bg-thread"; int duration = toast.length_long; toast.maketext(context, text, duration).show(); ((button) findviewbyid(r.id.push_button)) .settext("stopped. tap start!"); } @override protected void onprogressupdate(integer... num_runs) { context context = getapplicationcontext(); charsequence text = "looped " + num_runs[0].tostring() + " times"; int duration = toast.length_short; toast.maketext(context, text + "\nrtt: " + num_runs[1].tostring() + " ms", duration) .show(); ((button) findviewbyid(r.id.push_button)).settext(text + "\ntap stop"); } } /** * stupid function posts hardcoded data hardcoded address */ public void postdata() { // create new httpclient , post header httpclient httpclient = new defaulthttpclient(); // httppost httppost = new httppost("http://129.132.131.73:8880/form"); httppost httppost = new httppost("http://192.168.1.37"); // httppost httppost = new httppost("http://disney.com/"); // httpget httppost = new httpget("http://192.168.1.137:8880/form"); string resp = null; long time_passed = 0; try { // create data post list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2); namevaluepairs.add(new basicnamevaluepair("id", "12345")); namevaluepairs.add(new basicnamevaluepair("stringdata", "xxxxx pvt ltd!")); httppost.setentity(new urlencodedformentity(namevaluepairs)); long ms_before = systemclock.uptimemillis(); // execute http post request httpresponse response = httpclient.execute(httppost); long ms_after = systemclock.uptimemillis(); time_passed = ms_after - ms_before; resp = response.tostring(); } catch (clientprotocolexception e) { log.e(tag, e.tostring()); } catch (ioexception e) { log.e(tag, e.tostring()); } log.i(tag, "rtt inside post-data: " + time_passed); log.i(tag, resp.tostring()); } } please let me know problem .. thanks..
i think httpclient/android code fine. looks http server trying send cookies domain ".127.0.0.1", that's based on ip address instead of domain name.
you need configure http/soap server believe has real name, 1 accessible network, instead of 127.0.0.1 or ip address. might work: 37.1.168.192.in-addr.arpa
after configuring server, might need change java code use domain name (eg. new httppost("http://server-name.local/");).
Comments
Post a Comment