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
kaiherngkaiherng 

Java Request Error

hi guys,

 

I am a new in salesforce and I am trying to access salesforce via java codes. Unfortunately, I am getting this error:

 

com.sforce.ws.ConnectionException: Failed to send request to https://login.salesforce.com/services/Soap/u/24.0
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:113)
    at com.sforce.soap.partner.PartnerConnection.login(PartnerConnection.java:1)
    at com.sforce.soap.partner.PartnerConnection.<init>(PartnerConnection.java:1)
    at com.sforce.soap.partner.Connector.newConnection(Connector.java:1)
    at SalesforceTestQuery.main(SalesforceTestQuery.java:20)
Caused by: java.net.UnknownHostException: login.salesforce.com
    at java.net.PlainSocketImpl.connect(Unknown Source)
    at java.net.SocksSocketImpl.connect(Unknown Source)
    at java.net.Socket.connect(Unknown Source)
    at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
    at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(Unknown Source)
    at sun.net.NetworkClient.doConnect(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.http.HttpClient.openServer(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.<init>(Unknown Source)
    at sun.net.www.protocol.https.HttpsClient.New(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
    at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(Unknown Source)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(Unknown Source)
    at com.sforce.ws.transport.JdkHttpTransport.connectLocal(JdkHttpTransport.java:98)
    at com.sforce.ws.transport.JdkHttpTransport.connect(JdkHttpTransport.java:83)
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:99)
    ... 4 more

 

and I am following the steps which show on this web site http://blog.jeffdouglas.com/2010/05/17/java-command-line-app-using-the-salesforce-wsc/. I have tried to turn off or on my firewall but I am getting the same result as well. I hope somebody from salesforce can help me to solve this issues.

 

Thank you

Kai Herng

Best Answer chosen by Admin (Salesforce Developers) 
AlexandruAlexandru

Hi,

 

To set the proxy you have to do it in the config object by setting the Proxy properties as shown here:

ConnectorConfig config = new ConnectorConfig();

config.setProxy(host, port);

config.setProxyPassword(proxyPassword); -- if there is a proxy password, otherwise don't set it.

 

 

 

All the best,

Alexandru

 

All Answers

SuperfellSuperfell

Almost certainly your network requires you to connect via a proxy, and you need to configure your code to use the proxy.

kaiherngkaiherng

Hi Simon,

 

Thank you for your reply, may I know help to configure the poxy like what you are saying?

Can you show me some steps?

 

Thank you

Kai Herng

AlexandruAlexandru

Hi,

 

To set the proxy you have to do it in the config object by setting the Proxy properties as shown here:

ConnectorConfig config = new ConnectorConfig();

config.setProxy(host, port);

config.setProxyPassword(proxyPassword); -- if there is a proxy password, otherwise don't set it.

 

 

 

All the best,

Alexandru

 

This was selected as the best answer