You need to sign in to do that
Don't have an account?

ConnectionException
Ok. I give up... What am I doing wrong?
package comEJMSandbox; import com.sforce.soap.enterprise.EnterpriseConnection; import com.sforce.soap.enterprise.GetUserInfoResult; import com.sforce.ws.*; public class testLogin { public static void main(String[] args) { ConnectorConfig config = new ConnectorConfig(); config.setUsername("admin@salesforce.com"); config.setPassword("password"); config.setAuthEndpoint("https://login.salesforce.com/services/Soap/c/20.0"); EnterpriseConnection connection; try { connection = new EnterpriseConnection(config); GetUserInfoResult userInfo = connection.getUserInfo(); System.out.println("\nLogging in ...\n"); System.out.println("UserID: " + userInfo.getUserId()); System.out.println("User Full Name: " + userInfo.getUserFullName()); System.out.println("User Email: " + userInfo.getUserEmail()); System.out.println(); System.out.println("SessionID: " + config.getSessionId()); System.out.println("Auth End Point: " + config.getAuthEndpoint()); System.out.println("Service End Point: " + config.getServiceEndpoint()); System.out.println(); } catch (ConnectionException ce) { ce.printStackTrace(); } } }
I get this error
com.sforce.ws.ConnectionException: Unexpected element. Parser was expecting element 'urn:enterprise.soap.sforce.com:orgAttachmentFileSizeLimit' but found 'urn:enterprise.soap.sforce.com:orgDefaultCurrencyIsoCode' at com.sforce.ws.bind.TypeMapper.verifyTag(TypeMapper.java:386) at com.sforce.ws.bind.TypeMapper.verifyElement(TypeMapper.java:415) at com.sforce.soap.enterprise.GetUserInfoResult.loadFields(GetUserInfoResult.java:1) at com.sforce.soap.enterprise.GetUserInfoResult.load(GetUserInfoResult.java:1) at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:628) at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:504) at com.sforce.soap.enterprise.LoginResult.loadFields(LoginResult.java:1) at com.sforce.soap.enterprise.LoginResult.load(LoginResult.java:1) at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:628) at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:504) at com.sforce.soap.enterprise.LoginResponse_element.loadFields(LoginResponse_element.java:1) at com.sforce.soap.enterprise.LoginResponse_element.load(LoginResponse_element.java:1) at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:628) at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:504) at com.sforce.ws.transport.SoapConnection.bind(SoapConnection.java:170) at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:144) at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:98) at com.sforce.soap.enterprise.EnterpriseConnection.login(EnterpriseConnection.java:1) at com.sforce.soap.enterprise.EnterpriseConnection.<init>(EnterpriseConnection.java:1) at comEJMSandbox.testLogin.main(testLogin.java:22)
You can use any version of WSC, whats important is that the endpoint you connect to is the same version as the version of the WSDL you used to generate your client code.
All Answers
You are using one version of the WSDL, but sending your request to a different version, make sure you're setting the correct authEndpoint URL for the version of the WSDL you're using.
That is what I thought, but not sure if it's the case. WSDL is from EE sandbox and the end point is for sandbox... both end point and wsdl are for enterprise connection... Does version matter? the only WSC on wiki is version 20, but WSDL is generated for v 21... Does this matter? if it does, how can I get the WSC-21.jar?
Yes version matters.
Is there a way to genereate my own WSC-21.jar then? I only see wsc-20.jar on google code site...
You can use any version of WSC, whats important is that the endpoint you connect to is the same version as the version of the WSDL you used to generate your client code.
right on! it worked.
Thank you.
I don't think your code even gets through login portion of it. Can you see login attempts in SFDC when you run code?
I have tried calling the webservice again with new security token and getting the following error now:
java.lang.NoClassDefFoundError - you are missing one or more jars from your runtime classpath.
I have generated the jar files again and this time the code worked.
Thanks for your great help.
I got the seesion id and thus connection is established. The code I used for setting connection is:
I have webservice named "Integration" in salesforce. In the Integration class, there is a method called "import" which will do all the processing, so I need to call the "import" method. I have generated the jar files for "Integration" wsdl.
How should I call the import method through java code and run the webservice?
Plz help.