2014-03-06 84 views
1

我創建了我的.NET Web服務,我想從我的Android應用獲取使用XMLPullParser數據,但我得到HTTP/1.1 500 Internal Server ErrorAndroid應用程序調用.NET Web服務

這是一個樣的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 

和我的Android代碼:

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(); 
      } 

什麼我錯在這裏做什麼?

編輯: 日誌文件包含:

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 
+0

此錯誤只能通過修復Web服務器軟件來解決。這不是客戶端問題。 Web服務器站點的運營商應該定位和分析日誌,以提供有關錯誤的更多信息。 –

+0

我更新了我的答案。檢查日誌文件錯誤。 –

+0

[什麼是Apache-HttpClient/UNAVAILABLE錯誤(Android,Google App Engine)?](http://stackoverflow.com/questions/17025296/what-is-apache-httpclient-unavailable-error-android-google -app-engine) –

回答

0

我找到了解決辦法。我沒有在web.config中添加這些協議。以下是代碼

<webServices> 

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

    </webServices> 
相關問題