本文整理汇总了Java中com.sforce.ws.ConnectorConfig.setSessionId方法的典型用法代码示例。如果您正苦于以下问题:Java ConnectorConfig.setSessionId方法的具体用法?Java ConnectorConfig.setSessionId怎么用?Java ConnectorConfig.setSessionId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sforce.ws.ConnectorConfig
的用法示例。
在下文中一共展示了ConnectorConfig.setSessionId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createBulkConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private BulkConnection createBulkConnection(ConnectorConfig partnerConfig)
throws AsyncApiException {
ConnectorConfig config = new ConnectorConfig();
config.setSessionId(partnerConfig.getSessionId());
String soapEndpoint = partnerConfig.getServiceEndpoint();
String restEndpoint = soapEndpoint.substring(
0, soapEndpoint.indexOf("Soap/")) + "async/" + API_VERSION;
config.setRestEndpoint(restEndpoint);
config.setCompression(isCompression);
config.setTraceMessage(false);
return new BulkConnection(config);
}
示例2: login
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public void login(ConnectorConfig connect) {
switch (connection.oauth2FlowType.getValue()) {
case JWT_Flow:
JsonNode accessToken = new SalesforceJwtConnection(connection.oauth2JwtFlow, url).getAccessToken();
connect.setServiceEndpoint(getSOAPEndpoint(accessToken.get(Oauth2JwtClient.KEY_ID).asText(), //
accessToken.get(Oauth2JwtClient.KEY_TOKEN_TYPE).asText(), //
accessToken.get(Oauth2JwtClient.KEY_ACCESS_TOKEN).asText(), //
apiVersion));
connect.setSessionId(accessToken.get(Oauth2JwtClient.KEY_ACCESS_TOKEN).asText());
break;
case Implicit_Flow:
SalesforceOAuthAccessTokenResponse token = new SalesforceImplicitConnection(connection.oauth, url).getToken();
connect.setServiceEndpoint(getSOAPEndpoint(token.getID(), token.getTokenType(), token.getAccessToken(), apiVersion));
connect.setSessionId(token.getAccessToken());
break;
default:
break;
}
}
示例3: initializeConnectorConfig
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private void initializeConnectorConfig(ConnectorConfig connectorConfig) {
if (forceProject == null) {
throw new IllegalArgumentException("Object containing connection details cannot be null");
}
connectorConfig.setCompression(true);
if (Utils.isEmpty(forceProject.getSessionId())) {
connectorConfig.setManualLogin(true);
connectorConfig.setUsername(forceProject.getUserName());
connectorConfig.setPassword(forceProject.getPassword() + forceProject.getToken());
} else {
connectorConfig.setManualLogin(false);
connectorConfig.setSessionId(forceProject.getSessionId());
}
connectorConfig.setReadTimeout(forceProject.getReadTimeoutMillis());
connectorConfig.setConnectionTimeout(forceProject.getReadTimeoutMillis());
if (Utils.isNotEmpty(forceProject.getEndpointServer())) {
final String endpointUrl =
salesforceEndpoints.getFullEndpointUrl(forceProject.getEndpointServer(),
forceProject.isHttpsProtocol());
connectorConfig.setAuthEndpoint(endpointUrl);
connectorConfig.setServiceEndpoint(connectorConfig.getAuthEndpoint());
}
}
示例4: login
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public void login(@NotNull InstanceCredentials instanceCredentials, boolean traceMessages) {
clearAllConnections();
ConnectorConfig loginConfig = createConnectorConfig(instanceCredentials, traceMessages);
try {
// Create the Enterprise Connection which will log into Salesforce
enterpriseConnection = Connector.newConnection(loginConfig);
// Setup the Metadata Connection which will use the session Id from the Enterprise Connection
ConnectorConfig metadataConfig = createConnectorConfig(instanceCredentials, traceMessages);
metadataConfig.setSessionId(enterpriseConnection.getConfig().getSessionId());
metadataConfig.setServiceEndpoint(enterpriseConnection.getConfig().getServiceEndpoint().replace("services/Soap/c", "services/Soap/m"));
metadataConnection = com.sforce.soap.metadata.Connector.newConnection(metadataConfig);
// Setup the Apex Connection which will use the session Id from the Enterprise Connection
ConnectorConfig apexConfig = createConnectorConfig(instanceCredentials, traceMessages);
apexConfig.setSessionId(enterpriseConnection.getConfig().getSessionId());
apexConfig.setServiceEndpoint(enterpriseConnection.getConfig().getServiceEndpoint().replace("services/Soap/c", "services/Soap/s"));
apexConnection = com.sforce.soap.apex.Connector.newConnection(apexConfig);
} catch (ConnectionException e) {
logger.error("Unable to login to Salesforce", e);
}
}
示例5: getConnectorConfig
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private static ConnectorConfig getConnectorConfig(String serverUrl, String sessionId)
{
ConnectorConfig config = new ConnectorConfig();
config.setServiceEndpoint(serverUrl);
config.setSessionId(sessionId);
config.setCompression(true);
return config;
}
示例6: createBulkConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private void createBulkConnection() throws AsyncApiException
{
// check if connection has already been created
if (getBulkConnection() != null)
{
// connection already created
return;
}
// print the info we will use to build the connection
Utils.log("SalesforceService::createBulkConnection() entered" + "\n\tSession ID: " + getSessionId()
+ "\n\tBulk Endpoint: " + getBulkEndpoint());
// create partner connector configuration
ConnectorConfig bulkConfig = getConnectorConfig(getServerUrl(), getSessionId());
bulkConfig.setSessionId(getSessionId());
bulkConfig.setRestEndpoint(getBulkEndpoint());
bulkConfig.setCompression(true);
// check if tracing is enabled
if (getenv(SALESFORCE_TRACE_BULK) != null && getenv(SALESFORCE_TRACE_BULK).equalsIgnoreCase("1"))
{
// set this to true to see HTTP requests and responses on stdout
bulkConfig.setTraceMessage(true);
bulkConfig.setPrettyPrintXml(true);
// this should only be false when doing debugging.
bulkConfig.setCompression(false);
}
setBulkConnection(new BulkConnection(bulkConfig));
}
示例7: createMetadataConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private static MetadataConnection createMetadataConnection(
final LoginResult loginResult) throws ConnectionException {
final ConnectorConfig config = new ConnectorConfig();
config.setServiceEndpoint(loginResult.getMetadataServerUrl());
config.setSessionId(loginResult.getSessionId());
return new MetadataConnection(config);
}
示例8: createMetadataConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
private static MetadataConnection createMetadataConnection(final LoginResult loginResult)
throws ConnectionException {
final ConnectorConfig config = new ConnectorConfig();
config.setServiceEndpoint(loginResult.getMetadataServerUrl());
config.setSessionId(loginResult.getSessionId());
final MetadataConnection metadataConnection = new MetadataConnection(config);
return metadataConnection;
}
示例9: getMetadataConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public static MetadataConnection getMetadataConnection(PartnerConnection pc, SalesforceConfig config) throws ConnectionException {
LoginResult lr = pc.login(config.getUsername(), config.getPassword());
ConnectorConfig cc = new ConnectorConfig();
cc.setUsername(config.getUsername());
cc.setPassword(config.getPassword());
cc.setSessionId(lr.getSessionId());
cc.setServiceEndpoint(lr.getMetadataServerUrl());
cc.setManualLogin(false);
MetadataConnection connection = com.sforce.soap.metadata.Connector.newConnection(cc);
return connection;
}
示例10: getToolingConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public static SoapConnection getToolingConnection(PartnerConnection pc, SalesforceConfig config) throws ConnectionException {
LoginResult lr = pc.login(config.getUsername(), config.getPassword());
ConnectorConfig toolingConfig = new ConnectorConfig();
toolingConfig.setSessionId(pc.getSessionHeader().getSessionId());
toolingConfig.setServiceEndpoint(lr.getServerUrl().replace("Soap/u/", "Soap/s/"));
toolingConfig.setManualLogin(false);
SoapConnection soapConnection = Connector.newConnection(toolingConfig);
return soapConnection;
}
示例11: getBulkConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public static BulkConnection getBulkConnection(
ConnectorConfig partnerConfig,
ForceConfigBean conf
) throws ConnectionException, AsyncApiException, StageException, URISyntaxException {
// When PartnerConnection is instantiated, a login is implicitly
// executed and, if successful,
// a valid session is stored in the ConnectorConfig instance.
// Use this key to initialize a BulkConnection:
ConnectorConfig config = conf.mutualAuth.useMutualAuth
? new MutualAuthConnectorConfig(conf.mutualAuth.getUnderlyingConfig().getSslContext())
: new ConnectorConfig();
config.setSessionId(partnerConfig.getSessionId());
// The endpoint for the Bulk API service is the same as for the normal
// SOAP uri until the /Soap/ part. From here it's '/async/versionNumber'
String soapEndpoint = partnerConfig.getServiceEndpoint();
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/"))
+ "async/" + conf.apiVersion;
config.setRestEndpoint(restEndpoint);
config.setCompression(conf.useCompression);
config.setTraceMessage(conf.showTrace);
config.setSessionRenewer(partnerConfig.getSessionRenewer());
setProxyConfig(conf, config);
BulkConnection bulkConnection = new BulkConnection(config);
if (conf.mutualAuth.useMutualAuth) {
setupMutualAuthBulk(config, conf.mutualAuth);
}
return bulkConnection;
}
示例12: createConfig
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
public ConnectorConfig createConfig() {
// When PartnerConnection is instantiated, a login is implicitly
// executed and, if successful,
// a valid session is stored in the ConnectorConfig instance.
// Use this key to initialize a BulkConnection:
CommonConnectorConfig commonConnConfig = new CommonConnectorConfig();
ConnectorConfig config = commonConnConfig.createConfig();
String sessionId = ConnectionHandler.getConnectionHandlerInstance().getSessionIdFromConnectorConfig();
config.setSessionId(sessionId);
String restEndPoint = CommandLineArguments.getOrgUrl() + "/services/async/"
+ ConnectionHandler.SUPPORTED_VERSION;
config.setRestEndpoint(restEndPoint);
config.setTraceMessage(false);
return config;
}
示例13: connectBulk
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
protected BulkConnection connectBulk(ConnectorConfig config) throws ComponentException {
/*
* When PartnerConnection is instantiated, a login is implicitly executed and, if successful, a valid session is
* stored in the ConnectorConfig instance. Use this key to initialize a BulkConnection:
*/
ConnectorConfig bulkConfig = new ConnectorConfig();
bulkConfig.setSessionId(config.getSessionId());
// For session renew
bulkConfig.setSessionRenewer(config.getSessionRenewer());
bulkConfig.setUsername(config.getUsername());
bulkConfig.setPassword(config.getPassword());
/*
* The endpoint for the Bulk API service is the same as for the normal SOAP uri until the /Soap/ part. From here
* it's '/async/versionNumber'
*/
String soapEndpoint = config.getServiceEndpoint();
// set it by a default property file
String api_version = "34.0";
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/")) + "async/" + api_version;
bulkConfig.setRestEndpoint(restEndpoint);
bulkConfig.setCompression(true);// This should only be false when doing debugging.
bulkConfig.setTraceMessage(false);
bulkConfig.setValidateSchema(false);
try {
return new BulkConnection(bulkConfig);
} catch (AsyncApiException e) {
throw new ComponentException(e);
}
}
示例14: connectBulk
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
protected BulkConnection connectBulk(ConnectorConfig config) throws ComponentException {
final SalesforceConnectionProperties connProps = getConnectionProperties();
/*
* When PartnerConnection is instantiated, a login is implicitly executed and, if successful, a valid session id is
* stored in the ConnectorConfig instance. Use this key to initialize a BulkConnection:
*/
ConnectorConfig bulkConfig = new ConnectorConfig();
setProxy(bulkConfig);
bulkConfig.setSessionId(config.getSessionId());
// For session renew
bulkConfig.setSessionRenewer(config.getSessionRenewer());
bulkConfig.setUsername(config.getUsername());
bulkConfig.setPassword(config.getPassword());
/*
* The endpoint for the Bulk API service is the same as for the normal SOAP uri until the /Soap/ part. From here
* it's '/async/versionNumber'
*/
String soapEndpoint = config.getServiceEndpoint();
// Service endpoint should be like this:
// https://ap1.salesforce.com/services/Soap/u/37.0/00D90000000eSq3
String apiVersion = soapEndpoint.substring(soapEndpoint.lastIndexOf("/services/Soap/u/") + 17);
apiVersion = apiVersion.substring(0, apiVersion.indexOf("/"));
String restEndpoint = soapEndpoint.substring(0, soapEndpoint.indexOf("Soap/")) + "async/" + apiVersion;
bulkConfig.setRestEndpoint(restEndpoint);
// This should only be false when doing debugging.
bulkConfig.setCompression(connProps.needCompression.getValue());
bulkConfig.setTraceMessage(connProps.httpTraceMessage.getValue());
bulkConfig.setValidateSchema(false);
try {
return new BulkConnection(bulkConfig);
} catch (AsyncApiException e) {
throw new ComponentException(e);
}
}
示例15: doConnection
import com.sforce.ws.ConnectorConfig; //导入方法依赖的package包/类
/**
* Create a connection with specified connector configuration
*
* @param config connector configuration with endpoint/userId/password
* @param openNewSession whether need to create new session
* @return PartnerConnection object with correct session id
* @throws ConnectionException create connection fails
*/
protected PartnerConnection doConnection(ConnectorConfig config, boolean openNewSession) throws ConnectionException {
if (!openNewSession) {
config.setSessionId(this.sessionId);
config.setServiceEndpoint(this.serviceEndPoint);
} else {
SalesforceConnectionProperties connProps = getConnectionProperties();
String endpoint = connProps.endpoint.getStringValue();
endpoint = StringUtils.strip(endpoint, "\"");
if (SalesforceConnectionProperties.LoginType.OAuth.equals(connProps.loginType.getValue())) {
SalesforceOAuthConnection oauthConnection = new SalesforceOAuthConnection(connProps, endpoint,
connProps.apiVersion.getValue());
oauthConnection.login(config);
} else {
config.setAuthEndpoint(endpoint);
}
}
config.setManualLogin(true);
// Creating connection and not login there.
PartnerConnection connection = new PartnerConnection(config);
// Need to discard manual login parameter in configs to avoid execution errors.
config.setManualLogin(false);
if (null == config.getSessionId()) {
performLogin(config, connection);
}
if (openNewSession && isReuseSession()) {
this.sessionId = config.getSessionId();
this.serviceEndPoint = config.getServiceEndpoint();
if (this.sessionId != null && this.serviceEndPoint != null) {
// update session file with current sessionId/serviceEndPoint
setupSessionProperties(connection);
}
}
return connection;
}