I am using HTML Unit to automate a Google Search. I am using the proxy server of my organisation. The following lines of code
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_10, "10.122.3.98", 80);
//set proxy username and password
final DefaultCredentialsProvider credentialsProvider = (DefaultCredentialsProvider) webClient.getCredentialsProvider();
final HtmlPage page = webClient.getPage("http://htmlunit.sourceforge.net");
gives me the error "407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy filter is denied. ) for http://htmlunit.sourceforge.net/". I am supplying my username and password to the defaultCredentialsProvider. I also tried setting System property for proxyPort and ProxyHost as follows
but I guess HTMLUnit uses httpclient internally for authentication which ignores the JVM flags. Can anybody give me some pointers on the solution.
I notice the example uses http://myproxyserver ... so perhaps you need to use http://10.122.3.98 ?
If that doesn't work and you are sure your credentials are correct the try accessing a different website and browser versions too.
I had a lot of trouble trying to get any Java code to get through my former company's ISA server. That was because it demanded NTLM authorization, and the version of Java I was using at the time didn't support that. Have you been able to write your own code to get through the ISA server with the system properties you're using there, putting HTMLUnit aside for now? Because if your code can't do it then it isn't as surprising that HTMLUnit can't do it either.
The other thing that occurred to me was this: Apache HTTPClient, if I recall correctly, does support NTML authorization, but you have to use a CredentialsProvider which knows it should do that. Again that's from memory so I might be wrong about that.
Yes I have been able to get through the proxy to access the internet from my application by setting proxyHost and proxyPort but it doesn't seem to work with HTMLUnit. As of now can't seem to get a workaround this.