Make connection with the soap client

@since 2.1.0
@access public
@return \Icepay_Webservice_Base
166860
public function setupClient()
    {
        /* Return if already set */
        if ($this->client)
            return $this;

        /* Set the options for the SOAP request */
        $sslContext = array(
            'ssl' => array(
                'allow_self_signed' => false,
                'verify_peer' => false /* Temporary fix */
            )
        );

        $soapArguments = array(
            'location' => $this->service,
            'encoding' => 'UTF-8',
            'cache_wsdl' => 'WSDL_CACHE_NONE',
            'stream_context' => stream_context_create($sslContext)
        );

        /* Start a new client */
        $this->client = new SoapClient($this->service, $soapArguments);

        /* Client configuration */
        $this->client->soap_defencoding = "utf-8";

        return $this;
    }
1230394
public function build()
    {
        $soapClient = (new Factory)->getClient($this->getEndpoint(), $this->getSoapOptions());

        $params['user_id'] = $this->userId;
        $params['agent_code'] = $this->agentCode;
        $params['agent_seq'] = $this->agentSeq;
        $client = new $this->client($soapClient, $params);

        if ($this->log) {
            //
        }

        return $client;
    }
663676
protected function connect()
        {
            if (!is_null($this->connection)) {
                return $this->connection;
            }
            // $this->connection = fsockopen($this->host, $this->port, $error, $message);
            $remote_socket = 'tcp://'.$this->host.':' . $this->port;
            $this->connection = @stream_socket_client($remote_socket, $errno, $error, 30);
            if ($this->connection === false) {
                throw new Exception("Error making Redis connection: {$error} - {$message}");
            }
            // $this->select($this->database);
            return $this->connection;
        }
937429
protected function connect()
    {
        $rs = false;

        foreach ((array)$this->server as $svr) {
            $error = 0;
            $errstr = '';
            $rs = @fsockopen($svr['host'], $svr['port'], $error, $errstr);

            if ($rs) {
                $this->socket = $rs;

            } else {
                $key = $this->getServerKey(
                    $svr['host'],
                    $svr['port'],
                    $svr['weight']
                );
                $s = "Connect to $key error:" . PHP_EOL .
                    "    [$error] $errstr";
                error_log($s);
            }
        }

        if (is_null($this->socket)) {
            $this->resultCode = Memcached::RES_FAILURE;
            $this->resultMessage = 'No server avaliable.';
            return false;

        } else {
            $this->resultCode = Memcached::RES_SUCCESS;
            $this->resultMessage = '';
            return true;
        }
    }
763674
public function buildService()
  {
    require_once($this->classFile);
    $wsdl = $this->generateWsdl();

    if (isset($_GET['wsdl'])) {
      print $wsdl;
    } else {
      $file = 'data://text/plain;base64,'. base64_encode($wsdl);
      $server = new \SoapServer($file);
      $server->setClass($this->className);
      $functions = get_class_methods($this->className);
      foreach ($functions as $function) {
        $server->addFunction($function);
      }
      $server->handle();
    }
  }
242113
public function connect(): self
    {
        if ($this->resource) {
            return $this;
        }

        $connectionWarnings = [];
        set_error_handler(function ($errno, $errstr) use (&$connectionWarnings) {
            $connectionWarnings[] = $errstr;
            return true;
        }, E_WARNING);

        $this->resource = pg_connect($this->connectionString, PGSQL_CONNECT_FORCE_NEW);

        restore_error_handler();
        if (false === $this->resource) {
            throw new exceptions\ConnectionException(
                __METHOD__ . ': ' . implode("\n", $connectionWarnings)
            );
        }
        $serverVersion = pg_parameter_status($this->resource, 'server_version');
        if (version_compare($serverVersion, '9.2.0', '<')) {
            $this->disconnect();
            throw new exceptions\ConnectionException(
                __METHOD__ . ': PostgreSQL versions earlier than 9.2 are no longer supported, '
                . 'connected server reports version ' . $serverVersion
            );
        }
        pg_set_error_verbosity($this->resource, PGSQL_ERRORS_VERBOSE);

        return $this;
    }
99878
public function connect()
    {
        $nodes = $this->nodeUrls;

        while (count($nodes)) {
            // pick random server
            $idx = rand(0, count($nodes) - 1);

            try {
                $stream = new DefaultStream($nodes[$idx], $this->log);
                $stream->connect();

                return $stream;
            } catch (ConnectException $e) {
                $this->log->warning($e->getMessage());
            }

            // remove the selected server from the list
            array_splice($nodes, $idx, 1);
        }

        throw new ConnectException('unable to connect to any of ['.implode(',', $this->nodeUrls).']');
    }
788002
public function connect()
    {
        try {
            // Make string containing database settings
            $database = 'sqlsrv:Server=' . $this->host . ';Database=' . $this->database;

            // Make connection.
            $conn = new \PDO($database, $this->username, $this->password);

            // Set attributes from parameters
            $conn->setAttribute(\PDO::ATTR_DEFAULT_FETCH_MODE, $this->fetch);
            $conn->setAttribute(\PDO::ATTR_ERRMODE, $this->error);

            return $conn;
        } catch (\PDOException $ex) {
            throw new \InvalidArgumentException('Error! Cannot connect to database ' . $ex->getMessage());
        }
    }
1332114
public function connect()
    {
        // Paramètre du service de connexion
        //@todo : supprimer ce paramètre ??
        $params = array(
            'arg0' => '1',
        );

        $this->client = $this->setClientSoap($this->URL_WSDL_AUTH);
        $result = $this->client->call('connect', $params, self::API_NAMESPACE, self::API_NAMESPACE, $this->createHeaders());

        if ($this->client->fault) {
            $this->errors[] = $this->client->faultstring;

            return false;
        } else {
            $err = $this->client->getError();
            if ($err) {
                $this->errors = $err;

                return $err;
            } else {
                if ($result == 'true') {
                    $this->isAuthenticated = true;

                    return true;
                } else {
                    return false;
                }
            }
        }
    }
858328
protected function initializeClient()
    {
        // Store some specific soap-client related data locally
        // so it can be injected in the SoapClient and compared
        // for changes later

        $this->wsdl          = $this->request->getLocation();
        $this->clientOptions = $this->request->getOptions();

        // store hash to make it possible to detect changes to the client
        $this->clientHash = $this->makeSoapClientHash();

        $xdebugEnabled = extension_loaded('xdebug') && xdebug_is_enabled();

        try {

            // temporarily disable xdebug to prevent PHP Fatal error
            // while constructing SoapClient

            if ($xdebugEnabled) xdebug_disable();

            $class = $this->soapClientClass;

            $this->client = $this->getSoapClientFactory()->make($class, $this->wsdl, $this->clientOptions);

            if ($xdebugEnabled) xdebug_enable();

        } catch (SoapFault $e) {

            throw new CouldNotConnectException($e->getMessage(), $e->getCode(), $e);

        } catch (Exception $e) {

            throw new CouldNotConnectException($e->getMessage(), $e->getCode(), $e);
        }
    }
1227863
protected function soap() {
        if (!$this->soap instanceof SoapClient) {
            $this->soap = new SoapClient($this->url, $this->options);
            $this->soap->soap_defencoding = 'utf-8';
            $this->soap->xml_encoding = 'utf-8';
        }
        return $this->soap;
    }
867946
public function connect()
	{
		if ($this->connection)
		{
			return;
		}

		// Build the connection configuration array.
		$config = array(
			'Database' => $this->options['database'],
			'uid' => $this->options['user'],
			'pwd' => $this->options['password'],
			'CharacterSet' => 'UTF-8',
			'ReturnDatesAsStrings' => true);

		// Make sure the SQLSRV extension for PHP is installed and enabled.
		if (!static::isSupported())
		{
			throw new \RuntimeException('PHP extension sqlsrv_connect is not available.');
		}

		// Attempt to connect to the server.
		if (!($this->connection = @ sqlsrv_connect($this->options['host'], $config)))
		{
			throw new \RuntimeException('Database sqlsrv_connect failed');
		}

		// Make sure that DB warnings are not returned as errors.
		sqlsrv_configure('WarningsReturnAsErrors', 0);

		// If auto-select is enabled select the given database.
		if ($this->options['select'] && !empty($this->options['database']))
		{
			$this->select($this->options['database']);
		}
	}
102013
public function server()
    {
        $this->prepareInput();

        $encryptStr = !empty($_GET['echostr']) ? $_GET['echostr'] : $this->encryptStr;

        $input = array(
            $encryptStr,
            $this->token,
            $this->input->get('timestamp'),
            $this->input->get('nonce'),
        );

        if ($this->input->get('msg_signature')
            && $this->signature($input) !== $this->input->get('msg_signature')
        ) {
            throw new Exception('Bad Request', 400);
        }

        if ($this->input->get('echostr')) {

            $xml = $this->getCrypt()->decrypt($this->input->get('echostr'), $this->appId);
            
            return strip_tags($xml);
        }

        return $this->response($this->handleRequest());

    }
1074149
private function initSoapClient()
    {
        if (!isset($this->service))
        {
            throw new ClientException("Not set service");
        }

        if ($this->soapClient === null)
        {
            $this->soapClient = new SoapClient($this->service, $this->cert, $this->trace, $this->curlOptions);
        }
    }
525363
private static function connection()
    {
        if (!self::$connection) {
            self::$connection = new Connection();
            if (self::$client_id) {
                self::$connection->authenticateOauth(self::$client_id, self::$auth_token);
            } else {
                self::$connection->authenticateBasic(self::$username, self::$api_key);
            }
        }

        return self::$connection;
    }
704289
protected function createClient()
    {
        $client = new MultiCurl();

        $credentials     = $this->getCredentials();
        $isAuthenticated = $credentials instanceof SSLCertificate;

        $client->setVerifyPeer($isAuthenticated);

        if ($isAuthenticated) {
            $client->setOption(CURLOPT_SSLCERT, $credentials->getCertificatePassPhrase());
            $client->setOption(CURLOPT_SSLCERTPASSWD, $credentials->getCertificatePassPhrase());
        }

        $this->serviceClient = new Browser($client);

        return $this;
    }
394358
private function buildSoapClient() {
		$header = $this->buildAuthHeader();

		if($this->isTest())
			$location = self::DHL_SANDBOX_URL;
		else
			$location = self::DHL_PRODUCTION_URL;

		$auth_params = array(
			'login' => $this->getCredentials()->getApiUser(),
			'password' => $this->getCredentials()->getApiPassword(),
			'location' => $location,
			'trace' => 1
		);

		$this->setSoapClient(new SoapClient($this->getAPIUrl(), $auth_params));
		$this->getSoapClient()->__setSoapHeaders($header);
	}