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

Problem while connecting to Enterprise API using java (Axis)

I'm trying to connect the salesforce API by creating a web service client in java (Axis).


I'm behind proxy and I have set the property that is required for connecting a web service for proxy

The code that I'm using is 


            binding = (SoapBindingStub) new SforceServiceLocator().getSoap();

            binding._setProperty("http.proxySet", "true");
            binding._setProperty("http.proxyHost", <proxy-host>);
            binding._setProperty("http.proxyPort", <proxy-port>);



 I'm calling the login function given below


            Login login = new Login();
            LoginResult lr = binding.login(username, password);


I have added the following jars in my classpath :



I'm getting the following error while calling the login function 


 faultCode: {}Server.userException
    at Source)
    at Source)
    at Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.apache.axis.transport.http.HTTPSender.getSocket(


Can someone please help me how can I resolve the problem...



Best Answer chosen by Admin (Salesforce Developers) 

I'm able to connect to the ...


The problem was rectified by adding the ip address of to the HOST file.



Thanks for your Help!!!

All Answers


Your exception is pretty obvious:




You are definitely trying to connect to an unknown host which in this case is the salesforce sandbox/production, which ever enviroment you're trying to connect to.


I think sandbox should be:


and production should b:




To correct this:

Open the SforceServiceStub and replace all http/https connection to above.



Message Edited by Losintikfos on 11-12-2009 03:16 AM

No the URL that I'm trying to connect is correct i.e. I'm trying to connect to sandbox.


Same URL is in WSDL, I also tried with the URL that you mentioned with the same problem


Can someone suggest what may be the problem


I can see what you're saying - because the URL is the WSDL you're refusing to debug hence listening to advice. The exception you posted says:



 Do you know what it means? it means the SOAP request document contains the wrong URL hence the one in the WSDL, which in your case is You either try do what i said ealier or i am out.



Message Edited by Losintikfos on 11-12-2009 04:33 AM

First of all thanks for your help!

I forgot to mentioned in my previous post that I had modified the end point URL to the sandbox URL mentioned by you but got the same error message


 The error message was



I had created the web service client in eclipse and the soap address was modified in SforceServiceLocator class to the URL you had mentioned.

Please advice.


Best way to findout the URL is if you login to salesforce sandbox - click on Setup -> Develop ->API ->enterprise wsdl. Scroll to the bottom of the WSDL and you should see correct URL. If this is different from what you have currently, then i suggest you regenerate your stubs, and then try invoke the service again.


The URL in WSDL is - 


and the enterprise WSDL was retrieved from the location you have mentioned in the post before generating the web service client.




Now we can limit it down to the proxy. If you hit the URL you've just supplied in your browser address line, what message do you get?

It would appear that your request are not using the proxy, hence the error, you should double check that the property names are correct (you might need to set the system level settings, rather than just on the stub, IIRC, this differs between the regular axis http client and the commons-http based client)
oh, and is the correct host for sandbox logins.

I'm able to connect to the ...


The problem was rectified by adding the ip address of to the HOST file.



Thanks for your Help!!!

This was selected as the best answer