protected function soapClient(array $classMap, $parameters = array())
    {
        $endpoint = $this->client->getEndpoint();

        if ($this->soapClient === null) {
            $extensions = get_loaded_extensions();
            $errors     = array();

            if (!class_exists('SoapClient') || !in_array('soap', $extensions)) {
                $errors[] = 'The PHP SOAP extension doesn\'t seem to be installed. You need to install the PHP SOAP extension. (See: http://www.php.net/manual/en/book.soap.php)';
            }
            if (!in_array('openssl', $extensions)) {
                $errors[] = 'The PHP OpenSSL extension doesn\'t seem to be installed. You need to install PHP with the OpenSSL extension. (See: http://www.php.net/manual/en/book.openssl.php)';
            }
            if (!empty($errors)) {
                die('<p>' . implode("</p>\n<p>", $errors) . '</p>');
            }

            $options = array(
                'classmap' => $classMap,
                'encoding' => 'utf-8', // lets support unicode
                'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // see http://bugs.php.net/bug.php?id=43338
                'trace'    => false, // can be used for debugging
            );

            $wsdlUri = "https://{$endpoint}/wsdl/?service=" . $this->service;
            try {
                $this->soapClient = new \SoapClient($wsdlUri, $options);
            } catch (\SoapFault $sf) {
                throw new \Exception("Unable to connect to endpoint '{$endpoint}'");
            }

            $this->soapClient->__setCookie('login', $this->client->getLogin());
            $this->soapClient->__setCookie('mode', $this->client->getMode());
        }

        $timestamp = time();
        $nonce     = uniqid('', true);

        $this->soapClient->__setCookie('timestamp', $timestamp);
        $this->soapClient->__setCookie('nonce', $nonce);
        $this->soapClient->__setCookie('clientVersion', $this->apiVersion);
        $this->soapClient->__setCookie(
            'signature',
            $this->_urlencode(
                $this->_sign(
                    array_merge(
                        $parameters,
                        array(
                            '__service'   => $this->service,
                            '__hostname'  => $endpoint,
                            '__timestamp' => $timestamp,
                            '__nonce'     => $nonce
                        )
                    )
                )
            )
        );

        return $this->soapClient;
    }