diff --git a/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralResponseMessageBinder.php b/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralResponseMessageBinder.php index b6b4361c..125f03c2 100644 --- a/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralResponseMessageBinder.php +++ b/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralResponseMessageBinder.php @@ -68,7 +68,14 @@ private function processType($phpType, $message) $message = $array; } else { - $message = $this->checkComplexType($phpType, $message); + if (is_array($message)) { + foreach ($message as $complexType) { + $array[] = $this->checkComplexType($phpType, $complexType); + } + $message = $array; + } else { + $message = $this->checkComplexType($phpType, $message); + } } } diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php b/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php index 85072d47..0b3142bd 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php @@ -18,6 +18,8 @@ class ComplexType extends Configuration private $name; private $value; private $isNillable = false; + private $minOccurs; + private $maxOccurs; public function getName() { @@ -49,8 +51,28 @@ public function setNillable($isNillable) $this->isNillable = (bool) $isNillable; } + public function getMinOccurs() + { + return $this->minOccurs; + } + + public function setMinOccurs($minOccurs) + { + $this->minOccurs = $minOccurs; + } + + public function getMaxOccurs() + { + return $this->maxOccurs; + } + + public function setMaxOccurs($maxOccurs) + { + $this->maxOccurs = $maxOccurs; + } + public function getAliasName() { return 'complextype'; } -} \ No newline at end of file +} diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php b/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php index d0ae4647..d092fec2 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php @@ -20,6 +20,8 @@ class ComplexType private $name; private $value; private $isNillable = false; + private $minOccurs; + private $maxOccurs; public function getName() { @@ -50,4 +52,23 @@ public function setNillable($isNillable) { $this->isNillable = (bool) $isNillable; } + + public function getMinOccurs() + { + return $this->minOccurs; + } + + public function setMinOccurs($minOccurs) + { + $this->minOccurs = $minOccurs; + } + public function getMaxOccurs() + { + return $this->maxOccurs; + } + + public function setMaxOccurs($maxOccurs) + { + $this->maxOccurs = $maxOccurs; + } } diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php index dcd15002..0562aff3 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php @@ -155,7 +155,7 @@ private function loadType($phpType) $loaded = $complexTypeResolver->load($phpType); $complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType); foreach ($loaded['properties'] as $name => $property) { - $complexType->add($name, $this->loadType($property->getValue()), $property->isNillable()); + $complexType->add($name, $this->loadType($property->getValue()), $property->isNillable(), $property->getMinOccurs(), $property->getMaxOccurs()); } $this->typeRepository->addComplexType($complexType); diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php index 1d3e095e..7d030b12 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php @@ -58,6 +58,8 @@ public function load($class, $type = null) $propertyComplexType = new ComplexType(); $propertyComplexType->setValue($complexType->getValue()); $propertyComplexType->setNillable($complexType->isNillable()); + $propertyComplexType->setMinOccurs($complexType->getMinOccurs()); + $propertyComplexType->setMaxOccurs($complexType->getMaxOccurs()); $propertyComplexType->setName($property->getName()); $annotations['properties']->add($propertyComplexType); } diff --git a/src/BeSimple/SoapCommon/Definition/Message.php b/src/BeSimple/SoapCommon/Definition/Message.php index caa78fe2..bc39cce9 100644 --- a/src/BeSimple/SoapCommon/Definition/Message.php +++ b/src/BeSimple/SoapCommon/Definition/Message.php @@ -48,13 +48,13 @@ public function isEmpty() return 0 === count($this->parts) ? true : false; } - public function add($name, $phpType, $nillable = false) + public function add($name, $phpType, $nillable = false, $minOccurs = null, $maxOccurs = null) { if ($phpType instanceof TypeInterface) { $phpType = $phpType->getPhpType(); } - $this->parts[$name] = new Part($name, $phpType, $nillable); + $this->parts[$name] = new Part($name, $phpType, $nillable, $minOccurs, $maxOccurs); return $this; } diff --git a/src/BeSimple/SoapCommon/Definition/Part.php b/src/BeSimple/SoapCommon/Definition/Part.php index 317f0464..5e12c8da 100644 --- a/src/BeSimple/SoapCommon/Definition/Part.php +++ b/src/BeSimple/SoapCommon/Definition/Part.php @@ -20,12 +20,16 @@ class Part protected $name; protected $type; protected $nillable; + protected $minOccurs; + protected $maxOccurs; - public function __construct($name, $type, $nillable = false) + public function __construct($name, $type, $nillable = false, $minOccurs = null, $maxOccurs = null) { $this->name = $name; $this->type = $type; $this->setNillable($nillable); + $this->setMinOccurs($minOccurs); + $this->setNillable($maxOccurs); } public function getName() @@ -52,4 +56,24 @@ public function setNillable($nillable) { $this->nillable = (boolean) $nillable; } + + public function getMinOccurs() + { + return $this->minOccurs; + } + + public function setMinOccurs($minOccurs) + { + $this->minOccurs = $minOccurs; + } + + public function getMaxOccurs() + { + return $this->maxOccurs; + } + + public function setMaxOccurs($maxOccurs) + { + $this->maxOccurs = $maxOccurs; + } } diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index ef555209..8f11eb2e 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -259,6 +259,13 @@ protected function addComplexType(ComplexType $type) if ($child->isNillable()) { $element->setAttribute('nillable', 'true'); } + + if (null !== $child->getMinOccurs() && 1 != $child->getMinOccurs()) { + $element->setAttribute('minOccurs', $child->getMinOccurs()); + } + if (null !== $child->getMaxOccurs() && 1 != $child->getMaxOccurs()) { + $element->setAttribute('maxOccurs', $child->getMaxOccurs()); + } if ($type instanceof ArrayOfType) { $element->setAttribute('minOccurs', 0);