我試圖建立一個連接到我的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"));
有人有一個想法,爲什麼第一個例子失敗?
問候塞巴斯蒂安