1

I have created my .NET web service and I am trying to fetch data using XMLPullParser from my android app but I am getting HTTP/1.1 500 Internal Server Error

This is a 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 my android code is:

 HttpPost httppost = new HttpPost("http://192.168.141.1/CompanyService.asmx/AddUser");

            try {
                // Add your 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 am I 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
Tanuj Wadhwa
  • 2,025
  • 9
  • 35
  • 57

1 Answers1

0

I found the solution. I had not added the protocols in the web.config. Here is the code

  <webServices>

   <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
    </protocols>

  </webServices>
Tanuj Wadhwa
  • 2,025
  • 9
  • 35
  • 57