From ae746087e625f928d7585d376500c3fde6e0fe08 Mon Sep 17 00:00:00 2001 From: Ghislain Loaec Date: Fri, 6 Apr 2018 10:12:08 +0200 Subject: [PATCH] Test With Legacy bundle --- src/BeSimple/SoapBundle/Cache.php | 40 ++----- .../Controller/SoapWebServiceController.php | 15 +-- .../Converter/XopIncludeTypeConverter.php | 4 +- .../BeSimpleSoapExtension.php | 103 +++++++----------- .../DependencyInjection/Configuration.php | 4 - .../SoapBundle/Handler/ExceptionHandler.php | 7 +- .../SoapBundle/Resources/config/client.xml | 28 ++--- .../config/routing/webservicecontroller.xml | 4 +- .../SoapBundle/Resources/config/soap.xml | 29 ++--- .../Resources/config/webservice.xml | 2 +- .../soapserver/tutorial/associative_array.rst | 8 +- .../SoapBundle/Soap/SoapAttachmentList.php | 36 ------ .../SoapBundle/Soap/SoapClientBuilder.php | 77 +++++++++++++ .../Util/{StringUtility.php => String.php} | 4 +- src/BeSimple/SoapBundle/WebServiceContext.php | 23 ++-- 15 files changed, 183 insertions(+), 201 deletions(-) delete mode 100644 src/BeSimple/SoapBundle/Soap/SoapAttachmentList.php create mode 100644 src/BeSimple/SoapBundle/Soap/SoapClientBuilder.php rename src/BeSimple/SoapBundle/Util/{StringUtility.php => String.php} (94%) diff --git a/src/BeSimple/SoapBundle/Cache.php b/src/BeSimple/SoapBundle/Cache.php index 510b35f..fe5621f 100644 --- a/src/BeSimple/SoapBundle/Cache.php +++ b/src/BeSimple/SoapBundle/Cache.php @@ -13,45 +13,27 @@ namespace BeSimple\SoapBundle; use BeSimple\SoapCommon\Cache as BaseCache; -use BeSimple\SoapCommon\SoapOptions\SoapOptions; -use Exception; /** * @author Francis Besset */ class Cache { - public function __construct(SoapOptions $soapOptions) + public function __construct($cacheDisabled, $type, $directory, $lifetime = null, $limit = null) { - if ($soapOptions->isWsdlCached()) { - $isEnabled = (bool)$soapOptions->isWsdlCached() ? BaseCache::ENABLED : BaseCache::DISABLED; + $isEnabled = (Boolean) $cacheDisabled ? BaseCache::DISABLED : BaseCache::ENABLED; - BaseCache::setEnabled($isEnabled); - BaseCache::setType($soapOptions->getWsdlCacheType()); - BaseCache::setDirectory($soapOptions->getWsdlCacheDir()); - } else { - BaseCache::setEnabled(BaseCache::DISABLED); - BaseCache::setType(SoapOptions::SOAP_CACHE_TYPE_NONE); - BaseCache::setDirectory(null); + BaseCache::setEnabled($isEnabled); + + BaseCache::setType($type); + BaseCache::setDirectory($directory); + + if (null !== $lifetime) { + BaseCache::setLifetime($lifetime); } - } - public function validateSettings(SoapOptions $soapOptions) - { - if ($soapOptions->isWsdlCached()) { - if (BaseCache::isEnabled() !== true) { - throw new Exception('WSDL cache could not be set'); - } - if ($soapOptions->getWsdlCacheType() !== (int)BaseCache::getType()) { - throw new Exception('WSDL cache type could not be set, ini settings is: '.BaseCache::getType()); - } - if ($soapOptions->getWsdlCacheDir() !== BaseCache::getDirectory()) { - throw new Exception('WSDL cache dir could not be set, real dir is: '.BaseCache::getDirectory()); - } - } else { - if (BaseCache::isEnabled() !== false) { - throw new Exception('WSDL cache could not be turned off'); - } + if (null !== $limit) { + BaseCache::setLimit($limit); } } } diff --git a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php index 53af035..29d08c3 100644 --- a/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php +++ b/src/BeSimple/SoapBundle/Controller/SoapWebServiceController.php @@ -16,11 +16,10 @@ use BeSimple\SoapBundle\Handler\ExceptionHandler; use BeSimple\SoapBundle\Soap\SoapRequest; use BeSimple\SoapBundle\Soap\SoapResponse; use BeSimple\SoapServer\SoapServerBuilder; -use Symfony\Component\Debug\Exception\FlattenException; -use Symfony\Component\DependencyInjection\ContainerAwareInterface; -use Symfony\Component\DependencyInjection\ContainerAwareTrait; +use Symfony\Component\DependencyInjection\ContainerAware; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\FlattenException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; @@ -29,10 +28,8 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; * @author Christian Kerl * @author Francis Besset */ -class SoapWebServiceController implements ContainerAwareInterface +class SoapWebServiceController extends ContainerAware { - use ContainerAwareTrait; - /** * @var \SoapServer */ @@ -67,7 +64,7 @@ class SoapWebServiceController implements ContainerAwareInterface $this->serviceBinder = $webServiceContext->getServiceBinder(); - $this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request_stack')->getCurrentRequest()); + $this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request')); $this->soapServer = $webServiceContext ->getServerBuilder() ->withSoapVersion11() @@ -141,8 +138,8 @@ class SoapWebServiceController implements ContainerAwareInterface $request->query->remove('_besimple_soap_fault'); } - $server = SoapServerBuilder::createWithDefaults(__DIR__.'/../Handler/wsdl/exception.wsdl') - ->withWsdl() + $server = SoapServerBuilder::createWithDefaults() + ->withWsdl(__DIR__.'/../Handler/wsdl/exception.wsdl') ->withWsdlCacheNone() ->withHandler($handler) ->build() diff --git a/src/BeSimple/SoapBundle/Converter/XopIncludeTypeConverter.php b/src/BeSimple/SoapBundle/Converter/XopIncludeTypeConverter.php index d0dcc5b..b83e38d 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\StringUtility; +use BeSimple\SoapBundle\Util\String; use BeSimple\SoapCommon\Converter\TypeConverterInterface; /** @@ -40,7 +40,7 @@ class XopIncludeTypeConverter implements TypeConverterInterface $ref = $include->getAttribute('href'); - if (StringUtility::startsWith($ref, 'cid:')) { + if (String::startsWith($ref, 'cid:')) { $cid = urldecode(substr($ref, 4)); return $request->getSoapAttachments()->get($cid)->getContent(); diff --git a/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php b/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php index 413e1ca..4e2b47a 100644 --- a/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php +++ b/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php @@ -14,8 +14,6 @@ namespace BeSimple\SoapBundle\DependencyInjection; use BeSimple\SoapCommon\Cache; -use BeSimple\SoapCommon\SoapOptions\SoapOptions; -use Carpages\Core\Entity\ContactPhone; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -43,7 +41,6 @@ class BeSimpleSoapExtension extends Extension $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('request.xml'); - $loader->load('soap.xml'); $loader->load('loaders.xml'); $loader->load('converters.xml'); @@ -56,8 +53,8 @@ class BeSimpleSoapExtension extends Extension $this->registerCacheConfiguration($config['cache'], $container, $loader); - if ( ! empty($config['clients'])) { - $this->registerClientConfiguration($config, $container, $loader); + if (!empty($config['clients'])) { + $this->registerClientConfiguration($config['clients'], $container, $loader); } $container->setParameter('besimple.soap.definition.dumper.options.stylesheet', $config['wsdl_dumper']['stylesheet']); @@ -72,9 +69,11 @@ class BeSimpleSoapExtension extends Extension private function registerCacheConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { + $loader->load('soap.xml'); + $config['type'] = $this->getCacheType($config['type']); - foreach (array('type', 'file') as $key) { + foreach (array('type', 'lifetime', 'limit') as $key) { $container->setParameter('besimple.soap.cache.'.$key, $config[$key]); } } @@ -83,33 +82,22 @@ class BeSimpleSoapExtension extends Extension { $loader->load('client.xml'); - foreach ($config['clients'] as $client => $options) { - $soapClientOpts = new DefinitionDecorator('besimple.soap.client_options'); - $soapOpts = new DefinitionDecorator('besimple.soap.options'); + foreach ($config as $client => $options) { + $definition = new DefinitionDecorator('besimple.soap.client.builder'); + $container->setDefinition(sprintf('besimple.soap.client.builder.%s', $client), $definition); - $soapClientOptsService = sprintf('besimple.soap.client_options.%s', $client); - $soapOptsService = sprintf('besimple.soap.options.%s', $client); + $definition->replaceArgument(0, $options['wsdl']); - // configure SoapClient - $definition = new DefinitionDecorator('besimple.soap.client'); + $defOptions = $container + ->getDefinition('besimple.soap.client.builder') + ->getArgument(1); - $container->setDefinition( - sprintf('besimple.soap.client.%s', $client), - $definition - ); - $container->setDefinition( - $soapClientOptsService, - $soapClientOpts - ); - $container->setDefinition( - $soapOptsService, - $soapOpts - ); + foreach (array('cache_type', 'user_agent') as $key) { + if (isset($options[$key])) { + $defOptions[$key] = $options[$key]; + } + } - $definition->replaceArgument(0, new Reference($soapClientOptsService)); - $definition->replaceArgument(1, new Reference($soapOptsService)); - - // configure proxy $proxy = $options['proxy']; if (false !== $proxy['host']) { if (null !== $proxy['auth']) { @@ -120,58 +108,49 @@ class BeSimpleSoapExtension extends Extension } } - $proxy = $this->createClientProxy($client, $proxy, $container); - $soapClientOpts->setFactory([ - '%besimple.soap.client_options_builder.class%', - 'createWithProxy' - ]); - $soapClientOpts->setArgument(0, new Reference($proxy)); + $definition->addMethodCall('withProxy', array( + $proxy['host'], $proxy['port'], + $proxy['login'], $proxy['password'], + $proxy['auth'] + )); } - // configure SoapOptions for client - $classMap = $this->createClientClassMap($client, $options['classmap'], $container); - - $soapOpts->replaceArgument(0, $config['cache']['file']); - $soapOpts->replaceArgument(1, new Reference($classMap)); - $soapOpts->replaceArgument(2, $this->getCacheType($config['cache']['type'])); - - if ($config['cache']['version'] == SoapOptions::SOAP_VERSION_1_1) { - $soapOpts->setFactory([ - '%besimple.soap.options_builder.class%', - 'createWithClassMapV11' - ]); + if (isset($defOptions['cache_type'])) { + $defOptions['cache_type'] = $this->getCacheType($defOptions['cache_type']); } + + $definition->replaceArgument(1, $defOptions); + + $classmap = $this->createClientClassmap($client, $options['classmap'], $container); + $definition->replaceArgument(2, new Reference($classmap)); + + $this->createClient($client, $container); } } - private function createClientClassMap($client, array $classmap, ContainerBuilder $container) + private function createClientClassmap($client, array $classmap, ContainerBuilder $container) { $definition = new DefinitionDecorator('besimple.soap.classmap'); $container->setDefinition(sprintf('besimple.soap.classmap.%s', $client), $definition); - if ( ! empty($classmap)) { + if (!empty($classmap)) { $definition->setMethodCalls(array( - array('__construct', array($classmap)), + array('set', array($classmap)), )); } return sprintf('besimple.soap.classmap.%s', $client); } - private function createClientProxy($client, array $proxy, ContainerBuilder $container) + private function createClient($client, ContainerBuilder $container) { - $definition = new DefinitionDecorator('besimple.soap.client.proxy'); - $container->setDefinition(sprintf('besimple.soap.client.proxy.%s', $client), $definition); + $definition = new DefinitionDecorator('besimple.soap.client'); + $container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition); - if ( ! empty($proxy)) { - $definition->replaceArgument(0, $proxy['host']); - $definition->replaceArgument(1, $proxy['port']); - $definition->replaceArgument(2, $proxy['login']); - $definition->replaceArgument(3, $proxy['password']); - $definition->replaceArgument(4, $proxy['auth']); - } - - return sprintf('besimple.soap.client.proxy.%s', $client); + $definition->setFactory(array( + new Reference(sprintf('besimple.soap.client.builder.%s', $client)), + 'build' + )); } private function createWebServiceContext(array $config, ContainerBuilder $container) diff --git a/src/BeSimple/SoapBundle/DependencyInjection/Configuration.php b/src/BeSimple/SoapBundle/DependencyInjection/Configuration.php index dd22b42..9374bff 100644 --- a/src/BeSimple/SoapBundle/DependencyInjection/Configuration.php +++ b/src/BeSimple/SoapBundle/DependencyInjection/Configuration.php @@ -64,10 +64,6 @@ class Configuration ->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes))) ->end() ->end() - ->scalarNode('version')->defaultNull()->end() - ->scalarNode('encoding')->defaultNull()->end() - ->scalarNode('keepalive')->defaultNull()->end() - ->scalarNode('file')->defaultNull()->end() ->scalarNode('lifetime')->defaultNull()->end() ->scalarNode('limit')->defaultNull()->end() ->end() diff --git a/src/BeSimple/SoapBundle/Handler/ExceptionHandler.php b/src/BeSimple/SoapBundle/Handler/ExceptionHandler.php index 7a95152..54c12b4 100644 --- a/src/BeSimple/SoapBundle/Handler/ExceptionHandler.php +++ b/src/BeSimple/SoapBundle/Handler/ExceptionHandler.php @@ -12,9 +12,9 @@ namespace BeSimple\SoapBundle\Handler; -use SoapFault; -use Symfony\Component\Debug\Exception\FlattenException; +use BeSimple\SoapServer\Exception\ReceiverSoapFault; use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\HttpKernel\Exception\FlattenException; /** * @author Francis Besset @@ -44,8 +44,7 @@ class ExceptionHandler $code = $this->exception->getStatusCode(); - throw new SoapFault( - 'receiver', + throw new ReceiverSoapFault( isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', null, $this->details diff --git a/src/BeSimple/SoapBundle/Resources/config/client.xml b/src/BeSimple/SoapBundle/Resources/config/client.xml index 87b2f37..b1e1d3e 100644 --- a/src/BeSimple/SoapBundle/Resources/config/client.xml +++ b/src/BeSimple/SoapBundle/Resources/config/client.xml @@ -4,26 +4,26 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - BeSimple\SoapClient\SoapClientBuilder - BeSimple\SoapClient\SoapClient - BeSimple\SoapClient\SoapServerProxy\SoapServerProxy + BeSimple\SoapBundle\Soap\SoapClientBuilder + BeSimple\SoapCommon\Classmap - - - - - + + + + %kernel.debug% + + + + - - - - - - + + + + diff --git a/src/BeSimple/SoapBundle/Resources/config/routing/webservicecontroller.xml b/src/BeSimple/SoapBundle/Resources/config/routing/webservicecontroller.xml index cd370b9..98e80e4 100644 --- a/src/BeSimple/SoapBundle/Resources/config/routing/webservicecontroller.xml +++ b/src/BeSimple/SoapBundle/Resources/config/routing/webservicecontroller.xml @@ -4,13 +4,13 @@ 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 diff --git a/src/BeSimple/SoapBundle/Resources/config/soap.xml b/src/BeSimple/SoapBundle/Resources/config/soap.xml index 4ed2e29..28a7b1b 100644 --- a/src/BeSimple/SoapBundle/Resources/config/soap.xml +++ b/src/BeSimple/SoapBundle/Resources/config/soap.xml @@ -1,31 +1,20 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - BeSimple\SoapCommon\ClassMap - BeSimple\SoapClient\SoapOptions\SoapClientOptions - BeSimple\SoapClient\SoapClientOptionsBuilder - BeSimple\SoapCommon\SoapOptions\SoapOptions - BeSimple\SoapCommon\SoapOptionsBuilder - %kernel.cache_dir% + BeSimple\SoapBundle\Cache + %kernel.cache_dir%/besimple/soap - - - - - - - - - - %besimple.soap.cache.file% - + + %kernel.debug% %besimple.soap.cache.type% - %besimple.soap.cache.dir% + %besimple.soap.cache.dir%/cache + %besimple.soap.cache.lifetime% + %besimple.soap.cache.limit% diff --git a/src/BeSimple/SoapBundle/Resources/config/webservice.xml b/src/BeSimple/SoapBundle/Resources/config/webservice.xml index de24fce..343885c 100644 --- a/src/BeSimple/SoapBundle/Resources/config/webservice.xml +++ b/src/BeSimple/SoapBundle/Resources/config/webservice.xml @@ -15,7 +15,7 @@ BeSimple\SoapBundle\ServiceBinding\DocumentLiteralWrappedRequestHeaderMessageBinder BeSimple\SoapBundle\ServiceBinding\DocumentLiteralWrappedResponseMessageBinder BeSimple\SoapCommon\Definition\Type\TypeRepository - BeSimple\SoapCommon\ClassMap + BeSimple\SoapServer\Classmap diff --git a/src/BeSimple/SoapBundle/Resources/doc/soapserver/tutorial/associative_array.rst b/src/BeSimple/SoapBundle/Resources/doc/soapserver/tutorial/associative_array.rst index 119c210..045cb5b 100644 --- a/src/BeSimple/SoapBundle/Resources/doc/soapserver/tutorial/associative_array.rst +++ b/src/BeSimple/SoapBundle/Resources/doc/soapserver/tutorial/associative_array.rst @@ -7,7 +7,7 @@ Pre-existent Type +------------------------------------------------+-----------------+ | Php Type | Value Type | +================================================+=================+ -| BeSimple\\SoapCommon\\Type\\KeyValue\\StringUtility | StringUtility | +| BeSimple\\SoapCommon\\Type\\KeyValue\\String | String | +------------------------------------------------+-----------------+ | BeSimple\\SoapCommon\\Type\\KeyValue\\Boolean | Boolean | +------------------------------------------------+-----------------+ @@ -34,7 +34,7 @@ Controller { /** * @Soap\Method("returnAssocArray") - * @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\StringUtility[]") + * @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]") */ public function assocArrayOfStringAction() { @@ -46,8 +46,8 @@ Controller /** * @Soap\Method("sendAssocArray") - * @Soap\Param("assocArray", phpType = "BeSimple\SoapCommon\Type\KeyValue\StringUtility[]") - * @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\StringUtility[]") + * @Soap\Param("assocArray", phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]") + * @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]") */ public function sendAssocArrayOfStringAction(array $assocArray) { diff --git a/src/BeSimple/SoapBundle/Soap/SoapAttachmentList.php b/src/BeSimple/SoapBundle/Soap/SoapAttachmentList.php deleted file mode 100644 index e65503a..0000000 --- a/src/BeSimple/SoapBundle/Soap/SoapAttachmentList.php +++ /dev/null @@ -1,36 +0,0 @@ -soapAttachments = $soapAttachments; - } - - public function hasSoapAttachments() - { - return $this->soapAttachments !== null && count($this->soapAttachments) > 0; - } - - public function getSoapAttachments() - { - return $this->soapAttachments; - } - - public function getSoapAttachmentIds() - { - $ids = []; - foreach ($this->getSoapAttachments() as $soapAttachment) { - $ids[] = $soapAttachment->getId(); - } - - return $ids; - } -} diff --git a/src/BeSimple/SoapBundle/Soap/SoapClientBuilder.php b/src/BeSimple/SoapBundle/Soap/SoapClientBuilder.php new file mode 100644 index 0000000..977b92b --- /dev/null +++ b/src/BeSimple/SoapBundle/Soap/SoapClientBuilder.php @@ -0,0 +1,77 @@ +checkOptions($options); + + $this + ->withWsdl($wsdl) + ->withTrace($options['debug']) + ; + + if (isset($options['user_agent'])) { + $this->withUserAgent($options['user_agent']); + } + + if (isset($options['cache_type'])) { + $this->withWsdlCache($options['cache_type']); + } + + if ($classmap) { + $this->withClassmap($classmap); + } + + if ($converters) { + $this->withTypeConverters($converters); + } + } + + public function build() + { + if (!$this->soapClient) { + $this->soapClient = parent::build(); + } + + return $this->soapClient; + } + + protected function checkOptions(array $options) + { + $checkOptions = array( + 'debug' => false, + 'cache_type' => null, + 'exceptions' => true, + 'user_agent' => 'BeSimpleSoap', + ); + + // 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, $checkOptions)) { + $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) + )); + } + } +} diff --git a/src/BeSimple/SoapBundle/Util/StringUtility.php b/src/BeSimple/SoapBundle/Util/String.php similarity index 94% rename from src/BeSimple/SoapBundle/Util/StringUtility.php rename to src/BeSimple/SoapBundle/Util/String.php index d3664b0..b95d53e 100644 --- a/src/BeSimple/SoapBundle/Util/StringUtility.php +++ b/src/BeSimple/SoapBundle/Util/String.php @@ -11,11 +11,11 @@ namespace BeSimple\SoapBundle\Util; /** - * StringUtility provides utility methods for strings. + * String provides utility methods for strings. * * @author Christian Kerl */ -class StringUtility +class String { /** * Checks if a string starts with a given string. diff --git a/src/BeSimple/SoapBundle/WebServiceContext.php b/src/BeSimple/SoapBundle/WebServiceContext.php index 20c0dde..dce81a7 100644 --- a/src/BeSimple/SoapBundle/WebServiceContext.php +++ b/src/BeSimple/SoapBundle/WebServiceContext.php @@ -13,8 +13,6 @@ namespace BeSimple\SoapBundle; use BeSimple\SoapBundle\ServiceBinding\ServiceBinder; use BeSimple\SoapCommon\Converter\TypeConverterCollection; -use BeSimple\SoapCommon\SoapOptionsBuilder; -use BeSimple\SoapServer\SoapServerOptionsBuilder; use BeSimple\SoapWsdl\Dumper\Dumper; use BeSimple\SoapServer\SoapServerBuilder; use Symfony\Component\Config\ConfigCache; @@ -46,7 +44,7 @@ class WebServiceContext if (null === $this->serviceDefinition) { $cache = new ConfigCache(sprintf('%s/%s.definition.php', $this->options['cache_dir'], $this->options['name']), $this->options['debug']); if ($cache->isFresh()) { - $this->serviceDefinition = include $cache->getPath(); + $this->serviceDefinition = include (string) $cache; } else { if (!$this->loader->supports($this->options['resource'], $this->options['resource_type'])) { throw new \LogicException(sprintf('Cannot load "%s" (%s)', $this->options['resource'], $this->options['resource_type'])); @@ -84,7 +82,7 @@ class WebServiceContext $cache->write($dumper->dump()); } - return $cache->getPath(); + return (string) $cache; } public function getServiceBinder() @@ -104,14 +102,15 @@ class WebServiceContext public function getServerBuilder() { if (null === $this->serverBuilder) { - $soapServerBuilder = new SoapServerBuilder(); - $this->serverBuilder = $soapServerBuilder->build( - SoapServerOptionsBuilder::createWithDefaults(), - SoapOptionsBuilder::createWithClassMap( - $this->getWsdlFile(), - $this->getServiceDefinition()->getTypeRepository()->getClassmap() - ) - ); + $this->serverBuilder = SoapServerBuilder::createWithDefaults() + ->withWsdl($this->getWsdlFile()) + ->withClassmap($this->getServiceDefinition()->getTypeRepository()->getClassmap()) + ->withTypeConverters($this->converters) + ; + + if (null !== $this->options['cache_type']) { + $this->serverBuilder->withWsdlCache($this->options['cache_type']); + } } return $this->serverBuilder;