Domanda

sto usando HttpClient 4.0 per ottenere qualche XML dall'host remoto. Quando uso URL, ad esempio https: // utente: pwd@www.somesite.com esso funziona bene nel browser, ma non riesce nel HttpClient con questo stacktrace (segue). Eventuali suggerimenti? Sto usando SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER durante l'impostazione ThreadSafeClientConnManager per gestire le richieste HTTPS

Il codice (parziale):

final HttpGet get= new HttpGet(url);
final HttpResponse response = this.client.execute(get);
return new BasicResponseHandler().handleResponse(response);

Stacktrace:

01-05 22:34:03.783: ERROR/SearchResults(11565): 
    Failed to process request to URL: 
    https://user:pwd@www.somesite.com/products/foo/meta/xml_proper_encoding.jsp?version=1
01-05 22:34:03.783: ERROR/SearchResults(11565): 
    org.apache.http.client.HttpResponseException: Unauthorized 
È stato utile?

Soluzione

Passate UsernamePasswordCredentials come in questo esempio , non nella URL.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top