You are here

public function SoapClient::connect in Salesforce Suite 8.3

Same name and namespace in other branches
  1. 8.4 modules/salesforce_soap/src/Soap/SoapClient.php \Drupal\salesforce_soap\Soap\SoapClient::connect()
  2. 5.0.x modules/salesforce_soap/src/Soap/SoapClient.php \Drupal\salesforce_soap\Soap\SoapClient::connect()

Establish a connection to the SOAP API.

Overrides SoapClientInterface::connect

1 call to SoapClient::connect()
SoapClient::trySoap in modules/salesforce_soap/src/Soap/SoapClient.php
Salesforce SOAP API resource wrapper.

File

modules/salesforce_soap/src/Soap/SoapClient.php, line 64

Class

SoapClient
A client for communicating with the Salesforce SOAP API.

Namespace

Drupal\salesforce_soap\Soap

Code

public function connect() {
  $this->isConnected = FALSE;

  // Use the "isAuthorized" callback to initialize session headers.
  if ($this->restApi
    ->isAuthorized()) {
    $this
      ->createConnection($this->wsdl);
    $token = $this->restApi
      ->getAccessToken();
    if (!$token) {
      $token = $this->restApi
        ->refreshToken();
    }
    $this
      ->setSessionHeader($token);
    $this
      ->setEndPoint($this->restApi
      ->getApiEndPoint('partner'));
    $this->isConnected = TRUE;
  }
  else {
    throw new \Exception('Salesforce needs to be authorized to connect to this website.');
  }
}