I have got a connection to a salesforce webservice by the following method:
- Get an EnterpriseConnection to the auth endpoint and so a session id
- Set the service endpoint to that of the webservice
- Get a SoapConnection to the web service
Now I'm assuming that I have to log out but am having the following issues:
- SoapConnection does not have a logout() method.
- If I try to log out of the EnterpriseConnection using its logout() method, I get the following error message:
com.sforce.ws.SoapFaultException: No operation available for request {urn:enterprise.soap.sforce.com}logout, please check the WSDL for the service
Is there a different way to log out when using webservices than when using just the EnterpriseConnection?
Thanks
EDIT - Addition of code:
public static boolean login() {
boolean success = false;
try {
ConnectorConfig config = new ConnectorConfig();
config.setUsername(username);
config.setPassword(password);
config.setAuthEndpoint(authEndPoint);
config.setProxy(proxyAddress, 8080);
enterpriseConnection = com.sforce.soap.enterprise.Connector.newConnection(config); // EnterpriseConnection object
config.setServiceEndpoint(webserviceEndPoint);
webserviceConnection = Connector.newConnection(config); // SoapConnectionObject
webserviceConnection.setSessionHeader(config.getSessionId());
success = true;
System.out.print("Logged in to webservice- ");
Date startTime = new Date();
System.out.println(DateFormat.getDateTimeInstance().format(startTime));
} catch(ConnectionException e) {
e.printStackTrace();
}
return success;
}
public static void logout() {
try {
enterpriseConnection.logout();
System.out.print("Logged out - ");
Date endTime = new Date();
System.out.println(DateFormat.getDateTimeInstance().format(endTime));
} catch(ConnectionException e) {
e.printStackTrace();
}
}