/** * Creates a SoapClient with configured SoapConfig object and given additional settings. * * @param array $settings additional settings go here * * @return SoapClient * @throws InputException * @throws NoServerAvailableException * @throws \InvalidArgumentException */ public function create(array $settings = []) { // create soap settings, with given settings and platform settings $soapSettings = SoapSettings::loadFromArray($settings); // create a manager for endpoint management $manager = $this->createEndpointManager($settings); // replace the native soap client transport with a curl client $curlClient = $this->createCurlClient($soapSettings->toArray(), $manager); // build a SoapClient (extends the native soap client) $soapClient = new SoapClient($soapSettings, $manager, $curlClient); // set custom headers $soapHeaders = array_key_exists('soapHeaders', $settings) ? array_merge($settings['soapHeaders'], $this->config->getSoapHeaders()) : $this->config->getSoapHeaders(); $soapClient->__setSoapHeaders($soapHeaders); if ($this->config->hasConverter() === true) { $soapClient->setConverter($this->config->getConverter()); } if ($this->hasLogger() === true) { $soapClient->setLogger($this->logger); $this->logger->info('Created SoapClient for ' . $this->config->getPlatformConfig()->getPlatformName()); $this->logger->debug('Created SoapClient', ['SoapClient' => print_r($soapClient, true)]); $this->logger->debug('Settings', ['settings' => (array) $settings]); } return $soapClient; }
/** * @expectedException \SoapFault * * @throws \Exception * @throws \InvalidArgumentException * @throws \WebservicesNl\Common\Exception\Server\NoServerAvailableException * @throws \WebservicesNl\Common\Exception\Client\InputException * @throws \SoapFault */ public function testSoapClientInstanceWithBadRequest() { $mock = new MockHandler([new Response(202, ['Content-Length' => 0])]); $handler = HandlerStack::create($mock); $curlClient = new Client(['handler' => $handler, 'exceptions' => false]); $instance = new SoapClient($this->settings, $this->manager, $curlClient); $instance->setLogger($this->logger); $instance->__soapCall('/login'); }