Android communication with asp.net web service -
i'm trying post data asp.net web service seems not know how that. need post data
after json response
{"valid":"success"}
for i'm using function, seems not working purpose. /
/ create new httpclient , post header httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://yoors.somee.com/default.aspx?type=emailinsert"); // http://yoors.somee.com/default.aspx?type=email // insert&username=ben&password=pass&name=alv //&email=ben@yahoo.com&emailenabled=false try { // add data list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2); namevaluepairs.add(new basicnamevaluepair("username",username)); namevaluepairs.add(new basicnamevaluepair("name", name)); namevaluepairs.add(new basicnamevaluepair("password", password)); namevaluepairs.add(new basicnamevaluepair("email", email)); httppost.setentity(new urlencodedformentity(namevaluepairs)); // execute http post request httpresponse response = httpclient.execute(httppost); toast.maketext(signup.this, response.getallheaders().tostring(), toast.length_long).show(); } catch (clientprotocolexception e) { // todo auto-generated catch block } catch (ioexception e) { // todo auto-generated catch block }
so can please guide me how post data web service
try this, i'm not asp.net specialist :/
httpclient httpclient = new defaulthttpclient(); httppost httppost = new httppost("http://yoors.somee.com/default.aspx?type=emailinsert"); try { // add data list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(2); namevaluepairs.add(new basicnamevaluepair("username",username)); namevaluepairs.add(new basicnamevaluepair("name", name)); namevaluepairs.add(new basicnamevaluepair("password", password)); namevaluepairs.add(new basicnamevaluepair("email", email)); httppost.setentity(new urlencodedformentity(namevaluepairs)); // execute http post request httpresponse response = httpclient.execute(httppost); java.util.scanner s = new java.util.scanner(response.getentity().getcontent()).usedelimiter("\\a"); responsestring = s.hasnext() ? s.next() : ""; log.d("debug", responsestring); } catch (clientprotocolexception e) { // todo auto-generated catch block } catch (ioexception e) { // todo auto-generated catch block }
update :
httppost httppost = new httppost("http://yoors.somee.com/default.aspx?type=emailinsert&username=myusername&password=mypass&name=myname&email=myemail@provider.com&emailenabled=false");
works fine, it's not pretty ... think there find !
Comments
Post a Comment