Package com.sforce.soap.partner

Examples of com.sforce.soap.partner.PartnerConnection


    partnerConfig.setPassword(password);
    partnerConfig
        .setAuthEndpoint("https://login.salesforce.com/services/Soap/u/27.0");
    // Creating the connection automatically handles login and stores
    // the session in partnerConfig
    new PartnerConnection(partnerConfig);
    // 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 = new ConnectorConfig();
View Full Code Here


     * @return PartnerConnection
     * @throws com.sforce.ws.ConnectionException
     */
    private PartnerConnection newConnection(ConnectorConfig bindingConfig, int retries) {
        try {
            PartnerConnection newBinding = Connector.newConnection(bindingConfig);

            newBinding.setCallOptions(API_CLIENT_NAME, null);

            logger.info("Logging in as " + bindingConfig.getUsername() + "/" + bindingConfig.getPassword() + " to URL: " + bindingConfig.getAuthEndpoint());
            if (bindingConfig.isManualLogin()) {
                LoginResult loginResult = newBinding.login(bindingConfig.getUsername(), bindingConfig.getPassword());
                // if password has expired, throw an exception
                if (loginResult.getPasswordExpired()) {
                    throw new PasswordExpiredException(Messages.getString("Client.errorExpiredPassword")); //$NON-NLS-1$
                }
                // update session id and service endpoint based on response
                newBinding.setSessionHeader(loginResult.getSessionId());
                bindingConfig.setServiceEndpoint(loginResult.getServerUrl());
            }
            return newBinding;
        } catch (ConnectionException e) {
            // in case of exception try to get a connection again
View Full Code Here

    ConnectorConfig config = new ConnectorConfig();
    config.setUsername(username);
    config.setPassword(new String(password));

    try {
      PartnerConnection connection = Connector.newConnection(config);

      GetUserInfoResult info = connection.getUserInfo();

      String org = settings.getString(Keys.realm.salesforce.orgId, "0")
          .trim();

      if (!org.equals("0")) {
View Full Code Here

        try {
            ConnectorConfig config = new ConnectorConfig();
            config.setManualLogin(true);
           
            // Just return a non-null PartnerConnection
            return new PartnerConnection(config);
        } catch (ConnectionException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

       
        return sb.toString();
    }
   
    protected void verifyEntityManager(EntityManager em) throws ConnectionException {
        PartnerConnection conn = getPartnerConnection(em);
       
        GetUserInfoResult userInfoResult = conn.getUserInfo();
        assertNotNull(userInfoResult);
       
        assertEquals(userInfoResult.getOrganizationId(), userInfo.getOrgId());
        assertEquals(userInfoResult.getUserId(), userInfo.getUserId());
        assertEquals(userInfoResult.getUserName(), userInfo.getUserName());
View Full Code Here

        ForceConnectorConfig config = createConfig();

        ForceServiceConnector connector = new ForceServiceConnector(config);
        connector.setClientId("testSetClientId");

        PartnerConnection conn = connector.getConnection();
        assertEquals(conn.getCallOptions().getClient(), "testSetClientId");

        MetadataConnection mdConn = connector.getMetadataConnection();
        assertEquals(mdConn.getCallOptions().getClient(), "testSetClientId");
    }
View Full Code Here

        ForceConnectorConfig config = createConfig();

        ForceServiceConnector connector = new ForceServiceConnector(config);
        connector.setTimeout(1000);

        PartnerConnection conn = connector.getConnection();
        assertEquals(conn.getConfig().getReadTimeout(), 1000);
    }
View Full Code Here

        ForceServiceConnector connector = new ForceServiceConnector();
        connector.setConnectorConfig(config);
        connector.setClientId("testUseLatestClientId2");

        PartnerConnection conn = connector.getConnection();
        assertEquals(conn.getCallOptions().getClient(), "testUseLatestClientId2");

        MetadataConnection mdConn = connector.getMetadataConnection();
        assertEquals(mdConn.getCallOptions().getClient(), "testUseLatestClientId2");
    }
View Full Code Here

       
        ForceServiceConnector connector = new ForceServiceConnector();
        connector.setConnectorConfig(config);
        connector.setTimeout(2000);
       
        PartnerConnection conn = connector.getConnection();
        assertEquals(conn.getConfig().getReadTimeout(), 2000);
    }
View Full Code Here

     * @throws IOException IOException
     */
    public static UserInfo loadFromPropertyFile(String propertyFileName) throws ConnectionException, IOException {
        // Load up the connection properties on the classpath
        ForceServiceConnector connector = new ForceServiceConnector(propertyFileName);
        PartnerConnection conn = connector.getConnection();
       
        assertNotNull(conn, "Unable to establish API connection. See " + propertyFileName + ".properties");
       
        // Get the user information from the API connection
        GetUserInfoResult userInfoResult = conn.getUserInfo();
        assertNotNull(userInfoResult, "Unable to retrieve user info. See " + propertyFileName + ".properties");
       
        return new UserInfo(userInfoResult.getOrganizationId(),
                            userInfoResult.getUserId(),
                            conn.getConfig().getUsername(),
                            conn.getConfig().getPassword(),
                            conn.getConfig().getServiceEndpoint());
    }
View Full Code Here

TOP

Related Classes of com.sforce.soap.partner.PartnerConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.