嗨在我的Android應用程序我使用HttpUrlconnection的Web服務。因此,對於任何具有響應401的Web資源請求,它不會給出任何標題字段或響應代碼。並且它顯示內容長度爲-1。它引發異常java.io.IOException: Received authentication challenge is null
。現在我的問題是如何檢查這些條件的響應代碼。需要幫忙。我檢查在休息客戶的請求,但我發現,我的迴應與包頭響應碼來正確地與401等領域也無法獲得響應代碼爲401與HTTP網址連接
我的要求看起來像
String urlString ="http://WWW.ABC.com";
URL url = new URL(urlString);
login_urlConnection = (HttpURLConnection) url.openConnection();
login_urlConnection.setRequestMethod("GET");
int statusCode = login_urlConnection.getResponseCode() // Here I am getting exception I want this status code to check authentication failure
如何來解決這個問題。需要幫忙。謝謝。
我做了與HttpClient相同的調用,然後我能夠得到響應代碼,那麼爲什麼不用HttpUrlConnection。我做錯了什麼需要幫助。
http://android-spirit.blogspot.in/2013/07/cosume-phpget-method-webservice-in.html – Nirmal