簡體   English   中英

Web服務請求在android瀏覽器和代碼中不起作用; 但它在PC瀏覽器中工作

[英]Web Service request is not working in android browser and code; but it is working in pc browser

我的PC通過隧道連接到客戶端的網絡,我正在調用客戶端網絡中的Web服務。 這在PC瀏覽器中運行良好,當我嘗試通過Android應用程序訪問它時,我得到ClientProtocolException 我嘗試通過Android瀏覽器點擊Web服務ip我能夠在瀏覽器中看到IIS服務器響應但無法訪問web服務。 不是https網址,只是普通的網址。 它不適用於任何版本的Android模擬器。

代碼:

HttpClient httpclient = new DefaultHttpClient();

HttpGet httpget = new HttpGet(url); 

HttpResponse response;

try {
    response = httpclient.execute(httpget);

    Log.i("Debug",response.getStatusLine().toString());

    HttpEntity entity = response.getEntity();

    if (entity != null) {

        ....
    }


} catch (Exception e) {
   e.printStackTrace();
}

它可能是您的Android設備上可能阻止訪問Web服務的防火牆應用程序(我的知識沒有內置)。

實際上,webservice中沒有響應頭。 這就是我得到例外的原因。 現在我打開一個套接字來獲取響應,但是仍然沒有正確響應頭的請求也不好。

您是否嘗試過設置Web代理?

httpclient.getHostConfiguration().setProxy("ip-address","port")

要么

System.setProperty("http.proxyHost", "ip-address");
System.setPropery("http.proxyPort", "port");

暫無
暫無

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

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