From d609a35cca95c93f1e75004e1f1dcb60788e2f95 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Sat, 30 Jan 2021 23:16:26 +0100 Subject: [PATCH] fix exception name and ensure metadata are generated only once --- src/Loader/ArrayMetadataLoader.php | 2 +- src/Loader/DevMetadataLoader.php | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Loader/ArrayMetadataLoader.php b/src/Loader/ArrayMetadataLoader.php index b7f3cfe..0d9e80b 100644 --- a/src/Loader/ArrayMetadataLoader.php +++ b/src/Loader/ArrayMetadataLoader.php @@ -4,7 +4,7 @@ namespace GoetasWebservices\SoapServices\Metadata\Loader; -use GoetasWebservices\SoapServices\Exception\MetadataException; +use GoetasWebservices\SoapServices\Metadata\Exception\MetadataException; class ArrayMetadataLoader implements MetadataLoaderInterface { diff --git a/src/Loader/DevMetadataLoader.php b/src/Loader/DevMetadataLoader.php index d6f9f51..19f8df7 100644 --- a/src/Loader/DevMetadataLoader.php +++ b/src/Loader/DevMetadataLoader.php @@ -4,7 +4,7 @@ namespace GoetasWebservices\SoapServices\Metadata\Loader; -use GoetasWebservices\SoapServices\Exception\MetadataException; +use GoetasWebservices\SoapServices\Metadata\Exception\MetadataException; use GoetasWebservices\SoapServices\Metadata\Generator\MetadataGenerator; use GoetasWebservices\XML\SOAPReader\SoapReader; use GoetasWebservices\XML\WSDLReader\DefinitionsReader; @@ -41,9 +41,17 @@ public function __construct(MetadataGenerator $metadataGenerator, SoapReader $so public function load(string $wsdl): array { if (!isset($this->metadataCache[$wsdl])) { - $this->wsdlReader->readFile($wsdl); try { - $this->metadataCache[$wsdl] = $this->metadataGenerator->generate($this->soapReader->getServices()); + $definitions = $this->wsdlReader->readFile($wsdl); + + $services = []; + foreach ($definitions->getServices() as $service) { + foreach ($service->getPorts() as $port) { + $services[] = $this->soapReader->getServiceByPort($port); + } + } + + $this->metadataCache[$wsdl] = $this->metadataGenerator->generate($services); } catch (\Throwable $e) { throw new MetadataException(sprintf('Can not generate metadata information for %s', $wsdl), 0, $e); }