Android communication with asp.net web service -


i'm trying post data asp.net web service seems not know how that. need post data

eg. http://yoors.somee.com/default.aspx?type=emailinsert&username=myusername&password=mypass&name=myname&email=myemail@provider.com&emailenabled=false

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

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -