I wrote Java code to login to Salesforce and ran this code on a firewalled server. For this, I have to specify the proxy url and proxy port before connecting to Salesforce due to the firewall. However, I'm getting an unknownhostexception error for the proxy url. If I try to login via curl with the proxy settings, I am able to connect. How come there is a problem connecting using Java then? Any help is appreciated.
Java code :
System.setProperty("https.protocols", "TLSv1,TLSv1.1,TLSv1.2");
ConnectorConfig partnerConfig = new ConnectorConfig();
partnerConfig.setUsername(crmUsername);
partnerConfig.setPassword(crmPwd);
partnerConfig.setAuthEndpoint(crmServer + "/services/Soap/u/38.0");
partnerConfig.setProxy(this.proxyUrl, this.proxyPort);
// Creating the connection automatically handles login and stores
// the session in partnerConfig
try {
pConn = new PartnerConnection(partnerConfig);
} catch (ConnectionException e) {
e.printStackTrace();
if (e instanceof ApiFault) {
return ((ApiFault) e).getExceptionMessage();
}
}
// When PartnerConnection is instantiated, a login is implicitly
// executed and, if successful,
// a valid session is stored in the ConnectorConfig instance.
// Use this key to initialize a BulkConnection:
ConnectorConfig config = new ConnectorConfig();
config.setSessionId(partnerConfig.getSessionId());
// The endpoint for the Bulk API service is the same as for the normal
// SOAP uri until the /Soap/ part. From here it's '/async/versionNumber'
String soapEndpoint = partnerConfig.getServiceEndpoint();
String apiVersion = "38.0";
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/")) + "async/" + apiVersion;
config.setRestEndpoint(restEndpoint);
// This should only be false when doing debugging.
config.setCompression(false);
// Set this to true to see HTTP requests and responses on stdout
config.setTraceMessage(true);
config.setProxy(this.proxyUrl, this.proxyPort);
try {
bConn = new BulkConnection(config);
} catch (AsyncApiException e) {
e.printStackTrace();
return e.getMessage();
}