abhishekbunty / sfdc-wsc

Automatically exported from code.google.com/p/sfdc-wsc
0 stars 0 forks source link

HTTP/1.1 407 Proxy Authentication Required #50

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Generate jar from any  wsdl (I'm using the SFDC partners one)
2.Configure proxy parameters ( see code example below)
3.Call new PartnerConnection(config)

What is the expected output? What do you see instead?
Successful connection.
Instead I'm getting:
java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 
407 Proxy Authentication Required

What version of the product are you using? On what operating system?
I tested the issue on wsc-22.jar

Please provide any additional information below.

I'm using the following code:

      ConnectorConfig config = new ConnectorConfig();
      config.setUsername(userId);
      config.setPassword(passwd);
      config.setProxy("my_proxy", my_port);
      config.setProxyUsername(my_username);
      config.setProxyPassword(my_password);
      connection = new PartnerConnection(config);

It works fine if I use HTTP instead of HTTPS.

I found a way to make it work using the following code but it shouldn't be this 
way:

    Authenticator.setDefault(new ProxyAuthenticator("my_username", "my_password"));  
    Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("my_proxy", my_port));
    URL url = null;
    try {
        url = new URL("https://mail.google.com");
    } catch (MalformedURLException e) {
        e.printStackTrace();
    }
     HttpURLConnection uc = (HttpURLConnection)url.openConnection(proxy);    
     uc.connect();

      ConnectorConfig config = new ConnectorConfig();
      config.setUsername(userId);
      config.setPassword(passwd);
      config.setProxy("my_proxy", my_port);
      config.setProxyUsername(my_username);
      config.setProxyPassword(my_password);
      connection = new PartnerConnection(config);

Original issue reported on code.google.com by nicolas....@gmail.com on 17 Feb 2012 at 4:31