diff --git a/Controller/SoapWebServiceController.php b/Controller/SoapWebServiceController.php index fc93eb8..fee611d 100644 --- a/Controller/SoapWebServiceController.php +++ b/Controller/SoapWebServiceController.php @@ -58,9 +58,11 @@ class SoapWebServiceController extends ContainerAware $this->serviceBinder = $webServiceContext->getServiceBinder(); $this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request')); - $this->soapServer = $webServiceContext->getServerFactory()->create($this->soapRequest, $this->getResponse()); - - $this->soapServer->setObject($this); + $this->soapServer = $webServiceContext + ->getServerBuilder() + ->withHandler($this) + ->build() + ; ob_start(); $this->soapServer->handle($this->soapRequest->getSoapMessage()); diff --git a/Soap/SoapServerFactory.php b/Soap/SoapServerFactory.php deleted file mode 100644 index caa133f..0000000 --- a/Soap/SoapServerFactory.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - -namespace BeSimple\SoapBundle\Soap; - -use BeSimple\SoapCommon\Cache; -use BeSimple\SoapCommon\Classmap; -use BeSimple\SoapCommon\Converter\TypeConverterCollection; - -use Zend\Soap\Wsdl; - -/** - * @author Christian Kerl - */ -class SoapServerFactory -{ - private $wsdlFile; - private $classmap; - private $converters; - private $options; - - public function __construct($wsdlFile, Classmap $classmap, TypeConverterCollection $converters, array $options = array()) - { - $this->wsdlFile = $wsdlFile; - $this->classmap = $classmap; - $this->converters = $converters; - - $this->setOptions($options); - } - - public function setOptions(array $options) - { - $this->options = array( - 'debug' => false, - 'cache_type' => null, - ); - - // check option names and live merge, if errors are encountered Exception will be thrown - $invalid = array(); - $isInvalid = false; - foreach ($options as $key => $value) { - if (array_key_exists($key, $this->options)) { - $this->options[$key] = $value; - } else { - $isInvalid = true; - $invalid[] = $key; - } - } - - if ($isInvalid) { - throw new \InvalidArgumentException(sprintf( - 'The "%s" class does not support the following options: "%s".', - get_class($this), - implode('\', \'', $invalid) - )); - } - } - - public function create($request, $response) - { - return new \SoapServer( - $this->wsdlFile, - array( - 'classmap' => $this->classmap->all(), - 'typemap' => $this->converters->getTypemap(), - 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, - 'cache_wsdl' => null !== $this->options['cache_type'] ? $this->options['cache_type'] : Cache::getType(), - ) - ); - } -} diff --git a/WebServiceContext.php b/WebServiceContext.php index 666c806..eaeb588 100644 --- a/WebServiceContext.php +++ b/WebServiceContext.php @@ -14,10 +14,10 @@ use BeSimple\SoapBundle\Converter\TypeRepository; use BeSimple\SoapBundle\ServiceBinding\MessageBinderInterface; use BeSimple\SoapBundle\ServiceBinding\ServiceBinder; use BeSimple\SoapBundle\ServiceDefinition\Dumper\DumperInterface; -use BeSimple\SoapBundle\Soap\SoapServerFactory; use BeSimple\SoapCommon\Classmap; use BeSimple\SoapCommon\Converter\TypeConverterCollection; +use BeSimple\SoapServer\SoapServerBuilder; use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\Loader\LoaderInterface; @@ -38,7 +38,7 @@ class WebServiceContext private $serviceDefinition; private $serviceBinder; - private $serverFactory; + private $serverBuilder; public function __construct(LoaderInterface $loader, DumperInterface $dumper, Classmap $classmap, TypeRepository $typeRepository, TypeConverterCollection $converters, array $options) { $this->loader = $loader; @@ -100,20 +100,22 @@ class WebServiceContext return $this->serviceBinder; } - public function getServerFactory() + public function getServerBuilder() { - if (null === $this->serverFactory) { - $this->serverFactory = new SoapServerFactory( - $this->getWsdlFile(), - $this->classmap, - $this->converters, - array( - 'debug' => $this->options['debug'], - 'cache_type' => isset($this->options['cache_type']) ? $this->options['cache_type'] : null, - ) - ); + if (null === $this->serverBuilder) { + $this->serverBuilder = SoapServerBuilder::createWithDefaults() + ->withWsdl($this->getWsdlFile()) + ->withClassmap($this->classmap) + ->withTypeConverters($this->converters) + ; + + if (!$this->options['debug']) { + $this->serverBuilder->withWsdlCacheNone(); + } elseif (null !== $this->options['cache_type']) { + $this->serverBuilder->withWsdlCache($this->options['cache_type']); + } } - return $this->serverFactory; + return $this->serverBuilder; } } \ No newline at end of file