I'm trying to establish a Connection to my Apex-Webservice but it fails every time. My Website is quite Simple:
global class AtlassianService
{
webService static String hello(String Name)
{
return 'Hello '+Name+' ! :D';
}
}
To generate the Client i just the way, which is described here:
java –classpath pathToJAR/wsc-22.jar com.sforce.ws.tools.wsdlc pathToWsdl/WsdlFilename pathToOutputJar/OutputJarFilename
Accessing the Webservice:
SoapConnection soap = Connector.newConnection("[email protected]", "XXXX");
System.out.println(soap.hello("WORLD")); // Invalid Session ( => SessionID is null)
If I use the PartnerConnection to get a valid SessionID everything works fine:
ConnectorConfig config = new ConnectorConfig();
config.setUsername(username);
config.setPassword(password);
config.setAuthEndpoint("https://login.salesforce.com/services/Soap/u/24.0");
new PartnerConnection(config);
SoapConnection soap = Connector.newConnection(null, null);
soap.setSessionHeader(config.getSessionId());
System.out.println(soap.hello("WORLD"));
Does anybody have an idea why the first example fails?