Android app call to .NET web service -
i have created .net web service , trying fetch data using xmlpullparser android app getting http/1.1 500 internal server error
this sample httprequest:
post /companyservice.asmx/adduser http/1.1 host: 192.168.141.1 content-type: application/x-www-form-urlencoded content-length: length username=string&password=string&phonenumber=string&emailid=string&position=string&address=string
and android code is:
httppost httppost = new httppost("http://192.168.141.1/companyservice.asmx/adduser"); try { // add data list<namevaluepair> namevaluepairs = new arraylist<namevaluepair>(6); namevaluepairs.add(new basicnamevaluepair("username", "aaa")); namevaluepairs.add(new basicnamevaluepair("password", "a")); namevaluepairs.add(new basicnamevaluepair("phonenumber", "a")); namevaluepairs.add(new basicnamevaluepair("emailid", "a")); namevaluepairs.add(new basicnamevaluepair("position", "a")); namevaluepairs.add(new basicnamevaluepair("address", "a")); httppost.setentity(new urlencodedformentity(namevaluepairs)); // execute http post request httpresponse response = httpclient.execute(httppost); } catch (clientprotocolexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); }
what doing wrong here?
edit: log file contains:
2014-03-06 07:24:19 192.168.141.1 post /companyservice.asmx/adduser - 80 - 192.168.141.101 apache-httpclient/unavailable+(java+1.4) - 500 0 0 10
i found solution. had not added protocols in web.config. here code
<webservices> <protocols> <add name="httpget"/> <add name="httppost"/> </protocols> </webservices>
Comments
Post a Comment