From b10b5431e579302d2205761d523127647ce683c9 Mon Sep 17 00:00:00 2001 From: Michael Veroux Date: Mon, 11 Feb 2019 11:33:27 +0100 Subject: [PATCH 01/47] Back to original name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b45f925..6ef7c50 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "cadoles/soap", + "name": "besimple/soap", "type": "library", "description": "Build and consume SOAP and WSDL based web services", "keywords": ["soap"], From e046be22eb72d7242023a5fa624b19b63e7d6adf Mon Sep 17 00:00:00 2001 From: Michael Veroux Date: Mon, 11 Feb 2019 11:39:35 +0100 Subject: [PATCH 02/47] Date semantics must support milliseconds for better interoperability Fix BeSimple#68 --- src/BeSimple/SoapCommon/WsSecurityFilterClientServer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BeSimple/SoapCommon/WsSecurityFilterClientServer.php b/src/BeSimple/SoapCommon/WsSecurityFilterClientServer.php index 15b0d25..40505b2 100644 --- a/src/BeSimple/SoapCommon/WsSecurityFilterClientServer.php +++ b/src/BeSimple/SoapCommon/WsSecurityFilterClientServer.php @@ -30,7 +30,7 @@ abstract class WsSecurityFilterClientServer /** * The date format to be used with {@link \DateTime} */ - const DATETIME_FORMAT = 'Y-m-d\TH:i:s.000\Z'; + const DATETIME_FORMAT = 'Y-m-d\TH:i:s.u\Z'; /** * (X509 3.2.1) Reference to a Subject Key Identifier From cdeab44c2c681d1023450ef71fb735f1884b550d Mon Sep 17 00:00:00 2001 From: Michael Veroux Date: Mon, 11 Feb 2019 11:45:50 +0100 Subject: [PATCH 03/47] Like this, DATETIME_FORMAT could be overriden Partial Fix BeSimple#68 --- src/BeSimple/SoapServer/WsSecurityFilter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BeSimple/SoapServer/WsSecurityFilter.php b/src/BeSimple/SoapServer/WsSecurityFilter.php index b2e86a0..234283a 100644 --- a/src/BeSimple/SoapServer/WsSecurityFilter.php +++ b/src/BeSimple/SoapServer/WsSecurityFilter.php @@ -86,7 +86,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque $expires = $xpath->query($query, $security)->item(0); if (null !== $expires) { - $expiresDatetime = \DateTime::createFromFormat(self::DATETIME_FORMAT, $expires->textContent, new \DateTimeZone('UTC')); + $expiresDatetime = \DateTime::createFromFormat(static::DATETIME_FORMAT, $expires->textContent, new \DateTimeZone('UTC')); $currentDatetime = new \DateTime('now', new \DateTimeZone('UTC')); if ($currentDatetime > $expiresDatetime) { @@ -170,7 +170,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque // init timestamp $dt = new \DateTime('now', new \DateTimeZone('UTC')); - $createdTimestamp = $dt->format(self::DATETIME_FORMAT); + $createdTimestamp = $dt->format(static::DATETIME_FORMAT); // create security header $security = $filterHelper->createElement(Helper::NS_WSS, 'Security'); @@ -182,7 +182,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque $timestamp->appendChild($created); if (null !== $this->expires) { $dt->modify('+' . $this->expires . ' seconds'); - $expiresTimestamp = $dt->format(self::DATETIME_FORMAT); + $expiresTimestamp = $dt->format(static::DATETIME_FORMAT); $expires = $filterHelper->createElement(Helper::NS_WSU, 'Expires', $expiresTimestamp); $timestamp->appendChild($expires); } From ad93b5ca499e39094d34814e7a766b66313d944e Mon Sep 17 00:00:00 2001 From: Michael Veroux Date: Mon, 11 Feb 2019 11:53:26 +0100 Subject: [PATCH 04/47] PHP 7 compatibility --- .travis.yml | 12 ++++++------ myphp.ini | 2 ++ .../SoapBundle/Converter/XopIncludeTypeConverter.php | 4 ++-- .../SoapBundle/Util/{String.php => BsString.php} | 2 +- .../Type/KeyValue/{Boolean.php => BsBoolean.php} | 2 +- .../Type/KeyValue/{Float.php => BsFloat.php} | 2 +- .../SoapCommon/Type/KeyValue/{Int.php => BsInt.php} | 2 +- .../Type/KeyValue/{String.php => BsString.php} | 2 +- 8 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 myphp.ini rename src/BeSimple/SoapBundle/Util/{String.php => BsString.php} (98%) rename src/BeSimple/SoapCommon/Type/KeyValue/{Boolean.php => BsBoolean.php} (85%) rename src/BeSimple/SoapCommon/Type/KeyValue/{Float.php => BsFloat.php} (85%) rename src/BeSimple/SoapCommon/Type/KeyValue/{Int.php => BsInt.php} (86%) rename src/BeSimple/SoapCommon/Type/KeyValue/{String.php => BsString.php} (85%) diff --git a/.travis.yml b/.travis.yml index 6458c71..4432c30 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,16 @@ language: php php: - - 5.3 - - 5.4 - - 5.5 - 5.6 + - 7.0 + - 7.1 env: - - SYMFONY_VERSION=2.6.* - - SYMFONY_VERSION="dev-master symfony/debug:~2.7@dev symfony/http-kernel:~2.7@dev" + - SYMFONY_VERSION=2.8.* + - SYMFONY_VERSION="dev-master symfony/debug:~2.8@dev symfony/http-kernel:~2.8@dev" before_script: + - phpenv config-add myphp.ini - composer self-update - composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update - composer update --no-interaction --prefer-source @@ -22,4 +22,4 @@ script: matrix: allow_failures: - - env: SYMFONY_VERSION="dev-master symfony/debug:~2.7@dev symfony/http-kernel:~2.7@dev" + - env: SYMFONY_VERSION="dev-master symfony/debug:~2.8@dev symfony/http-kernel:~2.8@dev" diff --git a/myphp.ini b/myphp.ini new file mode 100644 index 0000000..56cf4d9 --- /dev/null +++ b/myphp.ini @@ -0,0 +1,2 @@ +date.timezone = "Europe/Paris" +always_populate_raw_post_data = -1 diff --git a/src/BeSimple/SoapBundle/Converter/XopIncludeTypeConverter.php b/src/BeSimple/SoapBundle/Converter/XopIncludeTypeConverter.php index b83e38d..773e175 100644 --- a/src/BeSimple/SoapBundle/Converter/XopIncludeTypeConverter.php +++ b/src/BeSimple/SoapBundle/Converter/XopIncludeTypeConverter.php @@ -12,7 +12,7 @@ namespace BeSimple\SoapBundle\Converter; use BeSimple\SoapBundle\Soap\SoapRequest; use BeSimple\SoapBundle\Soap\SoapResponse; -use BeSimple\SoapBundle\Util\String; +use BeSimple\SoapBundle\Util\BsString; use BeSimple\SoapCommon\Converter\TypeConverterInterface; /** @@ -40,7 +40,7 @@ class XopIncludeTypeConverter implements TypeConverterInterface $ref = $include->getAttribute('href'); - if (String::startsWith($ref, 'cid:')) { + if (BsString::startsWith($ref, 'cid:')) { $cid = urldecode(substr($ref, 4)); return $request->getSoapAttachments()->get($cid)->getContent(); diff --git a/src/BeSimple/SoapBundle/Util/String.php b/src/BeSimple/SoapBundle/Util/BsString.php similarity index 98% rename from src/BeSimple/SoapBundle/Util/String.php rename to src/BeSimple/SoapBundle/Util/BsString.php index b95d53e..0aa5d60 100644 --- a/src/BeSimple/SoapBundle/Util/String.php +++ b/src/BeSimple/SoapBundle/Util/BsString.php @@ -15,7 +15,7 @@ namespace BeSimple\SoapBundle\Util; * * @author Christian Kerl */ -class String +class BsString { /** * Checks if a string starts with a given string. diff --git a/src/BeSimple/SoapCommon/Type/KeyValue/Boolean.php b/src/BeSimple/SoapCommon/Type/KeyValue/BsBoolean.php similarity index 85% rename from src/BeSimple/SoapCommon/Type/KeyValue/Boolean.php rename to src/BeSimple/SoapCommon/Type/KeyValue/BsBoolean.php index bfe684a..7e81c90 100644 --- a/src/BeSimple/SoapCommon/Type/KeyValue/Boolean.php +++ b/src/BeSimple/SoapCommon/Type/KeyValue/BsBoolean.php @@ -5,7 +5,7 @@ namespace BeSimple\SoapCommon\Type\KeyValue; use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; use BeSimple\SoapCommon\Type\AbstractKeyValue; -class Boolean extends AbstractKeyValue +class BsBoolean extends AbstractKeyValue { /** * @Soap\ComplexType("boolean") diff --git a/src/BeSimple/SoapCommon/Type/KeyValue/Float.php b/src/BeSimple/SoapCommon/Type/KeyValue/BsFloat.php similarity index 85% rename from src/BeSimple/SoapCommon/Type/KeyValue/Float.php rename to src/BeSimple/SoapCommon/Type/KeyValue/BsFloat.php index 6d286b0..fe63c9a 100644 --- a/src/BeSimple/SoapCommon/Type/KeyValue/Float.php +++ b/src/BeSimple/SoapCommon/Type/KeyValue/BsFloat.php @@ -5,7 +5,7 @@ namespace BeSimple\SoapCommon\Type\KeyValue; use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; use BeSimple\SoapCommon\Type\AbstractKeyValue; -class Float extends AbstractKeyValue +class BsFloat extends AbstractKeyValue { /** * @Soap\ComplexType("float") diff --git a/src/BeSimple/SoapCommon/Type/KeyValue/Int.php b/src/BeSimple/SoapCommon/Type/KeyValue/BsInt.php similarity index 86% rename from src/BeSimple/SoapCommon/Type/KeyValue/Int.php rename to src/BeSimple/SoapCommon/Type/KeyValue/BsInt.php index 0e0c190..369423c 100644 --- a/src/BeSimple/SoapCommon/Type/KeyValue/Int.php +++ b/src/BeSimple/SoapCommon/Type/KeyValue/BsInt.php @@ -5,7 +5,7 @@ namespace BeSimple\SoapCommon\Type\KeyValue; use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; use BeSimple\SoapCommon\Type\AbstractKeyValue; -class Int extends AbstractKeyValue +class BsInt extends AbstractKeyValue { /** * @Soap\ComplexType("int") diff --git a/src/BeSimple/SoapCommon/Type/KeyValue/String.php b/src/BeSimple/SoapCommon/Type/KeyValue/BsString.php similarity index 85% rename from src/BeSimple/SoapCommon/Type/KeyValue/String.php rename to src/BeSimple/SoapCommon/Type/KeyValue/BsString.php index 29473a9..7b11b9a 100644 --- a/src/BeSimple/SoapCommon/Type/KeyValue/String.php +++ b/src/BeSimple/SoapCommon/Type/KeyValue/BsString.php @@ -5,7 +5,7 @@ namespace BeSimple\SoapCommon\Type\KeyValue; use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap; use BeSimple\SoapCommon\Type\AbstractKeyValue; -class String extends AbstractKeyValue +class BsString extends AbstractKeyValue { /** * @Soap\ComplexType("string") From 3f2a99adf6133910f36bf00f19a57accb59e1e40 Mon Sep 17 00:00:00 2001 From: Michael Veroux Date: Mon, 11 Feb 2019 12:16:41 +0100 Subject: [PATCH 05/47] Array support change Support of mapping xml attributes --- .../Controller/SoapWebServiceController.php | 2 +- .../RpcLiteralRequestMessageBinder.php | 18 ++++++++++++- .../Annotation/ComplexType.php | 21 +++++++++++++++ .../ServiceDefinition/ComplexType.php | 21 +++++++++++++++ .../Loader/AnnotationClassLoader.php | 2 +- .../Loader/AnnotationComplexTypeLoader.php | 1 + src/BeSimple/SoapBundle/WebServiceContext.php | 5 +++- .../SoapCommon/Definition/Message.php | 4 +-- src/BeSimple/SoapCommon/Definition/Part.php | 24 ++++++++++++++++- src/BeSimple/SoapWsdl/Dumper/Dumper.php | 26 +++++++++++++++---- 10 files changed, 112 insertions(+), 12 deletions(-) diff --git a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php index e37cd2b..b7232c2 100644 --- a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php +++ b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php @@ -35,7 +35,7 @@ class SoapWebServiceController implements ContainerAwareInterface /** * @var ContainerInterface */ - private $container; + protected $container; /** * @var \SoapServer diff --git a/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralRequestMessageBinder.php b/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralRequestMessageBinder.php index 13abf08..b743a51 100644 --- a/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralRequestMessageBinder.php +++ b/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralRequestMessageBinder.php @@ -55,7 +55,8 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface $isArray = true; $array = array(); - $type = $this->typeRepository->getType($type->get('item')->getType()); + $phpType = substr($type->getPhpType(), 0, strlen($type->getPhpType()) - 2); + $type = $this->typeRepository->getType($phpType); } // @TODO Fix array reference @@ -78,6 +79,21 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface $array = $assocArray; } } + if (is_array($message)) { + foreach ($message as $complexType) { + $array[] = $this->checkComplexType($phpType, $complexType); + } + + // See https://github.com/BeSimple/BeSimpleSoapBundle/issues/29 + if (in_array('BeSimple\SoapCommon\Type\AbstractKeyValue', class_parents($phpType))) { + $assocArray = array(); + foreach ($array as $keyValue) { + $assocArray[$keyValue->getKey()] = $keyValue->getValue(); + } + + $array = $assocArray; + } + } $message = $array; } else { diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php b/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php index 85072d4..47f9019 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php @@ -18,6 +18,7 @@ class ComplexType extends Configuration private $name; private $value; private $isNillable = false; + private $isAttribute = false; public function getName() { @@ -49,6 +50,26 @@ class ComplexType extends Configuration $this->isNillable = (bool) $isNillable; } + /** + * @return bool + */ + public function isAttribute() + { + return $this->isAttribute; + } + + /** + * @param bool $isAttribute + * + * @return $this + */ + public function setIsAttribute($isAttribute) + { + $this->isAttribute = $isAttribute; + + return $this; + } + public function getAliasName() { return 'complextype'; diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php b/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php index d0ae464..7dca7f2 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php @@ -20,6 +20,7 @@ class ComplexType private $name; private $value; private $isNillable = false; + private $isAttribute = false; public function getName() { @@ -46,6 +47,26 @@ class ComplexType $this->value = $value; } + /** + * @return bool + */ + public function isAttribute() + { + return $this->isAttribute; + } + + /** + * @param bool $isAttribute + * + * @return $this + */ + public function setIsAttribute($isAttribute) + { + $this->isAttribute = $isAttribute; + + return $this; + } + public function setNillable($isNillable) { $this->isNillable = (bool) $isNillable; diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php index dcd1500..99440c6 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php @@ -155,7 +155,7 @@ class AnnotationClassLoader extends Loader $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->isAttribute()); } $this->typeRepository->addComplexType($complexType); diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php index 1d3e095..44089b6 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php @@ -58,6 +58,7 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader $propertyComplexType = new ComplexType(); $propertyComplexType->setValue($complexType->getValue()); $propertyComplexType->setNillable($complexType->isNillable()); + $propertyComplexType->setIsAttribute($complexType->isAttribute()); $propertyComplexType->setName($property->getName()); $annotations['properties']->add($propertyComplexType); } diff --git a/src/BeSimple/SoapBundle/WebServiceContext.php b/src/BeSimple/SoapBundle/WebServiceContext.php index 875659e..7947278 100644 --- a/src/BeSimple/SoapBundle/WebServiceContext.php +++ b/src/BeSimple/SoapBundle/WebServiceContext.php @@ -79,7 +79,10 @@ class WebServiceContext } $dumper = new Dumper($definition, array('stylesheet' => $this->options['wsdl_stylesheet'])); - $cache->write($dumper->dump()); + + $wsdl = $dumper->dump(); + + $cache->write($wsdl); } return $cache->getPath(); diff --git a/src/BeSimple/SoapCommon/Definition/Message.php b/src/BeSimple/SoapCommon/Definition/Message.php index caa78fe..506c56d 100644 --- a/src/BeSimple/SoapCommon/Definition/Message.php +++ b/src/BeSimple/SoapCommon/Definition/Message.php @@ -48,13 +48,13 @@ class Message return 0 === count($this->parts) ? true : false; } - public function add($name, $phpType, $nillable = false) + public function add($name, $phpType, $nillable = false, $attribute = false) { if ($phpType instanceof TypeInterface) { $phpType = $phpType->getPhpType(); } - $this->parts[$name] = new Part($name, $phpType, $nillable); + $this->parts[$name] = new Part($name, $phpType, $nillable, $attribute); return $this; } diff --git a/src/BeSimple/SoapCommon/Definition/Part.php b/src/BeSimple/SoapCommon/Definition/Part.php index 317f046..925d293 100644 --- a/src/BeSimple/SoapCommon/Definition/Part.php +++ b/src/BeSimple/SoapCommon/Definition/Part.php @@ -20,12 +20,14 @@ class Part protected $name; protected $type; protected $nillable; + protected $attribute; - public function __construct($name, $type, $nillable = false) + public function __construct($name, $type, $nillable = false, $attribute = false) { $this->name = $name; $this->type = $type; $this->setNillable($nillable); + $this->setAttribute($attribute); } public function getName() @@ -33,6 +35,26 @@ class Part return $this->name; } + /** + * @return bool + */ + public function isAttribute() + { + return $this->attribute; + } + + /** + * @param bool $attribute + * + * @return $this + */ + public function setAttribute($attribute) + { + $this->attribute = $attribute; + + return $this; + } + public function getType() { return $this->type; diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index ef55520..ff66351 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -217,11 +217,13 @@ class Dumper protected function addComplexTypes() { - $types = $this->document->createElement('types'); + $types = $this->document->createElement(static::WSDL_NS . ':types'); $this->domDefinitions->appendChild($types); $this->domSchema = $this->document->createElement(static::XSD_NS.':schema'); $this->domSchema->setAttribute('targetNamespace', $this->definition->getNamespace()); + $this->domSchema->setAttribute('elementFormDefault', 'unqualified'); + $this->domSchema->setAttribute(static::XML_NS.':'.static::XSD_NS, static::XSD_NS_URI); $types->appendChild($this->domSchema); foreach ($this->definition->getTypeRepository()->getComplexTypes() as $type) { @@ -236,13 +238,18 @@ class Dumper $complexType = $this->document->createElement(static::XSD_NS.':complexType'); $complexType->setAttribute('name', $type->getXmlType()); - $all = $this->document->createElement(static::XSD_NS.':'.($type instanceof ArrayOfType ? 'sequence' : 'all')); + $all = $this->document->createElement(static::XSD_NS.':'.'sequence'); $complexType->appendChild($all); foreach ($type->all() as $child) { + $isArray = false; $childType = $this->definition->getTypeRepository()->getType($child->getType()); - $element = $this->document->createElement(static::XSD_NS.':element'); + if ($child->isAttribute()) { + $element = $this->document->createElement(static::XSD_NS.':attribute'); + } else { + $element = $this->document->createElement(static::XSD_NS.':element'); + } $element->setAttribute('name', $child->getName()); if ($childType instanceof ComplexType) { @@ -251,6 +258,11 @@ class Dumper $name = $childType->getName(); } + if (0 === strpos($name, 'ArrayOf')) { + $isArray = true; + $name = lcfirst(substr($name, 7)); + } + $element->setAttribute('type', static::TYPES_NS.':'.$name); } else { $element->setAttribute('type', $childType); @@ -260,12 +272,16 @@ class Dumper $element->setAttribute('nillable', 'true'); } - if ($type instanceof ArrayOfType) { + if ($type instanceof ArrayOfType || $isArray) { $element->setAttribute('minOccurs', 0); $element->setAttribute('maxOccurs', 'unbounded'); } - $all->appendChild($element); + if ($child->isAttribute()) { + $complexType->appendChild($element); + } else { + $all->appendChild($element); + } } $this->domSchema->appendChild($complexType); From bb95a6cb454e969b7d00fb157a1a8931698800eb Mon Sep 17 00:00:00 2001 From: Michael Veroux Date: Mon, 11 Feb 2019 12:22:13 +0100 Subject: [PATCH 06/47] 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() From cc888bf168e580142824544ae452efe73553ef32 Mon Sep 17 00:00:00 2001 From: Michael Veroux Date: Wed, 13 Feb 2019 10:02:20 +0100 Subject: [PATCH 07/47] Deprecated method change --- .../Resources/config/routing/webservicecontroller.xml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/BeSimple/SoapBundle/Resources/config/routing/webservicecontroller.xml b/src/BeSimple/SoapBundle/Resources/config/routing/webservicecontroller.xml index cd370b9..0a055c3 100644 --- a/src/BeSimple/SoapBundle/Resources/config/routing/webservicecontroller.xml +++ b/src/BeSimple/SoapBundle/Resources/config/routing/webservicecontroller.xml @@ -1,18 +1,16 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd"> - + BeSimpleSoapBundle:SoapWebService:Call xml - POST - + BeSimpleSoapBundle:SoapWebService:Definition xml - GET From 0cb00e71b5387adc96085067b278f59e96fda347 Mon Sep 17 00:00:00 2001 From: Gianluigi Mammarella Date: Thu, 14 Mar 2019 03:05:52 +0100 Subject: [PATCH 08/47] Change package name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 6ef7c50..a4c13d9 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "besimple/soap", + "name": "cocciagialla/soap", "type": "library", "description": "Build and consume SOAP and WSDL based web services", "keywords": ["soap"], From d0f53bc8068a7368d79e61dc4302ff26e098189e Mon Sep 17 00:00:00 2001 From: Gianluigi Mammarella Date: Thu, 14 Mar 2019 03:24:20 +0100 Subject: [PATCH 09/47] pdate to SF4 --- composer.json | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index a4c13d9..93d32db 100644 --- a/composer.json +++ b/composer.json @@ -20,12 +20,12 @@ } ], "require": { - "php": ">=5.3.0", + "php": ">=7.0", "ext-soap": "*", "ext-curl": "*", "ass/xmlsecurity": "~1.0", - "symfony/framework-bundle": "~2.0|~3.0", - "symfony/twig-bundle": "~2.0|~3.0", + "symfony/framework-bundle": "~3.4|~4.0", + "symfony/twig-bundle": "~3.4|~4.0", "zendframework/zend-mime": "2.1.*" }, "replace": { @@ -37,9 +37,10 @@ }, "require-dev": { "ext-mcrypt": "*", - "mikey179/vfsStream": "~1.0", - "symfony/filesystem": "~2.0", - "symfony/process": "~2.3" + "mikey179/vfsStream": "~1.6.5", + "symfony/filesystem": "~2.3", + "symfony/process": "~2.3", + "phpunit/phpunit": "^5.7" }, "autoload": { "psr-0": { "BeSimple\\": "src/" } From 0e24ffe23d20806658501365d7d97153cdf8ca01 Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Thu, 14 Mar 2019 04:31:19 +0100 Subject: [PATCH 10/47] Alias dev-master --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 93d32db..55050ff 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ }, "extra": { "branch-alias": { - "dev-master": "0.3-dev" + "dev-master": "master" } } } From 873dc0ae087bef2d31b1714c7168119d98535242 Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Thu, 14 Mar 2019 04:53:26 +0100 Subject: [PATCH 11/47] Replace DefinitionDecorator with ChildDefinition --- .../DependencyInjection/BeSimpleSoapExtension.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php b/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php index ebb3623..8a947cb 100644 --- a/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php +++ b/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php @@ -17,7 +17,7 @@ use BeSimple\SoapCommon\Cache; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\DefinitionDecorator; +use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; @@ -88,14 +88,14 @@ class BeSimpleSoapExtension extends Extension } foreach ($config as $client => $options) { - $definition = new DefinitionDecorator('besimple.soap.client.builder'); + $definition = new ChildDefinition('besimple.soap.client.builder'); $container->setDefinition(sprintf('besimple.soap.client.builder.%s', $client), $definition); $definition->replaceArgument(0, $options['wsdl']); $defOptions = $container - ->getDefinition('besimple.soap.client.builder') - ->getArgument(1); + ->getDefinition('besimple.soap.client.builder') + ->getArgument(1); foreach (array('cache_type', 'user_agent') as $key) { if (isset($options[$key])) { @@ -135,7 +135,7 @@ class BeSimpleSoapExtension extends Extension private function createClientClassmap($client, array $classmap, ContainerBuilder $container) { - $definition = new DefinitionDecorator('besimple.soap.classmap'); + $definition = new ChildDefinition('besimple.soap.classmap'); $container->setDefinition(sprintf('besimple.soap.classmap.%s', $client), $definition); if (!empty($classmap)) { @@ -149,7 +149,7 @@ class BeSimpleSoapExtension extends Extension private function createClient($client, ContainerBuilder $container) { - $definition = new DefinitionDecorator('besimple.soap.client'); + $definition = new ChildDefinition('besimple.soap.client'); $container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition); if (3 === Kernel::MAJOR_VERSION) { @@ -168,7 +168,7 @@ class BeSimpleSoapExtension extends Extension unset($config['binding']); $contextId = 'besimple.soap.context.'.$config['name']; - $definition = new DefinitionDecorator('besimple.soap.context.'.$bindingSuffix); + $definition = new ChildDefinition('besimple.soap.context.'.$bindingSuffix); $container->setDefinition($contextId, $definition); if (isset($config['cache_type'])) { From 2d36e5f06002e11e8be346f8518d79c22abd3856 Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Tue, 2 Apr 2019 14:58:41 +0200 Subject: [PATCH 12/47] Fix compatibility with SF4 + Other fixes --- src/BeSimple/SoapBundle/.gitignore | 1 + .../Controller/SoapWebServiceController.php | 28 +++++++------------ .../BeSimpleSoapExtension.php | 1 + .../SoapBundle/Handler/ExceptionHandler.php | 2 +- .../Resources/config/webservice.xml | 2 +- .../Annotation/ComplexType.php | 14 ++++++++-- src/BeSimple/SoapWsdl/Dumper/Dumper.php | 10 +++---- 7 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/BeSimple/SoapBundle/.gitignore b/src/BeSimple/SoapBundle/.gitignore index c49a5d8..a934131 100644 --- a/src/BeSimple/SoapBundle/.gitignore +++ b/src/BeSimple/SoapBundle/.gitignore @@ -1,3 +1,4 @@ vendor/ composer.lock phpunit.xml +.idea/ diff --git a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php index b7232c2..6c412e9 100644 --- a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php +++ b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php @@ -15,12 +15,14 @@ namespace BeSimple\SoapBundle\Controller; use BeSimple\SoapBundle\Handler\ExceptionHandler; use BeSimple\SoapBundle\Soap\SoapRequest; use BeSimple\SoapBundle\Soap\SoapResponse; +use BeSimple\SoapBundle\WebServiceContext; use BeSimple\SoapServer\SoapServerBuilder; use Symfony\Component\DependencyInjection\ContainerAwareInterface; +use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\FlattenException; +use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; @@ -31,11 +33,7 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; */ class SoapWebServiceController implements ContainerAwareInterface { - - /** - * @var ContainerInterface - */ - protected $container; + use ContainerAwareTrait; /** * @var \SoapServer @@ -62,19 +60,12 @@ class SoapWebServiceController implements ContainerAwareInterface */ private $headers = array(); - /** - * {@inheritDoc} - */ - public function setContainer(ContainerInterface $container = null) - { - $this->container = $container; - } - /** * @return \BeSimple\SoapBundle\Soap\SoapResponse */ public function callAction($webservice) { + /** @var WebServiceContext $webServiceContext */ $webServiceContext = $this->getWebServiceContext($webservice); $this->serviceBinder = $webServiceContext->getServiceBinder(); @@ -98,7 +89,7 @@ class SoapWebServiceController implements ContainerAwareInterface } /** - * @return Symfony\Component\HttpFoundation\Response + * @return Response */ public function definitionAction($webservice) { @@ -110,7 +101,8 @@ class SoapWebServiceController implements ContainerAwareInterface ) )); - $request = $this->container->get('request'); + /** @var Request $request */ + $request = $this->container->get('request_stack')->getCurrentRequest(); $query = $request->query; if ($query->has('wsdl') || $query->has('WSDL')) { $request->setRequestFormat('wsdl'); @@ -136,9 +128,9 @@ class SoapWebServiceController implements ContainerAwareInterface throw new \LogicException(sprintf('The parameter "%s" is required in Request::$query parameter bag to generate the SoapFault.', '_besimple_soap_webservice'), null, $e); } - $view = 'TwigBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error').'.txt.twig'; + $view = '@Twig/Exception/'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error').'.txt.twig'; $code = $exception->getStatusCode(); - $details = $this->container->get('templating')->render($view, array( + $details = $this->container->get('twig')->render($view, array( 'status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'exception' => $exception, diff --git a/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php b/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php index 8a947cb..69f8908 100644 --- a/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php +++ b/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php @@ -177,6 +177,7 @@ class BeSimpleSoapExtension extends Extension $options = $container ->getDefinition('besimple.soap.context.'.$bindingSuffix) + ->setPublic(true) ->getArgument(2); $definition->replaceArgument(2, array_merge($options, $config)); diff --git a/src/BeSimple/SoapBundle/Handler/ExceptionHandler.php b/src/BeSimple/SoapBundle/Handler/ExceptionHandler.php index 54c12b4..2a2d613 100644 --- a/src/BeSimple/SoapBundle/Handler/ExceptionHandler.php +++ b/src/BeSimple/SoapBundle/Handler/ExceptionHandler.php @@ -13,8 +13,8 @@ namespace BeSimple\SoapBundle\Handler; use BeSimple\SoapServer\Exception\ReceiverSoapFault; +use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\Exception\FlattenException; /** * @author Francis Besset diff --git a/src/BeSimple/SoapBundle/Resources/config/webservice.xml b/src/BeSimple/SoapBundle/Resources/config/webservice.xml index 343885c..23de8cf 100644 --- a/src/BeSimple/SoapBundle/Resources/config/webservice.xml +++ b/src/BeSimple/SoapBundle/Resources/config/webservice.xml @@ -19,7 +19,7 @@ - + diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php b/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php index 47f9019..d3d2a78 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php @@ -35,6 +35,11 @@ class ComplexType extends Configuration return $this->isNillable; } + public function getIsNillable() + { + return $this->isNillable; + } + public function setName($name) { $this->name = $name; @@ -50,6 +55,11 @@ class ComplexType extends Configuration $this->isNillable = (bool) $isNillable; } + public function setIsNillable($isNillable) + { + $this->isNillable = (bool) $isNillable; + } + /** * @return bool */ @@ -66,7 +76,7 @@ class ComplexType extends Configuration public function setIsAttribute($isAttribute) { $this->isAttribute = $isAttribute; - + return $this; } @@ -74,4 +84,4 @@ class ComplexType extends Configuration { return 'complextype'; } -} \ No newline at end of file +} diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index ff66351..4280eee 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -238,7 +238,7 @@ class Dumper $complexType = $this->document->createElement(static::XSD_NS.':complexType'); $complexType->setAttribute('name', $type->getXmlType()); - $all = $this->document->createElement(static::XSD_NS.':'.'sequence'); + $all = $this->document->createElement(static::XSD_NS.':'.($type instanceof ArrayOfType ? 'sequence' : 'all')); $complexType->appendChild($all); foreach ($type->all() as $child) { @@ -258,10 +258,10 @@ class Dumper $name = $childType->getName(); } - if (0 === strpos($name, 'ArrayOf')) { - $isArray = true; - $name = lcfirst(substr($name, 7)); - } +// if (0 === strpos($name, 'ArrayOf')) { +// $isArray = true; +// $name = lcfirst(substr($name, 7)); +// } $element->setAttribute('type', static::TYPES_NS.':'.$name); } else { From 22bde386abb96aea8b292f4724303abcfc22c684 Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Tue, 2 Apr 2019 15:15:56 +0200 Subject: [PATCH 13/47] Fix composer json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 55050ff..4a4e21f 100644 --- a/composer.json +++ b/composer.json @@ -47,7 +47,7 @@ }, "extra": { "branch-alias": { - "dev-master": "master" + "dev-master": "master-dev" } } } From 19326bccdd5d6850aaaa7e52664385e267d2a44c Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 10 Apr 2019 07:20:07 +0200 Subject: [PATCH 14/47] Add .idea to ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c347960..f4212d0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ composer.lock composer.phar phpunit.xml +.idea From ceb69d97c3cf4e7d3c08a5078a9164bc42886de1 Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 10 Apr 2019 07:20:49 +0200 Subject: [PATCH 15/47] Fix binding name and soapAction attribute on wsdl --- src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php b/src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php index c67c035..f8a394b 100644 --- a/src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php +++ b/src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php @@ -61,7 +61,7 @@ abstract class AbstractVersion implements VersionInterface { if (!$this->bindingNode) { $this->bindingNode = $this->document->createElement('binding'); - $this->bindingNode->setAttribute('name', $this->name.'Binding'); + $this->bindingNode->setAttribute('name', $this->name.'_SOAP'); $this->bindingNode->setAttribute('type', $this->portTypeName); $this->addSoapBinding(); @@ -75,7 +75,7 @@ abstract class AbstractVersion implements VersionInterface if (!$this->servicePortNode) { $this->servicePortNode = $this->document->createElement('port'); $this->servicePortNode->setAttribute('name', $this->name.'Port'); - $this->servicePortNode->setAttribute('binding', $this->typeNs.':'.$this->name.'Binding'); + $this->servicePortNode->setAttribute('binding', $this->typeNs.':'.$this->name.'_SOAP'); $this->addSoapAddress(); } @@ -89,7 +89,7 @@ abstract class AbstractVersion implements VersionInterface $operation->setAttribute('name', $method->getName()); $soapOperation = $this->document->createElement($this->soapNs.':operation'); - $soapOperation->setAttribute('soapAction', $this->namespace.$method->getName()); + $soapOperation->setAttribute('soapAction', $this->namespace.'/'.$method->getName()); $operation->appendChild($soapOperation); $this->getBindingNode()->appendChild($operation); From 2771991fc0f7a50e97eec8d4caa02b8b114b453c Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 10 Apr 2019 07:21:51 +0200 Subject: [PATCH 16/47] Set document instead of rpc as default binding style --- src/BeSimple/SoapCommon/Definition/Definition.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BeSimple/SoapCommon/Definition/Definition.php b/src/BeSimple/SoapCommon/Definition/Definition.php index 7d9f742..1d04c87 100644 --- a/src/BeSimple/SoapCommon/Definition/Definition.php +++ b/src/BeSimple/SoapCommon/Definition/Definition.php @@ -42,7 +42,7 @@ class Definition { $this->options = array( 'version' => \SOAP_1_1, - 'style' => \SOAP_RPC, + 'style' => \SOAP_DOCUMENT, 'use' => \SOAP_LITERAL, 'location' => null, ); From c4118855de5b50dbd7ed9fb0bd61e378eb762ed8 Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 10 Apr 2019 07:22:34 +0200 Subject: [PATCH 17/47] Fix document literal binder for request and response --- .../DocumentLiteralWrappedRequestMessageBinder.php | 9 +++++---- .../DocumentLiteralWrappedResponseMessageBinder.php | 10 ++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/BeSimple/SoapBundle/ServiceBinding/DocumentLiteralWrappedRequestMessageBinder.php b/src/BeSimple/SoapBundle/ServiceBinding/DocumentLiteralWrappedRequestMessageBinder.php index 5d779b0..ad082de 100644 --- a/src/BeSimple/SoapBundle/ServiceBinding/DocumentLiteralWrappedRequestMessageBinder.php +++ b/src/BeSimple/SoapBundle/ServiceBinding/DocumentLiteralWrappedRequestMessageBinder.php @@ -11,13 +11,14 @@ namespace BeSimple\SoapBundle\ServiceBinding; use BeSimple\SoapBundle\ServiceDefinition\Method; +use BeSimple\SoapCommon\Definition\Type\TypeRepository; /** * @author Christian Kerl */ class DocumentLiteralWrappedRequestMessageBinder implements MessageBinderInterface { - public function processMessage(Method $messageDefinition, $message) + public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository) { if(count($message) > 1) { throw new \InvalidArgumentException(); @@ -26,10 +27,10 @@ class DocumentLiteralWrappedRequestMessageBinder implements MessageBinderInterfa $result = array(); $message = $message[0]; - foreach($messageDefinition->getArguments() as $argument) { - $result[$argument->getName()] = $message->{$argument->getName()}; + foreach($messageDefinition->getInput()->all() as $argument) { + $result[$argument->getName()] = $message; } return $result; } -} \ No newline at end of file +} diff --git a/src/BeSimple/SoapBundle/ServiceBinding/DocumentLiteralWrappedResponseMessageBinder.php b/src/BeSimple/SoapBundle/ServiceBinding/DocumentLiteralWrappedResponseMessageBinder.php index 21c72e0..7a3fcef 100644 --- a/src/BeSimple/SoapBundle/ServiceBinding/DocumentLiteralWrappedResponseMessageBinder.php +++ b/src/BeSimple/SoapBundle/ServiceBinding/DocumentLiteralWrappedResponseMessageBinder.php @@ -11,17 +11,15 @@ namespace BeSimple\SoapBundle\ServiceBinding; use BeSimple\SoapBundle\ServiceDefinition\Method; +use BeSimple\SoapCommon\Definition\Type\TypeRepository; /** * @author Christian Kerl */ class DocumentLiteralWrappedResponseMessageBinder implements MessageBinderInterface { - public function processMessage(Method $messageDefinition, $message) + public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository) { - $result = new \stdClass(); - $result->{$messageDefinition->getName().'Result'} = $message; - - return $result; + return $message; } -} \ No newline at end of file +} From 7802a0d19fb4fe1c5ad2f8b180f19649c52854cd Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 10 Apr 2019 07:28:07 +0200 Subject: [PATCH 18/47] Fix Dumper. Each complext type is now wrapped inside container element tag --- src/BeSimple/SoapWsdl/Dumper/Dumper.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index 4280eee..ce919ce 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -203,9 +203,9 @@ class Dumper $partElement->setAttribute('name', $part->getName()); if ($type instanceof ComplexType) { - $partElement->setAttribute('type', static::TYPES_NS.':'.$type->getXmlType()); + $partElement->setAttribute('element', static::TYPES_NS.':'.$type->getXmlType()); } else { - $partElement->setAttribute('type', $type); + $partElement->setAttribute('element', $type); } $messageElement->appendChild($partElement); @@ -235,10 +235,14 @@ class Dumper protected function addComplexType(ComplexType $type) { - $complexType = $this->document->createElement(static::XSD_NS.':complexType'); - $complexType->setAttribute('name', $type->getXmlType()); + $rootElement = $this->document->createElement(static::XSD_NS.':element'); + $rootElement->setAttribute('name', $type->getName()); - $all = $this->document->createElement(static::XSD_NS.':'.($type instanceof ArrayOfType ? 'sequence' : 'all')); + $complexType = $this->document->createElement(static::XSD_NS.':complexType'); + $rootElement->appendChild($complexType); + + //$all = $this->document->createElement(static::XSD_NS.':'.($type instanceof ArrayOfType ? 'sequence' : 'all')); + $all = $this->document->createElement(static::XSD_NS.':'.'sequence'); $complexType->appendChild($all); foreach ($type->all() as $child) { @@ -284,7 +288,7 @@ class Dumper } } - $this->domSchema->appendChild($complexType); + $this->domSchema->appendChild($rootElement); } protected function addPortType() From cdf77dacd8906aeecab4bbe90f2e37ca77c3eaec Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 10 Apr 2019 07:29:27 +0200 Subject: [PATCH 19/47] Fix input naming --- src/BeSimple/SoapCommon/Definition/Method.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/BeSimple/SoapCommon/Definition/Method.php b/src/BeSimple/SoapCommon/Definition/Method.php index 579cf58..b6af064 100644 --- a/src/BeSimple/SoapCommon/Definition/Method.php +++ b/src/BeSimple/SoapCommon/Definition/Method.php @@ -63,8 +63,7 @@ class Method public function addInput($name, $type) { - $inName = $this->name; - $this->input = new Message($inName); + $this->input = new Message($name); $this->input->add($name, $type); } From ca4991a9f6703a6c15a5e2a7bfa97484e5dd598b Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 10 Apr 2019 07:30:25 +0200 Subject: [PATCH 20/47] Fix location url from relative to absolute --- .../SoapBundle/Controller/SoapWebServiceController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php index 6c412e9..b85b9db 100644 --- a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php +++ b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php @@ -26,6 +26,7 @@ use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; /** * @author Christian Kerl @@ -97,7 +98,7 @@ class SoapWebServiceController implements ContainerAwareInterface $this->container->get('router')->generate( '_webservice_call', array('webservice' => $webservice), - true + UrlGeneratorInterface::ABSOLUTE_URL ) )); @@ -244,7 +245,7 @@ class SoapWebServiceController implements ContainerAwareInterface return $this->soapResponse = $response; } - private function getWebServiceContext($webservice) + protected function getWebServiceContext($webservice) { $context = sprintf('besimple.soap.context.%s', $webservice); From f9f47b913d8542976c7768e140ee8c0b49061a3f Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 10 Apr 2019 07:30:54 +0200 Subject: [PATCH 21/47] Add base64Binary type --- src/BeSimple/SoapBundle/Resources/config/webservice.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/BeSimple/SoapBundle/Resources/config/webservice.xml b/src/BeSimple/SoapBundle/Resources/config/webservice.xml index 23de8cf..30b7c22 100644 --- a/src/BeSimple/SoapBundle/Resources/config/webservice.xml +++ b/src/BeSimple/SoapBundle/Resources/config/webservice.xml @@ -96,6 +96,10 @@ dateTime xsd:dateTime + + base64Binary + xsd:base64Binary + From 6718703ba5222cf14608d4c9cb2a76f39c977346 Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 10 Apr 2019 07:31:37 +0200 Subject: [PATCH 22/47] Add headers binder for document --- ...teralWrappedRequestHeaderMessageBinder.php | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/BeSimple/SoapBundle/ServiceBinding/DocumentLiteralWrappedRequestHeaderMessageBinder.php diff --git a/src/BeSimple/SoapBundle/ServiceBinding/DocumentLiteralWrappedRequestHeaderMessageBinder.php b/src/BeSimple/SoapBundle/ServiceBinding/DocumentLiteralWrappedRequestHeaderMessageBinder.php new file mode 100644 index 0000000..21a6c60 --- /dev/null +++ b/src/BeSimple/SoapBundle/ServiceBinding/DocumentLiteralWrappedRequestHeaderMessageBinder.php @@ -0,0 +1,33 @@ + + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapBundle\ServiceBinding; + +use BeSimple\SoapBundle\ServiceDefinition\Method; +use BeSimple\SoapCommon\Definition\Type\TypeRepository; + +/** + * @author Francis Besset + */ +class DocumentLiteralWrappedRequestHeaderMessageBinder extends DocumentLiteralWrappedRequestMessageBinder +{ + private $header; + + public function setHeader($header) + { + $this->header = $header; + } + + public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository) + { + $headerDefinition = $messageDefinition->getHeaders()->get($this->header); + return []; + } +} From 2b8f75b4aed5e3b8d942ea344b3238bf413493a5 Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Thu, 11 Apr 2019 10:33:17 +0200 Subject: [PATCH 23/47] Fix wsdl for array complex type --- src/BeSimple/SoapWsdl/Dumper/Dumper.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index ce919ce..9121ff9 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -239,6 +239,10 @@ class Dumper $rootElement->setAttribute('name', $type->getName()); $complexType = $this->document->createElement(static::XSD_NS.':complexType'); + if ($type instanceof ArrayOfType) { + $complexType->setAttribute('name', $type->getName()); + } + $rootElement->appendChild($complexType); //$all = $this->document->createElement(static::XSD_NS.':'.($type instanceof ArrayOfType ? 'sequence' : 'all')); @@ -288,7 +292,7 @@ class Dumper } } - $this->domSchema->appendChild($rootElement); + $this->domSchema->appendChild($type instanceof ArrayOfType ? $complexType : $rootElement); } protected function addPortType() From a7c610b76796c2221482e6eb5ff5f358edde85a2 Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Mon, 15 Apr 2019 18:20:57 +0200 Subject: [PATCH 24/47] Add hexBinary type --- src/BeSimple/SoapBundle/Resources/config/webservice.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/BeSimple/SoapBundle/Resources/config/webservice.xml b/src/BeSimple/SoapBundle/Resources/config/webservice.xml index 30b7c22..444e2ff 100644 --- a/src/BeSimple/SoapBundle/Resources/config/webservice.xml +++ b/src/BeSimple/SoapBundle/Resources/config/webservice.xml @@ -100,6 +100,10 @@ base64Binary xsd:base64Binary + + hexBinary + xsd:hexBinary + From 9fc58e43883a1805337148653e3ab7c5e437815c Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Mon, 24 Jun 2019 19:05:43 +0200 Subject: [PATCH 25/47] Replace SOAP-ENV with soap as soap-envelope ns prefix --- src/BeSimple/SoapServer/SoapServer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/BeSimple/SoapServer/SoapServer.php b/src/BeSimple/SoapServer/SoapServer.php index 9b1deed..92237db 100644 --- a/src/BeSimple/SoapServer/SoapServer.php +++ b/src/BeSimple/SoapServer/SoapServer.php @@ -99,6 +99,7 @@ class SoapServer extends \SoapServer ob_start(); parent::handle($soapRequest->getContent()); $response = ob_get_clean(); + $response = str_replace('SOAP-ENV', 'soap', $response); // Remove headers added by SoapServer::handle() method header_remove('Content-Length'); From fea1093bed108392caf4388b191d7c902a43838a Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 26 Jun 2019 18:53:59 +0200 Subject: [PATCH 26/47] Remove from response the nillable elements. Fix namespace declaration in the xml response --- src/BeSimple/SoapServer/SoapServer.php | 25 ++++++++++++++++++++++++- src/BeSimple/SoapWsdl/Dumper/Dumper.php | 2 +- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/BeSimple/SoapServer/SoapServer.php b/src/BeSimple/SoapServer/SoapServer.php index 92237db..88a595e 100644 --- a/src/BeSimple/SoapServer/SoapServer.php +++ b/src/BeSimple/SoapServer/SoapServer.php @@ -99,7 +99,30 @@ class SoapServer extends \SoapServer ob_start(); parent::handle($soapRequest->getContent()); $response = ob_get_clean(); - $response = str_replace('SOAP-ENV', 'soap', $response); + + $dom = \DOMDocument::loadXML($response); + + /** @var \DOMElement $envelop */ + $envelop = $dom->childNodes->item(0); + $ns1 = $envelop->getAttribute('xmlns:ns1'); + $envelop->removeAttributeNS($ns1, 'ns1'); + $envelop->prefix = 'soap'; + + $envelop->setAttribute('soap:encodingStyle', 'http://schemas.xmlsoap.org/soap/encoding/'); + $envelop->setAttribute('xmlns:soapenc', 'http://schemas.xmlsoap.org/soap/encoding/'); + $envelop->setAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); + + /** @var \DOMElement $body */ + $body = $envelop->childNodes->item(0); + $body->prefix = 'soap'; + + /** @var \DOMElement $responseRoot */ + $responseRoot = $body->childNodes->item(0); + $responseRoot->setAttribute('xmlns', $ns1); + + $envelop->removeAttributeNS('http://schemas.xmlsoap.org/soap/envelope/', 'SOAP-ENV'); + + $response = $dom->saveXML(); // Remove headers added by SoapServer::handle() method header_remove('Content-Length'); diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index 9121ff9..5e2ae46 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -277,7 +277,7 @@ class Dumper } if ($child->isNillable()) { - $element->setAttribute('nillable', 'true'); + $element->setAttribute('minOccurs', 0); } if ($type instanceof ArrayOfType || $isArray) { From d1f5c1f6740121751754644c1123d97717fe5035 Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 26 Jun 2019 19:03:56 +0200 Subject: [PATCH 27/47] Remove from response the nillable elements. Fix namespace declaration in the xml response --- src/BeSimple/SoapServer/SoapServer.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/BeSimple/SoapServer/SoapServer.php b/src/BeSimple/SoapServer/SoapServer.php index 88a595e..75935b8 100644 --- a/src/BeSimple/SoapServer/SoapServer.php +++ b/src/BeSimple/SoapServer/SoapServer.php @@ -111,6 +111,7 @@ class SoapServer extends \SoapServer $envelop->setAttribute('soap:encodingStyle', 'http://schemas.xmlsoap.org/soap/encoding/'); $envelop->setAttribute('xmlns:soapenc', 'http://schemas.xmlsoap.org/soap/encoding/'); $envelop->setAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); + $envelop->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); /** @var \DOMElement $body */ $body = $envelop->childNodes->item(0); From a7a49b793acd80df352610572135f5158b896934 Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 26 Jun 2019 19:22:09 +0200 Subject: [PATCH 28/47] Add minOccurs and maxOccurs into wsdl dumper --- src/BeSimple/SoapWsdl/Dumper/Dumper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index 5e2ae46..b527605 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -278,11 +278,15 @@ class Dumper if ($child->isNillable()) { $element->setAttribute('minOccurs', 0); + } else { + $element->setAttribute('minOccurs', 1); } if ($type instanceof ArrayOfType || $isArray) { $element->setAttribute('minOccurs', 0); $element->setAttribute('maxOccurs', 'unbounded'); + } else { + $element->setAttribute('maxOccurs', 1); } if ($child->isAttribute()) { From 679b44ba13b09d1b830b674b9cd36a4e692d0c6d Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Thu, 27 Jun 2019 13:08:26 +0200 Subject: [PATCH 29/47] Use encoded instead of literal --- src/BeSimple/SoapCommon/Definition/Method.php | 2 +- src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BeSimple/SoapCommon/Definition/Method.php b/src/BeSimple/SoapCommon/Definition/Method.php index b6af064..7ef7e93 100644 --- a/src/BeSimple/SoapCommon/Definition/Method.php +++ b/src/BeSimple/SoapCommon/Definition/Method.php @@ -53,7 +53,7 @@ class Method public function getUse() { - return \SOAP_LITERAL; + return \SOAP_ENCODED; } public function addHeader($name, $type) diff --git a/src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php b/src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php index f8a394b..e56f2df 100644 --- a/src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php +++ b/src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php @@ -89,7 +89,7 @@ abstract class AbstractVersion implements VersionInterface $operation->setAttribute('name', $method->getName()); $soapOperation = $this->document->createElement($this->soapNs.':operation'); - $soapOperation->setAttribute('soapAction', $this->namespace.'/'.$method->getName()); + $soapOperation->setAttribute('soapAction', $this->namespace.$method->getName()); $operation->appendChild($soapOperation); $this->getBindingNode()->appendChild($operation); From 54e9e0ed058f2785e514cc53034d062dfe5c547c Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Thu, 27 Jun 2019 13:40:00 +0200 Subject: [PATCH 30/47] Remove SOAP-ENC --- src/BeSimple/SoapServer/SoapServer.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/BeSimple/SoapServer/SoapServer.php b/src/BeSimple/SoapServer/SoapServer.php index 75935b8..83c7b24 100644 --- a/src/BeSimple/SoapServer/SoapServer.php +++ b/src/BeSimple/SoapServer/SoapServer.php @@ -122,9 +122,12 @@ class SoapServer extends \SoapServer $responseRoot->setAttribute('xmlns', $ns1); $envelop->removeAttributeNS('http://schemas.xmlsoap.org/soap/envelope/', 'SOAP-ENV'); + $envelop->removeAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'SOAP-ENC'); $response = $dom->saveXML(); + $response = preg_replace('/xsi:type="ns1:\w*"/', '', $response); + // Remove headers added by SoapServer::handle() method header_remove('Content-Length'); header_remove('Content-Type'); From ef81da77ea25d78cf55408fde3e7919f60faff3e Mon Sep 17 00:00:00 2001 From: Gianluigi 'cocciagialla' Mammarella Date: Wed, 3 Jul 2019 01:08:36 +0200 Subject: [PATCH 31/47] Fix error handling --- .../Controller/SoapWebServiceController.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php index b85b9db..24d2ba8 100644 --- a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php +++ b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php @@ -17,12 +17,12 @@ use BeSimple\SoapBundle\Soap\SoapRequest; use BeSimple\SoapBundle\Soap\SoapResponse; use BeSimple\SoapBundle\WebServiceContext; use BeSimple\SoapServer\SoapServerBuilder; +use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; @@ -153,17 +153,17 @@ class SoapWebServiceController implements ContainerAwareInterface ->build() ; - ob_start(); - $server->handle( - ''. - ''. - ''. - ''. - ''. - '' - ); - - return new Response(ob_get_clean()); +// ob_start(); +// $server->handle( +// ''. +// ''. +// ''. +// ''. +// ''. +// '' +// ); +// +// return new Response(ob_get_clean()); } /** From 00101ff7fbc18de5427751e37929cd7f30943f11 Mon Sep 17 00:00:00 2001 From: BohwaZ Date: Tue, 6 Aug 2019 10:26:19 +0200 Subject: [PATCH 32/47] Restore package name after merging back changes of cocciagialla fork --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 4a4e21f..58d4a19 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "cocciagialla/soap", + "name": "cadoles/soap", "type": "library", "description": "Build and consume SOAP and WSDL based web services", "keywords": ["soap"], @@ -33,7 +33,8 @@ "besimple/soap-client": "self.version", "besimple/soap-common": "self.version", "besimple/soap-server": "self.version", - "besimple/soap-wsdl": "self.version" + "besimple/soap-wsdl": "self.version", + "cocciagialla/soap": "self.version" }, "require-dev": { "ext-mcrypt": "*", From ec0004ea3633886054f9e8e3dc035dd44c2a606c Mon Sep 17 00:00:00 2001 From: BohwaZ Date: Tue, 6 Aug 2019 10:28:55 +0200 Subject: [PATCH 33/47] Revert "Fix error handling" This reverts commit ef81da77ea25d78cf55408fde3e7919f60faff3e. --- .../Controller/SoapWebServiceController.php | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php index 24d2ba8..b85b9db 100644 --- a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php +++ b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php @@ -17,12 +17,12 @@ use BeSimple\SoapBundle\Soap\SoapRequest; use BeSimple\SoapBundle\Soap\SoapResponse; use BeSimple\SoapBundle\WebServiceContext; use BeSimple\SoapServer\SoapServerBuilder; -use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; @@ -153,17 +153,17 @@ class SoapWebServiceController implements ContainerAwareInterface ->build() ; -// ob_start(); -// $server->handle( -// ''. -// ''. -// ''. -// ''. -// ''. -// '' -// ); -// -// return new Response(ob_get_clean()); + ob_start(); + $server->handle( + ''. + ''. + ''. + ''. + ''. + '' + ); + + return new Response(ob_get_clean()); } /** From 95a91bb8bb26b4fce1ef081179c7f1b79bf57044 Mon Sep 17 00:00:00 2001 From: BohwaZ Date: Tue, 6 Aug 2019 10:48:46 +0200 Subject: [PATCH 34/47] Those tests don't have any value as depending on different PHP versions, the headers can slightly change --- .../Tests/AbstractWebserverTest.php | 3 --- src/BeSimple/SoapClient/Tests/CurlTest.php | 27 ------------------- 2 files changed, 30 deletions(-) diff --git a/src/BeSimple/SoapClient/Tests/AbstractWebserverTest.php b/src/BeSimple/SoapClient/Tests/AbstractWebserverTest.php index a7bc6d4..042b4f3 100644 --- a/src/BeSimple/SoapClient/Tests/AbstractWebserverTest.php +++ b/src/BeSimple/SoapClient/Tests/AbstractWebserverTest.php @@ -24,7 +24,6 @@ abstract class AbstractWebServerTest extends \PHPUnit_Framework_TestCase * @var ProcessBuilder */ static protected $webserver; - static protected $websererPortLength; public static function setUpBeforeClass() { @@ -44,8 +43,6 @@ abstract class AbstractWebServerTest extends \PHPUnit_Framework_TestCase self::$webserver->start(); usleep(100000); - - self::$websererPortLength = strlen(WEBSERVER_PORT); } public static function tearDownAfterClass() diff --git a/src/BeSimple/SoapClient/Tests/CurlTest.php b/src/BeSimple/SoapClient/Tests/CurlTest.php index 28b6311..bcfb2f6 100644 --- a/src/BeSimple/SoapClient/Tests/CurlTest.php +++ b/src/BeSimple/SoapClient/Tests/CurlTest.php @@ -45,19 +45,6 @@ class CurlTest extends AbstractWebserverTest $this->assertEquals('Unable to parse URL', $curl->getErrorMessage()); } - public function testGetRequestHeaders() - { - $curl = new Curl(array( - 'proxy_host' => false, - )); - - $curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)); - $this->assertEquals(132 + self::$websererPortLength, strlen($curl->getRequestHeaders())); - - $curl->exec(sprintf('http://localhost:%s/404.txt', WEBSERVER_PORT)); - $this->assertEquals(131 + self::$websererPortLength, strlen($curl->getRequestHeaders())); - } - public function testGetResponse() { $curl = new Curl(array( @@ -66,7 +53,6 @@ class CurlTest extends AbstractWebserverTest $curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)); $this->assertSame('OK', $curl->getResponseStatusMessage()); - $this->assertEquals(145 + self::$websererPortLength, strlen($curl->getResponse())); $curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT)); $this->assertSame('Not Found', $curl->getResponseStatusMessage()); @@ -95,19 +81,6 @@ class CurlTest extends AbstractWebserverTest $this->assertEquals('text/html; charset=UTF-8', $curl->getResponseContentType()); } - public function testGetResponseHeaders() - { - $curl = new Curl(array( - 'proxy_host' => false, - )); - - $curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)); - $this->assertEquals(117 + self::$websererPortLength, strlen($curl->getResponseHeaders())); - - $curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT)); - $this->assertEquals(124 + self::$websererPortLength, strlen($curl->getResponseHeaders())); - } - public function testGetResponseStatusCode() { $curl = new Curl(array( From 2e9dc9a34ddc6861eae22dd1e4ab30b288d2696f Mon Sep 17 00:00:00 2001 From: Tim Timmermans Date: Thu, 11 Jul 2019 14:50:44 +0200 Subject: [PATCH 35/47] Fix issue that each method param overrides the initial input message. --- src/BeSimple/SoapCommon/Definition/Method.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/BeSimple/SoapCommon/Definition/Method.php b/src/BeSimple/SoapCommon/Definition/Method.php index 7ef7e93..5c10f56 100644 --- a/src/BeSimple/SoapCommon/Definition/Method.php +++ b/src/BeSimple/SoapCommon/Definition/Method.php @@ -63,8 +63,6 @@ class Method public function addInput($name, $type) { - $this->input = new Message($name); - $this->input->add($name, $type); } From 6cf62100a44728e799f698d0f1d49619eaf41678 Mon Sep 17 00:00:00 2001 From: BohwaZ Date: Tue, 6 Aug 2019 11:03:54 +0200 Subject: [PATCH 36/47] ext-mcrypt is not necessary and is not included in PHP anymore --- composer.json | 5 ++--- src/BeSimple/SoapCommon/composer.json | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 58d4a19..ec001c5 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "type": "library", "description": "Build and consume SOAP and WSDL based web services", "keywords": ["soap"], - "homepage": "http://besim.pl", + "homepage": "https://github.com/Cadoles/BeSimpleSoap", "license": "MIT", "authors": [ { @@ -37,8 +37,7 @@ "cocciagialla/soap": "self.version" }, "require-dev": { - "ext-mcrypt": "*", - "mikey179/vfsStream": "~1.6.5", + "mikey179/vfsstream": "~1.6.5", "symfony/filesystem": "~2.3", "symfony/process": "~2.3", "phpunit/phpunit": "^5.7" diff --git a/src/BeSimple/SoapCommon/composer.json b/src/BeSimple/SoapCommon/composer.json index bf1ec6d..6948063 100644 --- a/src/BeSimple/SoapCommon/composer.json +++ b/src/BeSimple/SoapCommon/composer.json @@ -25,8 +25,7 @@ "ass/xmlsecurity": "~1.0" }, "require-dev": { - "ext-mcrypt": "*", - "mikey179/vfsStream": "~1.0" + "mikey179/vfsstream": "~1.0" }, "autoload": { "psr-0": { "BeSimple\\SoapCommon": "" } From a3d691261c41261c7b10e26043c653198c071346 Mon Sep 17 00:00:00 2001 From: BohwaZ Date: Tue, 6 Aug 2019 11:04:18 +0200 Subject: [PATCH 37/47] Update README, add back some instructions on how to use --- myphp.ini | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 myphp.ini diff --git a/myphp.ini b/myphp.ini deleted file mode 100644 index 56cf4d9..0000000 --- a/myphp.ini +++ /dev/null @@ -1,2 +0,0 @@ -date.timezone = "Europe/Paris" -always_populate_raw_post_data = -1 From b8bf76aeb961ebfb05af4df8888042033e28f833 Mon Sep 17 00:00:00 2001 From: BohwaZ Date: Tue, 6 Aug 2019 11:07:42 +0200 Subject: [PATCH 38/47] fixup! Update README, add back some instructions on how to use --- README.md | 152 +++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 133 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 1f30fbf..2ca917a 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,146 @@ -# BeSimpleSoap (Symfony 3.0) +# BeSimpleSoap (Symfony 3.4 / 4.x) -This fork aims to provide the BeSimpleSoap bundles compatibles with Symfony 3. +This fork provides the BeSimpleSoap bundle, updated to be compatible with Symfony 3.4 and 4.x (as well as with PHP 7.0-7.4). -We forked the official -[BeSimpleSoap](https://github.com/BeSimple/BeSimpleSoap) repository in -order to sucessfully maintain some projects of ours. Therefore, **we are -not going to maintain this library**. +We forked the official [BeSimpleSoap](https://github.com/BeSimple/BeSimpleSoap) repository in order to sucessfully maintain some of our projects. + +We now have integrated changes and fixes from sub-forks (thank you guys!), and we should be up to date now :) + +This fork is maintained by people from [Cadoles](https://www.cadoles.com/). + +# Contributing + +We do welcome pull requests :) please include tests if you can. + +Running tests can be done by running `php vendor/bin/phpunit`. # Installation -If you do not yet have composer, install it like this: +If you do not yet have composer, follow instructions on the [Composer website](https://getcomposer.org/download/) to install it. -```sh -curl -s http://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin +Then just running: + +``` +$ composer require cadoles/soap ``` -Create a `composer.json` file: +should be enough to get you up and running. -```json +# Components + +BeSimpleSoap consists of five components ... + +## BeSimpleSoapClient + +**Refactored** BeSimpleSoapClient is a component that extends the native PHP SoapClient with further features like SwA and WS-Security. + +## BeSimpleSoapServer + +**Refactored** BeSimpleSoapServer is a component that extends the native PHP SoapServer with further features like SwA and WS-Security. + +## BeSimpleSoapCommon + +**Refactored** BeSimpleSoapCommon component contains functionality shared by both the server and client implementations. + +## BeSimpleSoapWsdl + +**Untouched!** +The component is not affected by refactoring so it should work properly. +For further information see the original [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapWsdl/README.md). + +## BeSimpleSoapBundle + +**Unsupported!** +The BeSimpleSoapBundle is a Symfony2 bundle to build WSDL and SOAP based web services. +For further information see the the original [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapBundle/README.md). +*Will not work since the Symfony libraries were removed and usages of other components were not refactored. Feel free to fork this repository and fix it!* + +# How to use + +You can investigate the unit tests dir ``tests`` in order to get a clue. +Forget about associative arrays, vague configurations, multiple extension and silent errors! +This may look a bit more complex at the first sight, +but it will guide you to configure and set up your client or server properly. + +## Example of soap client call + +```php +$soapClientBuilder = new SoapClientBuilder(); +$soapClient = $soapClientBuilder->build( + SoapClientOptionsBuilder::createWithDefaults(), + SoapOptionsBuilder::createWithDefaults('http://path/to/wsdlfile.wsdl') +); +$myRequest = new MyRequest(); +$myRequest->attribute = 'string value'; +$soapResponse = $soapClient->soapCall('myMethod', [$myRequest]); + +var_dump($soapResponse); // Contains Response, Attachments +``` + +### Something wrong?! + +Turn on the tracking and catch `SoapFaultWithTracingData` exception to get some sweets :) + +```php +try { + $soapResponse = $soapClient->soapCall('myMethod', [$myRequest]); +} catch (SoapFaultWithTracingData $fault) { + var_dump($fault->getSoapResponseTracingData()->getLastRequest()); +} +``` +In this example, a ``MyRequest`` object has been used to describe request. +Using a ClassMap, you help SoapClient to turn it into XML request. + +## Example of soap server handling + +Starting a SOAP server is a bit more complex. +I recommend you to inspect SoapServer unit tests for inspiration. + +```php +$dummyService = new DummyService(); +$classMap = new ClassMap(); +foreach ($dummyService->getClassMap() as $type => $className) { + $classMap->add($type, $className); +} +$soapServerBuilder = new SoapServerBuilder(); +$soapServerOptions = SoapServerOptionsBuilder::createWithDefaults($dummyService); +$soapOptions = SoapOptionsBuilder::createWithClassMap($dummyService->getWsdlPath(), $classMap); +$soapServer = $soapServerBuilder->build($soapServerOptions, $soapOptions); + +$request = $soapServer->createRequest( + $dummyService->getEndpoint(), + 'DummyService.dummyServiceMethod', + 'text/xml;charset=UTF-8', + '' +); +$response = $soapServer->handleRequest($request); + +var_dump($response); // Contains Response, Attachments +``` + +In this example, a ``DummyService`` service has been used to handle request. +Using a service can help you create coherent SoapServer endpoints. +Service can hold an endpoint URL, WSDL path and a class map as associative array. +You can hold a class map as ``ClassMap`` object directly in the ``DummyService`` instead of array. + +In the service you should describe SOAP methods from given WSDL. +In the example, the dummyServiceMethod is called. +The method will receive request object and return response object that are matched according to the class map. + +See a simplified implementation of ``dummyServiceMethod`` to get a clue: + +```php +/** + * @param DummyServiceRequest $dummyServiceRequest + * @return DummyServiceResponse + */ +public function dummyServiceMethod(DummyServiceRequest $dummyServiceRequest) { - "require": { - "cadoles/soap": "0.3.*@dev" - } + $response = new DummyServiceResponse(); + $response->status = true; + + return $response; } ``` -Now you are ready to install the library: - -```sh -php /usr/local/bin/composer.phar install -``` +For further information and getting inspiration for your implementation, see the unit tests in ``tests`` dir. \ No newline at end of file From 729a2bc8df835b4dbb5d8ac857c933dfe275cf39 Mon Sep 17 00:00:00 2001 From: Tim Timmermans Date: Thu, 11 Jul 2019 15:26:23 +0200 Subject: [PATCH 39/47] Fix dumper in order to generate a valid WSDL --- src/BeSimple/SoapWsdl/Dumper/Dumper.php | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index b527605..736b608 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -235,17 +235,9 @@ class Dumper protected function addComplexType(ComplexType $type) { - $rootElement = $this->document->createElement(static::XSD_NS.':element'); - $rootElement->setAttribute('name', $type->getName()); - $complexType = $this->document->createElement(static::XSD_NS.':complexType'); - if ($type instanceof ArrayOfType) { - $complexType->setAttribute('name', $type->getName()); - } + $complexType->setAttribute('name', $type->getXmlType()); - $rootElement->appendChild($complexType); - - //$all = $this->document->createElement(static::XSD_NS.':'.($type instanceof ArrayOfType ? 'sequence' : 'all')); $all = $this->document->createElement(static::XSD_NS.':'.'sequence'); $complexType->appendChild($all); @@ -266,11 +258,6 @@ class Dumper $name = $childType->getName(); } -// if (0 === strpos($name, 'ArrayOf')) { -// $isArray = true; -// $name = lcfirst(substr($name, 7)); -// } - $element->setAttribute('type', static::TYPES_NS.':'.$name); } else { $element->setAttribute('type', $childType); @@ -296,7 +283,7 @@ class Dumper } } - $this->domSchema->appendChild($type instanceof ArrayOfType ? $complexType : $rootElement); + $this->domSchema->appendChild($complexType); } protected function addPortType() From 412e7f16c9abec566fb9269695353abac8e4b833 Mon Sep 17 00:00:00 2001 From: Tim Timmermans Date: Thu, 11 Jul 2019 16:34:15 +0200 Subject: [PATCH 40/47] Reverted default definition style to RPC. --- src/BeSimple/SoapCommon/Definition/Definition.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BeSimple/SoapCommon/Definition/Definition.php b/src/BeSimple/SoapCommon/Definition/Definition.php index 1d04c87..7d9f742 100644 --- a/src/BeSimple/SoapCommon/Definition/Definition.php +++ b/src/BeSimple/SoapCommon/Definition/Definition.php @@ -42,7 +42,7 @@ class Definition { $this->options = array( 'version' => \SOAP_1_1, - 'style' => \SOAP_DOCUMENT, + 'style' => \SOAP_RPC, 'use' => \SOAP_LITERAL, 'location' => null, ); From cc83e1e6db88507bbdcfa7c643b0ca2affd5d574 Mon Sep 17 00:00:00 2001 From: Tim Timmermans Date: Thu, 11 Jul 2019 16:55:43 +0200 Subject: [PATCH 41/47] Add support for "overriden" routes --- .../SoapBundle/Controller/SoapWebServiceController.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php index b85b9db..97246eb 100644 --- a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php +++ b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php @@ -94,9 +94,15 @@ class SoapWebServiceController implements ContainerAwareInterface */ public function definitionAction($webservice) { + $routeName = $webservice . '_webservice_call'; + $result = $this->container->get('router')->getRouteCollection()->get($routeName); + if ($result === null) { + $routeName = '_webservice_call'; + } + $response = new Response($this->getWebServiceContext($webservice)->getWsdlFileContent( $this->container->get('router')->generate( - '_webservice_call', + $routeName, array('webservice' => $webservice), UrlGeneratorInterface::ABSOLUTE_URL ) From aa0b750f47f400476e7673115eebbbbd53423b5c Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 12 Sep 2019 11:43:53 +0200 Subject: [PATCH 42/47] Revert "Array support change" This reverts commit 3f2a99adf6133910f36bf00f19a57accb59e1e40. --- .../Controller/SoapWebServiceController.php | 39 +++++++++---------- .../RpcLiteralRequestMessageBinder.php | 18 +-------- .../Annotation/ComplexType.php | 21 ---------- .../ServiceDefinition/ComplexType.php | 21 ---------- .../Loader/AnnotationClassLoader.php | 2 +- .../Loader/AnnotationComplexTypeLoader.php | 1 - src/BeSimple/SoapBundle/WebServiceContext.php | 5 +-- .../SoapCommon/Definition/Message.php | 4 +- src/BeSimple/SoapCommon/Definition/Part.php | 24 +----------- src/BeSimple/SoapWsdl/Dumper/Dumper.php | 21 +++------- 10 files changed, 30 insertions(+), 126 deletions(-) diff --git a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php index 97246eb..05631c9 100644 --- a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php +++ b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php @@ -19,7 +19,6 @@ use BeSimple\SoapBundle\WebServiceContext; use BeSimple\SoapServer\SoapServerBuilder; use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareTrait; -use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Debug\Exception\FlattenException; @@ -59,7 +58,7 @@ class SoapWebServiceController implements ContainerAwareInterface /** * @var array */ - private $headers = array(); + private $headers = []; /** * @return \BeSimple\SoapBundle\Soap\SoapResponse @@ -67,12 +66,12 @@ class SoapWebServiceController implements ContainerAwareInterface public function callAction($webservice) { /** @var WebServiceContext $webServiceContext */ - $webServiceContext = $this->getWebServiceContext($webservice); + $webServiceContext = $this->getWebServiceContext($webservice); $this->serviceBinder = $webServiceContext->getServiceBinder(); $this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request_stack')->getCurrentRequest()); - $this->soapServer = $webServiceContext + $this->soapServer = $webServiceContext ->getServerBuilder() ->withSoapVersion11() ->withHandler($this) @@ -96,14 +95,14 @@ class SoapWebServiceController implements ContainerAwareInterface { $routeName = $webservice . '_webservice_call'; $result = $this->container->get('router')->getRouteCollection()->get($routeName); - if ($result === null) { + if (null === $result) { $routeName = '_webservice_call'; } $response = new Response($this->getWebServiceContext($webservice)->getWsdlFileContent( $this->container->get('router')->generate( $routeName, - array('webservice' => $webservice), + ['webservice' => $webservice], UrlGeneratorInterface::ABSOLUTE_URL ) )); @@ -135,14 +134,14 @@ class SoapWebServiceController implements ContainerAwareInterface throw new \LogicException(sprintf('The parameter "%s" is required in Request::$query parameter bag to generate the SoapFault.', '_besimple_soap_webservice'), null, $e); } - $view = '@Twig/Exception/'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error').'.txt.twig'; + $view = '@Twig/Exception/' . ($this->container->get('kernel')->isDebug() ? 'exception' : 'error') . '.txt.twig'; $code = $exception->getStatusCode(); - $details = $this->container->get('twig')->render($view, array( + $details = $this->container->get('twig')->render($view, [ 'status_code' => $code, 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', - 'exception' => $exception, - 'logger' => $logger, - )); + 'exception' => $exception, + 'logger' => $logger, + ]); $handler = new ExceptionHandler($exception, $details); if ($soapFault = $request->query->get('_besimple_soap_fault')) { @@ -153,7 +152,7 @@ class SoapWebServiceController implements ContainerAwareInterface } $server = SoapServerBuilder::createWithDefaults() - ->withWsdl(__DIR__.'/../Handler/wsdl/exception.wsdl') + ->withWsdl(__DIR__ . '/../Handler/wsdl/exception.wsdl') ->withWsdlCacheNone() ->withHandler($handler) ->build() @@ -161,11 +160,11 @@ class SoapWebServiceController implements ContainerAwareInterface ob_start(); $server->handle( - ''. - ''. - ''. - ''. - ''. + '' . + '' . + '' . + '' . + '' . '' ); @@ -176,8 +175,8 @@ class SoapWebServiceController implements ContainerAwareInterface * This method gets called once for every SOAP header the \SoapServer received * and afterwards once for the called SOAP operation. * - * @param string $method The SOAP header or SOAP operation name - * @param array $arguments + * @param string $method The SOAP header or SOAP operation name + * @param array $arguments * * @return mixed */ @@ -234,7 +233,7 @@ class SoapWebServiceController implements ContainerAwareInterface } /** - * Set the SoapResponse + * Set the SoapResponse. * * @param Response $response A response to check and set * diff --git a/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralRequestMessageBinder.php b/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralRequestMessageBinder.php index b743a51..13abf08 100644 --- a/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralRequestMessageBinder.php +++ b/src/BeSimple/SoapBundle/ServiceBinding/RpcLiteralRequestMessageBinder.php @@ -55,8 +55,7 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface $isArray = true; $array = array(); - $phpType = substr($type->getPhpType(), 0, strlen($type->getPhpType()) - 2); - $type = $this->typeRepository->getType($phpType); + $type = $this->typeRepository->getType($type->get('item')->getType()); } // @TODO Fix array reference @@ -79,21 +78,6 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface $array = $assocArray; } } - if (is_array($message)) { - foreach ($message as $complexType) { - $array[] = $this->checkComplexType($phpType, $complexType); - } - - // See https://github.com/BeSimple/BeSimpleSoapBundle/issues/29 - if (in_array('BeSimple\SoapCommon\Type\AbstractKeyValue', class_parents($phpType))) { - $assocArray = array(); - foreach ($array as $keyValue) { - $assocArray[$keyValue->getKey()] = $keyValue->getValue(); - } - - $array = $assocArray; - } - } $message = $array; } else { diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php b/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php index d3d2a78..49122cf 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Annotation/ComplexType.php @@ -18,7 +18,6 @@ class ComplexType extends Configuration private $name; private $value; private $isNillable = false; - private $isAttribute = false; public function getName() { @@ -60,26 +59,6 @@ class ComplexType extends Configuration $this->isNillable = (bool) $isNillable; } - /** - * @return bool - */ - public function isAttribute() - { - return $this->isAttribute; - } - - /** - * @param bool $isAttribute - * - * @return $this - */ - public function setIsAttribute($isAttribute) - { - $this->isAttribute = $isAttribute; - - return $this; - } - public function getAliasName() { return 'complextype'; diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php b/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php index 7dca7f2..d0ae464 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/ComplexType.php @@ -20,7 +20,6 @@ class ComplexType private $name; private $value; private $isNillable = false; - private $isAttribute = false; public function getName() { @@ -47,26 +46,6 @@ class ComplexType $this->value = $value; } - /** - * @return bool - */ - public function isAttribute() - { - return $this->isAttribute; - } - - /** - * @param bool $isAttribute - * - * @return $this - */ - public function setIsAttribute($isAttribute) - { - $this->isAttribute = $isAttribute; - - return $this; - } - public function setNillable($isNillable) { $this->isNillable = (bool) $isNillable; diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php index 0903f18..5460a85 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationClassLoader.php @@ -160,7 +160,7 @@ class AnnotationClassLoader extends Loader $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(), $property->isAttribute()); + $complexType->add($name, $this->loadType($property->getValue()), $property->isNillable()); } $this->typeRepository->addComplexType($complexType); diff --git a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php index 44089b6..1d3e095 100644 --- a/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php +++ b/src/BeSimple/SoapBundle/ServiceDefinition/Loader/AnnotationComplexTypeLoader.php @@ -58,7 +58,6 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader $propertyComplexType = new ComplexType(); $propertyComplexType->setValue($complexType->getValue()); $propertyComplexType->setNillable($complexType->isNillable()); - $propertyComplexType->setIsAttribute($complexType->isAttribute()); $propertyComplexType->setName($property->getName()); $annotations['properties']->add($propertyComplexType); } diff --git a/src/BeSimple/SoapBundle/WebServiceContext.php b/src/BeSimple/SoapBundle/WebServiceContext.php index 7947278..875659e 100644 --- a/src/BeSimple/SoapBundle/WebServiceContext.php +++ b/src/BeSimple/SoapBundle/WebServiceContext.php @@ -79,10 +79,7 @@ class WebServiceContext } $dumper = new Dumper($definition, array('stylesheet' => $this->options['wsdl_stylesheet'])); - - $wsdl = $dumper->dump(); - - $cache->write($wsdl); + $cache->write($dumper->dump()); } return $cache->getPath(); diff --git a/src/BeSimple/SoapCommon/Definition/Message.php b/src/BeSimple/SoapCommon/Definition/Message.php index 506c56d..caa78fe 100644 --- a/src/BeSimple/SoapCommon/Definition/Message.php +++ b/src/BeSimple/SoapCommon/Definition/Message.php @@ -48,13 +48,13 @@ class Message return 0 === count($this->parts) ? true : false; } - public function add($name, $phpType, $nillable = false, $attribute = false) + public function add($name, $phpType, $nillable = false) { if ($phpType instanceof TypeInterface) { $phpType = $phpType->getPhpType(); } - $this->parts[$name] = new Part($name, $phpType, $nillable, $attribute); + $this->parts[$name] = new Part($name, $phpType, $nillable); return $this; } diff --git a/src/BeSimple/SoapCommon/Definition/Part.php b/src/BeSimple/SoapCommon/Definition/Part.php index 925d293..317f046 100644 --- a/src/BeSimple/SoapCommon/Definition/Part.php +++ b/src/BeSimple/SoapCommon/Definition/Part.php @@ -20,14 +20,12 @@ class Part protected $name; protected $type; protected $nillable; - protected $attribute; - public function __construct($name, $type, $nillable = false, $attribute = false) + public function __construct($name, $type, $nillable = false) { $this->name = $name; $this->type = $type; $this->setNillable($nillable); - $this->setAttribute($attribute); } public function getName() @@ -35,26 +33,6 @@ class Part return $this->name; } - /** - * @return bool - */ - public function isAttribute() - { - return $this->attribute; - } - - /** - * @param bool $attribute - * - * @return $this - */ - public function setAttribute($attribute) - { - $this->attribute = $attribute; - - return $this; - } - public function getType() { return $this->type; diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index 736b608..a66120e 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -217,13 +217,11 @@ class Dumper protected function addComplexTypes() { - $types = $this->document->createElement(static::WSDL_NS . ':types'); + $types = $this->document->createElement('types'); $this->domDefinitions->appendChild($types); $this->domSchema = $this->document->createElement(static::XSD_NS.':schema'); $this->domSchema->setAttribute('targetNamespace', $this->definition->getNamespace()); - $this->domSchema->setAttribute('elementFormDefault', 'unqualified'); - $this->domSchema->setAttribute(static::XML_NS.':'.static::XSD_NS, static::XSD_NS_URI); $types->appendChild($this->domSchema); foreach ($this->definition->getTypeRepository()->getComplexTypes() as $type) { @@ -238,18 +236,13 @@ class Dumper $complexType = $this->document->createElement(static::XSD_NS.':complexType'); $complexType->setAttribute('name', $type->getXmlType()); - $all = $this->document->createElement(static::XSD_NS.':'.'sequence'); + $all = $this->document->createElement(static::XSD_NS.':'.($type instanceof ArrayOfType ? 'sequence' : 'all')); $complexType->appendChild($all); foreach ($type->all() as $child) { - $isArray = false; $childType = $this->definition->getTypeRepository()->getType($child->getType()); - if ($child->isAttribute()) { - $element = $this->document->createElement(static::XSD_NS.':attribute'); - } else { - $element = $this->document->createElement(static::XSD_NS.':element'); - } + $element = $this->document->createElement(static::XSD_NS.':element'); $element->setAttribute('name', $child->getName()); if ($childType instanceof ComplexType) { @@ -269,18 +262,14 @@ class Dumper $element->setAttribute('minOccurs', 1); } - if ($type instanceof ArrayOfType || $isArray) { + if ($type instanceof ArrayOfType) { $element->setAttribute('minOccurs', 0); $element->setAttribute('maxOccurs', 'unbounded'); } else { $element->setAttribute('maxOccurs', 1); } - if ($child->isAttribute()) { - $complexType->appendChild($element); - } else { - $all->appendChild($element); - } + $all->appendChild($element); } $this->domSchema->appendChild($complexType); From 0c94185907244d35aae8528116eb6932094943a8 Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 12 Sep 2019 11:44:47 +0200 Subject: [PATCH 43/47] Revert "Fix Dumper. Each complext type is now wrapped inside container element tag" This reverts commit 7802a0d19fb4fe1c5ad2f8b180f19649c52854cd. --- src/BeSimple/SoapWsdl/Dumper/Dumper.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index a66120e..f222684 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -203,9 +203,9 @@ class Dumper $partElement->setAttribute('name', $part->getName()); if ($type instanceof ComplexType) { - $partElement->setAttribute('element', static::TYPES_NS.':'.$type->getXmlType()); + $partElement->setAttribute('type', static::TYPES_NS.':'.$type->getXmlType()); } else { - $partElement->setAttribute('element', $type); + $partElement->setAttribute('type', $type); } $messageElement->appendChild($partElement); From 914acccf1dbf2ac10edb89fd58f7938e1b57430b Mon Sep 17 00:00:00 2001 From: William Petit Date: Thu, 12 Sep 2019 11:45:48 +0200 Subject: [PATCH 44/47] Ignore .php_cs.cache files --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f4212d0..fb4dbce 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ composer.lock composer.phar phpunit.xml .idea +.php_cs.cache From 6d5f9ff9e53aa252eb6c3eb50363744a9925bfc0 Mon Sep 17 00:00:00 2001 From: William Petit Date: Mon, 16 Sep 2019 16:41:21 +0200 Subject: [PATCH 45/47] Show null attributes in response Partially revert changes from d1f5c1f6740121751754644c1123d97717fe5035 and fea1093bed108392caf4388b191d7c902a43838a --- src/BeSimple/SoapWsdl/Dumper/Dumper.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/BeSimple/SoapWsdl/Dumper/Dumper.php b/src/BeSimple/SoapWsdl/Dumper/Dumper.php index f222684..ef55520 100644 --- a/src/BeSimple/SoapWsdl/Dumper/Dumper.php +++ b/src/BeSimple/SoapWsdl/Dumper/Dumper.php @@ -257,16 +257,12 @@ class Dumper } if ($child->isNillable()) { - $element->setAttribute('minOccurs', 0); - } else { - $element->setAttribute('minOccurs', 1); + $element->setAttribute('nillable', 'true'); } if ($type instanceof ArrayOfType) { $element->setAttribute('minOccurs', 0); $element->setAttribute('maxOccurs', 'unbounded'); - } else { - $element->setAttribute('maxOccurs', 1); } $all->appendChild($element); From 95706abbd7b89c0fc76ff677a1ac29bc73fe22ed Mon Sep 17 00:00:00 2001 From: Teddy Cornaut Date: Thu, 19 Sep 2019 15:29:04 -0400 Subject: [PATCH 46/47] =?UTF-8?q?Retour=20=C3=A0=20une=20signature=20iso?= =?UTF-8?q?=20PROD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BeSimple/SoapCommon/Definition/Method.php | 10 ++-------- src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php | 4 ++-- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/BeSimple/SoapCommon/Definition/Method.php b/src/BeSimple/SoapCommon/Definition/Method.php index 5c10f56..99b1f4c 100644 --- a/src/BeSimple/SoapCommon/Definition/Method.php +++ b/src/BeSimple/SoapCommon/Definition/Method.php @@ -12,8 +12,6 @@ namespace BeSimple\SoapCommon\Definition; -use BeSimple\SoapCommon\Definition\Type\TypeRepository; - /** * @author Francis Besset */ @@ -53,7 +51,7 @@ class Method public function getUse() { - return \SOAP_ENCODED; + return \SOAP_LITERAL; } public function addHeader($name, $type) @@ -68,11 +66,7 @@ class Method public function setOutput($type, $name = 'return') { - if ('return' !== $name) { - $this->output = new Message($name); - } - - $this->output->add($name, $type); + $this->output->add('return', $type); } public function getHeaders() diff --git a/src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php b/src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php index e56f2df..c67c035 100644 --- a/src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php +++ b/src/BeSimple/SoapWsdl/Dumper/AbstractVersion.php @@ -61,7 +61,7 @@ abstract class AbstractVersion implements VersionInterface { if (!$this->bindingNode) { $this->bindingNode = $this->document->createElement('binding'); - $this->bindingNode->setAttribute('name', $this->name.'_SOAP'); + $this->bindingNode->setAttribute('name', $this->name.'Binding'); $this->bindingNode->setAttribute('type', $this->portTypeName); $this->addSoapBinding(); @@ -75,7 +75,7 @@ abstract class AbstractVersion implements VersionInterface if (!$this->servicePortNode) { $this->servicePortNode = $this->document->createElement('port'); $this->servicePortNode->setAttribute('name', $this->name.'Port'); - $this->servicePortNode->setAttribute('binding', $this->typeNs.':'.$this->name.'_SOAP'); + $this->servicePortNode->setAttribute('binding', $this->typeNs.':'.$this->name.'Binding'); $this->addSoapAddress(); } From a1695680aeb99d8faaf683650dd57836bddfb4c8 Mon Sep 17 00:00:00 2001 From: Teddy Cornaut Date: Fri, 20 Sep 2019 12:10:09 -0400 Subject: [PATCH 47/47] Signature de Response iso PROD --- src/BeSimple/SoapServer/SoapServer.php | 38 +++----------------------- 1 file changed, 4 insertions(+), 34 deletions(-) diff --git a/src/BeSimple/SoapServer/SoapServer.php b/src/BeSimple/SoapServer/SoapServer.php index 83c7b24..f12c16d 100644 --- a/src/BeSimple/SoapServer/SoapServer.php +++ b/src/BeSimple/SoapServer/SoapServer.php @@ -100,34 +100,6 @@ class SoapServer extends \SoapServer parent::handle($soapRequest->getContent()); $response = ob_get_clean(); - $dom = \DOMDocument::loadXML($response); - - /** @var \DOMElement $envelop */ - $envelop = $dom->childNodes->item(0); - $ns1 = $envelop->getAttribute('xmlns:ns1'); - $envelop->removeAttributeNS($ns1, 'ns1'); - $envelop->prefix = 'soap'; - - $envelop->setAttribute('soap:encodingStyle', 'http://schemas.xmlsoap.org/soap/encoding/'); - $envelop->setAttribute('xmlns:soapenc', 'http://schemas.xmlsoap.org/soap/encoding/'); - $envelop->setAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema'); - $envelop->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance'); - - /** @var \DOMElement $body */ - $body = $envelop->childNodes->item(0); - $body->prefix = 'soap'; - - /** @var \DOMElement $responseRoot */ - $responseRoot = $body->childNodes->item(0); - $responseRoot->setAttribute('xmlns', $ns1); - - $envelop->removeAttributeNS('http://schemas.xmlsoap.org/soap/envelope/', 'SOAP-ENV'); - $envelop->removeAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'SOAP-ENC'); - - $response = $dom->saveXML(); - - $response = preg_replace('/xsi:type="ns1:\w*"/', '', $response); - // Remove headers added by SoapServer::handle() method header_remove('Content-Length'); header_remove('Content-Type'); @@ -159,9 +131,7 @@ class SoapServer extends \SoapServer /** * Configure filter and type converter for SwA/MTOM. * - * @param array &$options SOAP constructor options array. - * - * @return void + * @param array &$options SOAP constructor options array */ private function configureMime(array &$options) { @@ -185,11 +155,11 @@ class SoapServer extends \SoapServer } $options['typemap'][] = array( 'type_name' => $converter->getTypeName(), - 'type_ns' => $converter->getTypeNamespace(), - 'from_xml' => function($input) use ($converter) { + 'type_ns' => $converter->getTypeNamespace(), + 'from_xml' => function ($input) use ($converter) { return $converter->convertXmlToPhp($input); }, - 'to_xml' => function($input) use ($converter) { + 'to_xml' => function ($input) use ($converter) { return $converter->convertPhpToXml($input); }, );