Skip to content

Commit 29c2389

Browse files
authored
Merge pull request #36 from veewee/rpc-reader-fix
Fix reading RPC responses
2 parents 3265f1c + d807dac commit 29c2389

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/Xml/Reader/OperationReader.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
use Soap\Engine\Metadata\Model\MethodMeta;
99
use Soap\WsdlReader\Model\Definitions\BindingStyle;
1010
use function Psl\Vec\map;
11+
use function VeeWee\Xml\Dom\Assert\assert_element;
1112
use function VeeWee\Xml\Dom\Locator\Element\children as locateChildElements;
12-
use function VeeWee\Xml\Dom\Xpath\Configurator\namespaces;
1313

1414
final class OperationReader
1515
{
@@ -25,21 +25,16 @@ public function __construct(
2525
*/
2626
public function __invoke(string $xml): ElementList
2727
{
28-
$operationName = $this->meta->operationName()->unwrap();
29-
$namespace = $this->meta->outputNamespace()->or($this->meta->targetNamespace())->unwrap();
3028
$bindingStyle = BindingStyle::tryFrom($this->meta->bindingStyle()->unwrapOr(BindingStyle::DOCUMENT->value));
3129

3230
// The Response can contain out of multiple response parts.
3331
// Therefore, it is being wrapped by a central root element:
3432
$body = (new SoapEnvelopeReader())($xml);
3533
$bodyElement = $body->element();
36-
$xpath = $body->document()->xpath(namespaces(['tns' => $namespace]));
3734

3835
$elements = match($bindingStyle) {
3936
BindingStyle::DOCUMENT => locateChildElements($bodyElement),
40-
BindingStyle::RPC => locateChildElements(
41-
$xpath->querySingle('./tns:'.$operationName, $bodyElement)
42-
)
37+
BindingStyle::RPC => locateChildElements(assert_element($bodyElement->firstElementChild)),
4338
};
4439

4540
return new ElementList(...map($elements, Element::fromDOMElement(...)));

0 commit comments

Comments
 (0)