From 887169de13a32050e202514c77010cd2060de292 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sun, 17 Jul 2011 12:35:47 +0200 Subject: [PATCH] Added debug parameter at SoapServerFactory If kernel.debug parameter is true, the cache is disabled. --- Resources/config/webservice.xml | 1 + Soap/SoapServerFactory.php | 29 +++++++++++++++-------------- WebServiceContext.php | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Resources/config/webservice.xml b/Resources/config/webservice.xml index ebd14d4..d0fdbd1 100644 --- a/Resources/config/webservice.xml +++ b/Resources/config/webservice.xml @@ -24,6 +24,7 @@ %webservice.cache_dir% + %kernel.debug% diff --git a/Soap/SoapServerFactory.php b/Soap/SoapServerFactory.php index d81ec7f..1666a8c 100644 --- a/Soap/SoapServerFactory.php +++ b/Soap/SoapServerFactory.php @@ -23,34 +23,35 @@ class SoapServerFactory private $definition; private $converters; private $wsdlFile; + private $debug; - public function __construct(ServiceDefinition $definition, $wsdlFile, ConverterRepository $converters) + public function __construct(ServiceDefinition $definition, $wsdlFile, ConverterRepository $converters, $debug = false) { $this->definition = $definition; $this->wsdlFile = $wsdlFile; $this->converters = $converters; + $this->debug = $debug; } public function create($request, $response) { - $server = new \SoapServer( + return new \SoapServer( $this->wsdlFile, array( - 'classmap' => $this->createSoapServerClassmap(), - 'typemap' => $this->createSoapServerTypemap($request, $response), - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, + 'classmap' => $this->createSoapServerClassmap(), + 'typemap' => $this->createSoapServerTypemap($request, $response), + 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, + 'cache_wsdl' => $this->debug ? WSDL_CACHE_NONE : WSDL_CACHE_DISK, ) ); - - return $server; } private function createSoapServerTypemap($request, $response) { - $result = array(); + $typemap = array(); foreach($this->converters->getTypeConverters() as $typeConverter) { - $result[] = array( + $typemap[] = array( 'type_name' => $typeConverter->getTypeName(), 'type_ns' => $typeConverter->getTypeNamespace(), 'from_xml' => function($input) use ($request, $typeConverter) { @@ -62,24 +63,24 @@ class SoapServerFactory ); } - return $result; + return $typemap; } private function createSoapServerClassmap() { - $result = array(); + $classmap = array(); foreach($this->definition->getHeaders() as $header) { - $this->addSoapServerClassmapEntry($result, $header->getType()); + $this->addSoapServerClassmapEntry($classmap, $header->getType()); } foreach($this->definition->getMethods() as $method) { foreach($method->getArguments() as $arg) { - $this->addSoapServerClassmapEntry($result, $arg->getType()); + $this->addSoapServerClassmapEntry($classmap, $arg->getType()); } } - return $result; + return $classmap; } private function addSoapServerClassmapEntry(&$classmap, Type $type) diff --git a/WebServiceContext.php b/WebServiceContext.php index f421595..af14ee7 100644 --- a/WebServiceContext.php +++ b/WebServiceContext.php @@ -95,7 +95,7 @@ class WebServiceContext public function getServerFactory() { if (null === $this->serverFactory) { - $this->serverFactory = new SoapServerFactory($this->getServiceDefinition(), $this->getWsdlFile(), $this->converterRepository); + $this->serverFactory = new SoapServerFactory($this->getServiceDefinition(), $this->getWsdlFile(), $this->converterRepository, $this->options['debug']); } return $this->serverFactory;