/**
  * @throws \Exception
  * @throws \InvalidArgumentException
  * @throws \WebservicesNl\Common\Exception\Server\NoServerAvailableException
  * @throws \WebservicesNl\Common\Exception\Client\InputException
  * @throws \SoapFault
  */
 public function testSoapClientInstance()
 {
     static::assertNull($this->manager->getActiveEndpoint()->getLastConnected());
     // Create a mock and queue successful response.
     $mock = new MockHandler([new Response(202, ['Content-Length' => 0])]);
     $handler = HandlerStack::create($mock);
     $curlClient = new Client(['handler' => $handler]);
     $instance = new SoapClient($this->settings, $this->manager, $curlClient);
     $instance->setLogger($this->logger);
     $instance->__soapCall('login');
     static::assertNotNull($this->manager->getActiveEndpoint()->getLastConnected());
     static::assertEquals('soap', $instance->getProtocolName());
 }
 /**
  * Triggers the SOAP request over HTTP.
  * Sent request by cURL instead of native SOAP request.
  *
  * @param string      $request
  * @param string      $location
  * @param string      $action
  * @param int         $version
  * @param string|null $one_way
  *
  * @return string The XML SOAP response.
  * @throws WsClientException
  * @throws NoServerAvailableException
  * @throws \InvalidArgumentException
  * @throws \SoapFault
  */
 public function __doRequest($request, $location, $action, $version, $one_way = null)
 {
     $active = $this->manager->getActiveEndpoint();
     try {
         $response = $this->doHttpRequest($request, (string) $active->getUri(), $action);
         $this->manager->updateLastConnected();
         return $response;
     } catch (ConnectException $exception) {
         $active->setStatus('error');
         $this->log('Endpoint is not responding', 'error', ['endpoint' => $active]);
         return $this->__doRequest($request, $location, $action, $version, $one_way);
     }
 }
 /**
  * Configure PSR-7 guzzle client for this soap factory.
  *
  * @param array   $settings settings with extra guzzle settings
  * @param Manager $manager  endpoint Manager
  *
  * @return Client
  * @throws NoServerAvailableException
  */
 private function createCurlClient(array $settings, Manager $manager)
 {
     $settings['url'] = (string) $manager->getActiveEndpoint()->getUri();
     $factory = GuzzleClientFactory::build($this->config->getPlatformConfig());
     if ($this->hasLogger() === true) {
         $factory->setLogger($this->logger);
     }
     return $factory->create($settings);
 }
Beispiel #4
0
 /**
  * Test if endpoint last connected is updated
  *
  * @throws InputException
  * @throws NoServerAvailableException
  */
 public function testUpdateEndpoint()
 {
     $manager = new Manager();
     /** @var Endpoint[] $endpoints */
     $endpoints = FactoryMuffin::seed(3, 'WebservicesNl\\Common\\Endpoint\\Endpoint');
     foreach ($endpoints as $endpoint) {
         $manager->addEndpoint($endpoint);
     }
     $endpoint = $manager->updateLastConnected();
     $dateTime = new \DateTime();
     self::assertInstanceOf('\\DateTime', $manager->getActiveEndpoint()->getLastConnected());
     self::assertEquals($dateTime, $endpoint->getLastConnected(), 'DateTimes should be close to each other', 5);
 }