You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Christoph Kutzinski <ku...@gmx.de> on 2004/08/31 10:03:05 UTC
Re: httpclient: Behined ISA proxy server and need to reach Internet
site
I haven't used it myself, but a look at the API tells me that you should
probably use the state.setProxyCredentials method.
hth,
Christoph
Ashraf Fouad wrote:
> Dears,
>
> My client machine accesses the Internet through a proxy, I'm writing
> http client program to download page source from the Internet, here is
> my code:
>
>
>
> HttpClient client = new HttpClient();
>
> HostConfiguration hostConfiguration = client.getHostConfiguration();
>
> hostConfiguration.setProxy( "192.168.0.200", "8080" );
>
>
>
> HttpState state = client.getState();
>
> Credentials proxyCredentials = new UsernamePasswordCredentials(
> "username", "password" );
>
>
>
> state.setCredentials( "rayasoftware.com", "192.168.0.200",
> proxyCredentials );
>
>
>
> PostMethod cnnPost = new PostMethod( "http://www.cnn.com" );
>
> cnnPost.setDoAuthentication( true );
>
>
>
> client.executeMethod( cnnPost );
>
> System.out.println( cnnPost.getStatusLine().toString() );
>
> // release any connection resources used by the method
>
> cnnPost.releaseConnection();
>
>
>
>
>
>
>
> I'm getting the following message:
>
>
>
>
> HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires
> authorization to fulfill the request. Access to the Web Proxy service is
> denied. )
>
> [WARN] HttpMethodBase - -No credentials available for the 'null'
> authentication realm at 192.168.0.200
>
> What is wrong with my code.
>
>
>
> Thanks, Best regards
>
> Ashraf Fouad Ayoub
> S/W Team leader
> Raya Software
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org