public function generateSoapClient(
        AdsSession $session,
        AdsHeaderHandler $headerHandler,
        AdsServiceDescriptor $serviceDescriptor
    ) {
        $options = [
            'trace' => true,
            'encoding' => 'utf-8',
            'connection_timeout' => $this->soapCallTimeout,
            'features' => SOAP_SINGLE_ELEMENT_ARRAYS
        ];

        $soapSettings = $session->getSoapSettings();
        $options = $this->populateOptions($session, $options, $soapSettings);

        $soapClient = $this->reflection->createInstance(
            $serviceDescriptor->getServiceClass(),
            $options
        );
        $soapClient->setStreamContext($options['stream_context']);
        $soapClient->setSoapLogMessageFormatter($this->soapLogMessageFormatter);
        $soapClient->setAdsSession($session);
        $soapClient->setHeaderHandler($headerHandler);
        $soapClient->setServiceDescriptor($serviceDescriptor);
        $soapClient->setSoapCallTimeout($this->soapCallTimeout);
        $soapClient->__setLocation(
            str_replace(
                sprintf(
                    '%s://%s',
                    parse_url($soapClient->getWsdlUri(), PHP_URL_SCHEME),
                    parse_url($soapClient->getWsdlUri(), PHP_URL_HOST)
                ),
                rtrim($session->getEndpoint(), '/'),
                $soapClient->getWsdlUri()
            )
        );

        return $soapClient;
    }