def getSessionId(): username, password, securitytoken = getCredentials() scriptDir = os.path.split(os.path.abspath(__file__))[0] wsdlFile = os.path.join(scriptDir, '..', 'config', 'wsdl.jsp.xml') h = SforceEnterpriseClient(wsdlFile) result = h.login(username, password, securitytoken) header = h.generateHeader('SessionHeader') header.sessionId = result['sessionId'] # print result return header.sessionId
def metaDataLogin(): username, password, securitytoken = getCredentials() h = SforceEnterpriseClient('config/wsdl.jsp.xml') result = h.login(username, password, securitytoken) header = h.generateHeader('SessionHeader') header.sessionId = result['sessionId'] #MetaData WSDL does not have a login call. Use Enterprise WSDL to get SessionID #All future calls need metadata WSDL metaDataClient = SforceEnterpriseClient('config/metadata.xml') metaDataClient.setSessionHeader(header) metaDataClient._setHeaders() metaDataClient._sforce.set_options(location = result.metadataServerUrl) return metaDataClient
def apexAPILogin(): username, password, securitytoken = getCredentials() scriptDir = os.path.split(os.path.abspath(__file__))[0] wsdlFile = os.path.join(scriptDir, '..', 'config', 'wsdl.jsp.xml') h = SforceEnterpriseClient(wsdlFile) result = h.login(username, password, securitytoken) header = h.generateHeader('SessionHeader') header.sessionId = result['sessionId'] #ApexAPI WSDL does not have a login call. Use Enterprise WSDL to get SessionID #All future calls need ApexAPI WSDL apexFile = os.path.join(scriptDir, '..', 'config', 'apex.xml') ApexAPIClient = SforceEnterpriseClient(apexFile) ApexAPIClient.setSessionHeader(header) ApexAPIClient._setHeaders() ApexAPIClient._sforce.set_options(location = getApexAPIUrl(result.serverUrl)) return ApexAPIClient