I try to establish a connection with my Apex-Webservice, but it fails every time. My web service is pretty simple:
global class AtlassianService { webService static String hello(String Name) { return 'Hello '+Name+' ! :D'; } }
To generate Client, I am as described here :
java –classpath pathToJAR/wsc-22.jar com.sforce.ws.tools.wsdlc pathToWsdl/WsdlFilename pathToOutputJar/OutputJarFilename
Access to Webservice:
SoapConnection soap = Connector.newConnection(" mail@XXXXXX.com ", "XXXX"); System.out.println(soap.hello("WORLD")); // Invalid Session ( => SessionID is null)
If I use 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 anyone have an idea why the first example fails?
Greetings of Sebastian
source share