मैं अपाचे HttpComponents का उपयोग एक वेब सेवा का उपयोग करने के लिए, और डॉन 'पता है कि अनुरोध में उपयोगकर्ता/पासवर्ड सेट करने के लिए, यहाँ मेरी कोड है स्थापित करने के लिए:कैसे उपयोगकर्ता नाम/httpget में पासवर्ड
URI url = new URI(query);
HttpGet httpget = new HttpGet(url);
DefaultHttpClient httpclient = new DefaultHttpClient();
Credentials defaultcreds = new UsernamePasswordCredentials("test", "test");
httpclient.getCredentialsProvider().setCredentials(new AuthScope(HOST, AuthScope.ANY_PORT), defaultcreds);
HttpResponse response = httpclient.execute(httpget);
..
लेकिन फिर भी इसे 401 अनधिकृत त्रुटि मिली।
HTTP/1.1 401 Unauthorized [Server: Apache-Coyote/1.1, Pragma: No-cache, Cache-Control: no-cache, Expires: Wed, 31 Dec 1969 16:00:00 PST, WWW-Authenticate: Basic realm="MemoryRealm", Content-Type: text/html;charset=utf-8, Content-Length: 954, Date: Wed, 04 Apr 2012 02:28:49 GMT]
मुझे यकीन नहीं है कि यह उपयोगकर्ता/पासवर्ड सेट करने का सही तरीका है या नहीं? कोई भी मदद कर सकता है? धन्यवाद।