function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
jmasl7jmasl7 

Java login to salesforce.com via proxy server

Hello,

I'm strying to get started using the salesforce.com API in Java to log on to our salesforce.com org, based on the sample code in the quickstartJava.zip file.

To do this I create a SoapBindingStub object by calling the getSoap() method of a SforceServiceLocator object, call its setTimeout() method to set the timeout to 60 seconds and then call its login() method, passing my salesforce.com user name and password as arguments.

The login() method fails with an exception:

java.net.UnknownHostException: www.salesforce.com

I think this is probably because it is trying to access www.salesforce.com directly rather than going through our proxy server. But how do I specify the proxy settings such as URL and port number? I can't find any documentation or example of doing this.

Any help appreciated.

Regards

John Lewis

jmasl7jmasl7
Ok,
 
I managed to get the answer from here:
 
 
I added two lines of code to my class:
 

Code:

System.setProperty("http.proxyHost", "<name of proxy server here>");
System.setProperty("http.proxyPort", "80");

 

It know logs on successfully.

Before that I tried setting the Proxy Server settings for the JRE in Control Panel (as described here: http://www.java.com/en/download/help/5000020600.xml ) but this didn't work. Anyone know why?

My guess is that the JDK and the JRE are separate (?).

Regards

John

Rick.BanisterRick.Banister
We have found that there is a serious bug in various releases of Axis that will not work with proxy servers, in addition to setting the properties. Axis 1.4 works wonderfully, and you can turn on native compression, but you will need commons-httpclient-3.0-rc4.jar (google it because it's not on the apache web site). The commons-httpclient-3.0-rc2.jar and commons-httpclient-3.0-rc3.jar versions have a fatal bug.
glen sglen s
We were having similar problems with accessing SF behind a proxy, even after setting the correct two proxy parameters in the System object:

   private static final String SYSTEM_HTTP_PROXY_HOST = "http.proxyHost";
   private static final String SYSTEM_HTTP_PROXY_PORT = "http.proxyPort";

Actually, we could get the binding object fine, but when it came to calling the getUserInfo() method, we would time out.

Updating the commons-httpclient-3.0 file from rc1 to rc4 fixed the problem - thanks for the hint!
haashaas

Hi,

 

We are geeting the below error when we try to connect to SFDC using Enterprise WSDL file. This problem is occurring from 14-FEB-2013 onwards. 

 

1. We are able to connect to SFDC as a standslone code i.e not integrated to any application.

2. When we integrate SFDC API code with our app code (which is hosted on weblogic server), we are receiving the error below.

 

<Mar 15, 2013 3:33:11 PM IST> <Warning> <Security> <BEA-090504> <Certificate chain received from usproxy.spansion.com - 10.247.251.124 --> na13-api.salesforce.com failed hostname verification check. Certificate contained *.salesforce.com but check expected na13-api.salesforce.com>

java.lang.Exception: SFDC Portal Connection issue:com.sforce.ws.ConnectionException: Failed to send request to https://na13-api.salesforce.com/services/Soap/c/24.0/00D300000001JgR/0DF30000000PMYt

 

 

Please suggest if you have any clue why this error is popping up.

 

Thanks,

Haas.

SuperfellSuperfell

The server certificate is a wildcard cert, the CN in the cert is *.salesforce.com, your client SSL library is implementing a security check to check that the CN in the certificate is valid for the hostname specified in the URL it connected to, however the library in use doesn't support wildcard certificates, you'll have to get an update/patch from your weblogic folks to support wildcard CN checks.

SuperfellSuperfell

You might find this article on Wildcard certs in Weblogic useful.