2014-02-09 31 views
0

我在看它是使用Salesforce的SOAP API來創建一個會話,訪問數據的一些代碼:使用OAuth與SforceServiceLocator

SoapBindingStub binding = (SoapBindingStub) new SforceServiceLocator().getSoap(); 
String username; 
String password; 
[...] 
LoginResult result = binding.login(username, password); 
binding._setProperty(SoapBindingStub.ENDPOINT_ADDRESS_PROPERTY,result.getServerUrl()); 
SessionHeader sh = new SessionHeader(); 
sh.setSessionId(result.getSessionId()); 
binding.setHeader(new SforceServiceLocator().getServiceName().getNamespaceURI(), "SessionHeader", sh); 

假設我有一個OAuth訪問令牌和終點,是有沒有一種方法來適應這個沒有用戶名/密碼正確工作?

回答

1

試驗和錯誤的很多後 - 答案似乎是以下

  1. 使用OAuth訪問令牌的SessionID
  2. 的ENDPOINT_ADDRESS_PROPERTY是端點URL 一個SOAP API網址,例如:https://na15.salesforce.com/services/Soap/u/21.0