我试图建立一个连接到我的Apex-Webservice,但每次都失败。我Webserce很简单:从Java访问Salesforce Apex Soap Webservice
global class AtlassianService
{
webService static String hello(String Name)
{
return 'Hello '+Name+' ! :D';
}
}
生成客户端我现在的样子,被描述here:
java –classpath pathToJAR/wsc-22.jar com.sforce.ws.tools.wsdlc pathToWsdl/WsdlFilename pathToOutputJar/OutputJarFilename
在访问webservice:
SoapConnection soap = Connector.newConnection("[email protected]", "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"));
有人有一个想法,为什么第一个例子失败?
问候塞巴斯蒂安