簡體   English   中英

與HttpWebRequest / HttpClient的Android問題

[英]Android issue with HttpWebRequest/HttpClient

我有asp.net網絡服務。 網絡服務有這樣的網址:
mydomain dot com/service.asmx/getlocation?id=100

我總是低於錯誤。 我嘗試了同步和異步方式。 我甚至嘗試使用Google.com,但我總是得到以下錯誤:

未處理的異常:

 System.Net.WebException: The remote server returned an error: (500) Internal Server Error. 

我的代碼看起來像這樣:

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(new Uri(url));
request.ContentType = "application/json";
request.Timeout = 60000;
request.Method = "GET";

// I get error here 
using (WebResponse response =  request.GetResponse())
{
    // Get a stream representation of the HTTP web response:
    using (Stream stream = response.GetResponseStream())
    {
        // Use this stream to build a JSON document object:
        JsonValue jsonDoc = await Task.Run(() => JsonObject.Load(stream));
        Console.Out.WriteLine("Response: {0}", jsonDoc.ToString());

        // Return the JSON document:
        return jsonDoc;
    }
}

謝謝

編輯

我嘗試了不同的仿真器 - Nexus 7 Lollipop(5.1.0)和Nexus S(4.4.2)

似乎從SOAP服務返回JSON非常棘手,我已經看過這個stackoverflow 問題了

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM