You need to sign in to do that
Don't have an account?
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();
login.setUsername(<username>);
login.setPassword(<password>);
LoginResult lr = binding.login(username, password);
I have added the following jars in my classpath :
jaxrpc.jar
axis.jar
commons-discovery-0.2.jar
commons-logging.jar
wsdl4j-1.5.1.jar
commons-httpclient-3.0-rc4.jar
I'm getting the following error while calling the login function
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.net.UnknownHostException: test.salesforce.com
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.net.UnknownHostException: test.salesforce.com
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown 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.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:153)
at org.apache.axis.components.net.DefaultSocketFactory.create(DefaultSocketFactory.java:120)
at org.apache.axis.transport.http.HTTPSender.getSocket(HTTPSender.java:191)
Can someone please help me how can I resolve the problem...
Thanks!!!
I'm able to connect to the salesforce.com ...
The problem was rectified by adding the ip address of salesforce.com to the HOST file.
Thanks for your Help!!!
All Answers
Your exception is pretty obvious:
faultString: java.net.UnknownHostException: test.salesforce.com
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:
https://cs2.salesforce.com/services/Soap/c/17.0/0DF20000000Tqps
https://www.salesforce.com/services/Soap/c/17.0/0DF20000000Tqps.
To correct this:
Open the SforceServiceStub and replace all http/https connection to above.
No the URL that I'm trying to connect is correct i.e. test.salesforce.com. 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:
{http://xml.apache.org/axis/}stackTrace:java.net.UnknownHostException: test.salesforce.com
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 test.salesforce.com. You either try do what i said ealier or i am out.
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
faultString: java.net.UnknownHostException: cs2.salesforce.com
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 - https://test.salesforce.com/services/Soap/c/17.0
and the enterprise WSDL was retrieved from the location you have mentioned in the post before generating the web service client.
Good!
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?
I'm able to connect to the salesforce.com ...
The problem was rectified by adding the ip address of salesforce.com to the HOST file.
Thanks for your Help!!!