Question

I'm trying to connect to salesforce from a java application. I was earlier getting a login error as follows which was resolved by setting the appropriate proxy settings.

com.sforce.ws.ConnectionException: Failed to send request to https://login.salesforce.com/services/Soap/c/29.0

Now, I'm getting the following error:

com.sforce.ws.ConnectionException: Failed to send request to https://ap1.salesforce.com/services/Soap/m/29.0/00D90000000q0ZR
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:121)
at com.sforce.soap.metadata.MetadataConnection.describeMetadata(MetadataConnection.java:281)
at integration.IntegrationClass.describeMetadata(IntegrationClass.java:80)
at integration.IntegrationClass.main(IntegrationClass.java:26)
Caused by: java.net.ConnectException: Connection refused: connect

Any ideas on how to resolve this error? Thanks!

UPDATE: I tried the code at my home (free from the restrictions of the office firewalls et al :) ) and found that the code ran successfully. Any ideas about changes that I should make to do the same at the company. As I already said, I added the config.setProxy(host, port) which allowed me to successfully log in, but not access the application. I have also enabled proxy from eclipse using Preferences -> General -> Network Connections. What am I missing?

Thanks a lot for your help. Cheers!

Was it helpful?

Solution

Ok, I got the solution and it's kinda silly, but since I didn't spot it anywhere else inspite of seeing similar questions, I'm going to post the solution.

The ConnectorConfig config = new ConnectorConfig(); is used multiple times; in my case, it is first used to login using new EnterpriseConnection(config)).login(username, password); and next to obtain a metadata connection using new MetadataConnection(config);. Since I'm creating 2 ConnectorConfig objects, I would need to use the setProxy method on both, which I...forgot. Hope this solution helps other people having the same problem.

Cheers!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top