From bb95a6cb454e969b7d00fb157a1a8931698800eb Mon Sep 17 00:00:00 2001 From: Michael Veroux Date: Mon, 11 Feb 2019 12:22:13 +0100 Subject: [PATCH] Response xml format change support with backward compatibility --- .../RpcLiteralResponseMessageBinder.php | 5 ++++- .../Loader/AnnotationClassLoader.php | 7 ++++++- src/BeSimple/SoapCommon/Definition/Method.php | 11 +++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralResponseMessageBinder.php b/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralResponseMessageBinder.php index b6b4361..ba2e54f 100644 --- a/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralResponseMessageBinder.php +++ b/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralResponseMessageBinder.php @@ -32,7 +32,10 @@ class RpcLiteralResponseMessageBinder implements MessageBinderInterface { $this->typeRepository = $typeRepository; - return $this->processType($messageDefinition->getOutput()->get('return')->getType(), $message); + $parts = $messageDefinition->getOutput()->all(); + $part = array_shift($parts); + + return $this->processType($part->getType(), $message); } private function processType($phpType, $message) diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php index 99440c6..0903f18 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php @@ -96,6 +96,7 @@ class AnnotationClassLoader extends Loader } $serviceReturn = $annotation->getPhpType(); + $serviceXmlReturn = $annotation->getXmlType(); } } @@ -116,7 +117,11 @@ class AnnotationClassLoader extends Loader throw new \LogicException(sprintf('@Soap\Result non-existent for "%s".', $method->getName())); } - $serviceMethod->setOutput($this->loadType($serviceReturn)); + if (!isset($serviceXmlReturn) || !$serviceXmlReturn) { + $serviceXmlReturn = 'return'; + } + + $serviceMethod->setOutput($this->loadType($serviceReturn), $serviceXmlReturn); $definition->addMethod($serviceMethod); } diff --git a/src/BeSimple/SoapCommon/Definition/Method.php b/src/BeSimple/SoapCommon/Definition/Method.php index e79e9d2..579cf58 100644 --- a/src/BeSimple/SoapCommon/Definition/Method.php +++ b/src/BeSimple/SoapCommon/Definition/Method.php @@ -63,12 +63,19 @@ class Method public function addInput($name, $type) { + $inName = $this->name; + $this->input = new Message($inName); + $this->input->add($name, $type); } - public function setOutput($type) + public function setOutput($type, $name = 'return') { - $this->output->add('return', $type); + if ('return' !== $name) { + $this->output = new Message($name); + } + + $this->output->add($name, $type); } public function getHeaders()