• umesh pandey
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies

Downloaded enterprise wsdl from salesforce.


Step 1: Create enterprise.jar using enterprise wsdl

java -Dpackage -classpath force-wsc-32.0.0.jar;tools.jar;antlr-runtime-3.5.jar;ST4-4.0.7.jar com.sforce.ws.tools.wsdlc enterprise.wsdl enterprise.jar

Step 2: Added enterprise.jar and force-wsc-32.0.0.jar to java project class path.
Step 3: Create stub using enterprise.wsdl (com.sforce.soap.enterprise , com.sforce.soap.enterprise.fault , com.sforce.soap.enterprise.sobject )

Step 4: Created package wsc and a class


package wsc;

import com.sforce.soap.enterprise.Connector;
import com.sforce.soap.enterprise.EnterpriseConnection;
import com.sforce.soap.enterprise.GetUserInfoResult;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;

public class Main1 {
static final String USERNAME = "ux.p@gmail.com";
static final String PASSWORD = "Password with security token";
static EnterpriseConnection connection;

public static void main(String[] args) {

  ConnectorConfig config = new ConnectorConfig();
  config.setUsername(USERNAME);
  config.setPassword(PASSWORD);
  config.setTraceMessage(true);

  try {
   connection = Connector.newConnection(config);

   // display some current settings
   System.out.println("Auth EndPoint: "+config.getAuthEndpoint());
   System.out.println("Service EndPoint: "+config.getServiceEndpoint());
   System.out.println("Username: "+config.getUsername());
   System.out.println("SessionId: "+config.getSessionId());
  }
  catch (ConnectionException e1) { e1.printStackTrace();
  }
}

}


Step 5: When running this simple class getting below error

Exception in thread "main" java.lang.ClassCastException: com.sforce.soap.enterprise.LoginResult cannot be cast to com.sforce.ws.bind.XMLizable
at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:650)
at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:527)
at com.sforce.soap.enterprise.LoginResponse_element.loadFields(LoginResponse_element.java:62)
at com.sforce.soap.enterprise.LoginResponse_element.load(LoginResponse_element.java:54)
at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:651)
at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:527)
at com.sforce.ws.transport.SoapConnection.bind(SoapConnection.java:174)
at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:148)
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:99)
at com.sforce.soap.enterprise.EnterpriseConnection.login(EnterpriseConnection.java:568)
at com.sforce.soap.enterprise.EnterpriseConnection.<init>(EnterpriseConnection.java:364)
at com.sforce.soap.enterprise.Connector.newConnection(Connector.java:27)
at wsc.Main1.main(Main1.java:22)


Appreciate if anyone let me know what changes do i need to make it running.

Step 1: Create enterprise.jar using enterprise wsdl

java -Dpackage -classpath force-wsc-32.0.0.jar;tools.jar;antlr-runtime-3.5.jar;ST4-4.0.7.jar com.sforce.ws.tools.wsdlc enterprise.wsdl enterprise.jar

Step 2: Added enterprise.jar and force-wsc-32.0.0.jar to java project class path.
Step 3: Create stub using enterprise.wsdl (com.sforce.soap.enterprise , com.sforce.soap.enterprise.fault , com.sforce.soap.enterprise.sobject )

Step 4: Created package wsc and a class


package wsc;

import com.sforce.soap.enterprise.Connector;
import com.sforce.soap.enterprise.EnterpriseConnection;
import com.sforce.soap.enterprise.GetUserInfoResult;
import com.sforce.ws.ConnectionException;
import com.sforce.ws.ConnectorConfig;

public class Main1 {
static final String USERNAME = "ux.p@gmail.com";
static final String PASSWORD = "Password with security token";
static EnterpriseConnection connection;

public static void main(String[] args) {

  ConnectorConfig config = new ConnectorConfig();
  config.setUsername(USERNAME);
  config.setPassword(PASSWORD);
  config.setTraceMessage(true);

  try {
   connection = Connector.newConnection(config);

   // display some current settings
   System.out.println("Auth EndPoint: "+config.getAuthEndpoint());
   System.out.println("Service EndPoint: "+config.getServiceEndpoint());
   System.out.println("Username: "+config.getUsername());
   System.out.println("SessionId: "+config.getSessionId());
  }
  catch (ConnectionException e1) { e1.printStackTrace();
  }
}

}


Step 5: When running this simple class getting below error

Exception in thread "main" java.lang.ClassCastException: com.sforce.soap.enterprise.LoginResult cannot be cast to com.sforce.ws.bind.XMLizable
at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:650)
at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:527)
at com.sforce.soap.enterprise.LoginResponse_element.loadFields(LoginResponse_element.java:62)
at com.sforce.soap.enterprise.LoginResponse_element.load(LoginResponse_element.java:54)
at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:651)
at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:527)
at com.sforce.ws.transport.SoapConnection.bind(SoapConnection.java:174)
at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:148)
at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:99)
at com.sforce.soap.enterprise.EnterpriseConnection.login(EnterpriseConnection.java:568)
at com.sforce.soap.enterprise.EnterpriseConnection.<init>(EnterpriseConnection.java:364)
at com.sforce.soap.enterprise.Connector.newConnection(Connector.java:27)
at wsc.Main1.main(Main1.java:22)


Appreciate if anyone let me know what changes do i need to make it running.