From d807dacd33616ed172f136804b7d311bae2bc213 Mon Sep 17 00:00:00 2001 From: Toon Verwerft Date: Fri, 7 Feb 2025 11:09:38 +0100 Subject: [PATCH] Fix reading RPC responses : It is the response type name that is being wrapped as element instead of the operation name --- src/Xml/Reader/OperationReader.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Xml/Reader/OperationReader.php b/src/Xml/Reader/OperationReader.php index 958a53c..d881806 100644 --- a/src/Xml/Reader/OperationReader.php +++ b/src/Xml/Reader/OperationReader.php @@ -8,8 +8,8 @@ use Soap\Engine\Metadata\Model\MethodMeta; use Soap\WsdlReader\Model\Definitions\BindingStyle; use function Psl\Vec\map; +use function VeeWee\Xml\Dom\Assert\assert_element; use function VeeWee\Xml\Dom\Locator\Element\children as locateChildElements; -use function VeeWee\Xml\Dom\Xpath\Configurator\namespaces; final class OperationReader { @@ -25,21 +25,16 @@ public function __construct( */ public function __invoke(string $xml): ElementList { - $operationName = $this->meta->operationName()->unwrap(); - $namespace = $this->meta->outputNamespace()->or($this->meta->targetNamespace())->unwrap(); $bindingStyle = BindingStyle::tryFrom($this->meta->bindingStyle()->unwrapOr(BindingStyle::DOCUMENT->value)); // The Response can contain out of multiple response parts. // Therefore, it is being wrapped by a central root element: $body = (new SoapEnvelopeReader())($xml); $bodyElement = $body->element(); - $xpath = $body->document()->xpath(namespaces(['tns' => $namespace])); $elements = match($bindingStyle) { BindingStyle::DOCUMENT => locateChildElements($bodyElement), - BindingStyle::RPC => locateChildElements( - $xpath->querySingle('./tns:'.$operationName, $bodyElement) - ) + BindingStyle::RPC => locateChildElements(assert_element($bodyElement->firstElementChild)), }; return new ElementList(...map($elements, Element::fromDOMElement(...)));