我试图连接我的Apex-Web服务,但每次都失败。我的Web服务非常简单:
global class AtlassianService
{
webService static String hello(String Name)
{
return 'Hello '+Name+' ! :D';
}
}
要生成客户端,我只需按照这里描述的方式即可:
java –classpath pathToJAR/wsc-22.jar com.sforce.ws.tools.wsdlc pathToWsdl/WsdlFilename pathToOutputJar/OutputJarFilename
访问 Web 服务:
SoapConnection soap = Connector.newConnection("mail@XXXXXX.com", "XXXX");
System.out.println(soap.hello("WORLD")); // Invalid Session ( => SessionID is null)
如果我使用PartnerConnection获取有效的SessionID,一切都很正常:
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"));
有没有人知道为什么第一个例子失败了呢?
问候Sebastian