From 17fdd6448907adf085265bc0fbf90362bc714238 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sat, 3 Sep 2011 21:17:57 +0200 Subject: [PATCH 01/20] Added soap client --- DependencyInjection/BeSimpleSoapExtension.php | 16 ++++++++++++++++ DependencyInjection/Configuration.php | 18 ++++++++++++++++++ Resources/config/client.xml | 19 +++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 Resources/config/client.xml diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index 5870366..9b492b7 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -44,6 +44,10 @@ class BeSimpleSoapExtension extends Extension $config = $processor->process($configuration->getConfigTree(), $configs); + if (isset($config['clients'])) { + $this->registerClientConfiguration($config['clients'], $container, $loader); + } + $container->setParameter('besimple.soap.definition.dumper.options.stylesheet', $config['wsdl_dumper']['stylesheet']); foreach($config['services'] as $name => $serviceConfig) { @@ -52,6 +56,18 @@ class BeSimpleSoapExtension extends Extension } } + private function registerClientConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) + { + $loader->load('client.xml'); + + foreach ($config as $client => $options) { + $definition = new DefinitionDecorator('besimple.soap.client'); + $context = $container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition); + + $definition->replaceArgument(0, $options['wsdl']); + } + } + private function createWebServiceContext(array $config, ContainerBuilder $container) { $bindingSuffix = $this->bindingConfigToServiceSuffixMap[$config['binding']]; diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 0f538cc..2228f37 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -30,12 +30,30 @@ class Configuration $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('be_simple_soap'); + $this->addClientSection($rootNode); $this->addServicesSection($rootNode); $this->addWsdlDumperSection($rootNode); return $treeBuilder->buildTree(); } + private function addClientSection(ArrayNodeDefinition $rootNode) + { + $rootNode + ->children() + ->arrayNode('clients') + ->useAttributeAsKey('name') + ->prototype('array') + ->children() + ->scalarNode('wsdl') + ->isRequired() + ->end() + ->end() + ->end() + ->end() + ; + } + private function addServicesSection(ArrayNodeDefinition $rootNode) { $rootNode diff --git a/Resources/config/client.xml b/Resources/config/client.xml new file mode 100644 index 0000000..1fc90f1 --- /dev/null +++ b/Resources/config/client.xml @@ -0,0 +1,19 @@ + + + + + BeSimple\SoapClient\Soap\SoapClient + + + + + wsdl + + %kernel.debug% + + + + + From 502ba419351745d6ab4297596e74b0e9559cc5c0 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sun, 4 Sep 2011 00:48:45 +0200 Subject: [PATCH 02/20] Updated namespace for soap client --- Resources/config/client.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/config/client.xml b/Resources/config/client.xml index 1fc90f1..405a4de 100644 --- a/Resources/config/client.xml +++ b/Resources/config/client.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - BeSimple\SoapClient\Soap\SoapClient + BeSimple\SoapClient\SoapClient From 1a4e9246db265cc5f5656d0a607e729dd970ee76 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sun, 4 Sep 2011 01:59:32 +0200 Subject: [PATCH 03/20] Added besimple.soap.cache service --- Cache.php | 39 +++++++++++++++++++ DependencyInjection/BeSimpleSoapExtension.php | 34 ++++++++++++++++ DependencyInjection/Configuration.php | 25 ++++++++++++ Resources/config/client.xml | 1 + Resources/config/soap.xml | 21 ++++++++++ Resources/config/webservice.xml | 2 + Soap/SoapServerFactory.php | 3 +- 7 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 Cache.php create mode 100644 Resources/config/soap.xml diff --git a/Cache.php b/Cache.php new file mode 100644 index 0000000..71d8927 --- /dev/null +++ b/Cache.php @@ -0,0 +1,39 @@ + + * (c) Francis Besset + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace BeSimple\SoapBundle; + +use BeSimple\SoapCommon\Cache as BaseCache; + +/** + * @author Francis Besset + */ +class Cache +{ + public function __construct($disabled, $type, $directory, $lifetime = null, $limit = null) + { + BaseCache::setEnabled(!$disabled); + + if (BaseCache::ENABLED == BaseCache::isEnabled()) { + BaseCache::setType($type); + BaseCache::setDirectory($directory); + + if (null !== $lifetime) { + BaseCache::setLifetime($lifetime); + } + + if (null !== $limit) { + BaseCache::setLimit($limit); + } + } + } +} \ No newline at end of file diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index 9b492b7..5abd6de 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -1,8 +1,10 @@ + * (c) Francis Besset * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. @@ -10,6 +12,8 @@ namespace BeSimple\SoapBundle\DependencyInjection; +use BeSimple\SoapCommon\Cache; + use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -22,6 +26,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension; * BeSimpleSoapExtension. * * @author Christian Kerl + * @author Francis Besset */ class BeSimpleSoapExtension extends Extension { @@ -44,6 +49,8 @@ class BeSimpleSoapExtension extends Extension $config = $processor->process($configuration->getConfigTree(), $configs); + $this->registerCacheConfiguration($config['cache'], $container, $loader); + if (isset($config['clients'])) { $this->registerClientConfiguration($config['clients'], $container, $loader); } @@ -56,6 +63,33 @@ class BeSimpleSoapExtension extends Extension } } + private function registerCacheConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) + { + $loader->load('soap.xml'); + + switch ($config['type']) { + case 'none': + $config['type'] = Cache::TYPE_NONE; + break; + + case 'disk': + $config['type'] = Cache::TYPE_DISK; + break; + + case 'memory': + $config['type'] = Cache::TYPE_MEMORY; + break; + + case 'disk_memory': + $config['type'] = Cache::TYPE_DISK_MEMORY; + break; + } + + foreach (array('type', 'lifetime', 'limit') as $key) { + $container->setParameter('besimple.soap.cache.'.$key, $config[$key]); + } + } + private function registerClientConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader) { $loader->load('client.xml'); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 2228f37..dde299d 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -1,8 +1,10 @@ + * (c) Francis Besset * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. @@ -17,6 +19,7 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder; * WebServiceExtension configuration structure. * * @author Christian Kerl + * @author Francis Besset */ class Configuration { @@ -30,6 +33,7 @@ class Configuration $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('be_simple_soap'); + $this->addCacheSection($rootNode); $this->addClientSection($rootNode); $this->addServicesSection($rootNode); $this->addWsdlDumperSection($rootNode); @@ -37,6 +41,27 @@ class Configuration return $treeBuilder->buildTree(); } + private function addCacheSection(ArrayNodeDefinition $rootNode) + { + $rootNode + ->children() + ->arrayNode('cache') + ->children() + ->scalarNode('type') + ->defaultValue('disk') + ->validate() + ->ifNotInArray(array('none', 'disk', 'memory', 'disk_memory')) + ->thenInvalid('The cache type has to be either "none", "disk", "memory" or "disk_memory"') + ->end() + ->end() + ->scalarNode('lifetime')->defaultNull()->end() + ->scalarNode('limit')->defaultNull()->end() + ->end() + ->end() + ->end() + ; + } + private function addClientSection(ArrayNodeDefinition $rootNode) { $rootNode diff --git a/Resources/config/client.xml b/Resources/config/client.xml index 405a4de..7869c80 100644 --- a/Resources/config/client.xml +++ b/Resources/config/client.xml @@ -13,6 +13,7 @@ %kernel.debug% + diff --git a/Resources/config/soap.xml b/Resources/config/soap.xml new file mode 100644 index 0000000..3fb3d4c --- /dev/null +++ b/Resources/config/soap.xml @@ -0,0 +1,21 @@ + + + + + BeSimple\SoapBundle\Cache + %kernel.cache_dir%/besimple/soap + + + + + %kernel.debug% + %besimple.soap.cache.type% + %besimple.soap.cache.directory% + %besimple.soap.cache.lifetime% + %besimple.soap.cache.limit% + + + + diff --git a/Resources/config/webservice.xml b/Resources/config/webservice.xml index a33b0c2..081e3b3 100644 --- a/Resources/config/webservice.xml +++ b/Resources/config/webservice.xml @@ -32,6 +32,7 @@ %besimple.soap.binder.request.rpcliteral.class% %besimple.soap.binder.response.rpcliteral.class% + @@ -46,6 +47,7 @@ %besimple.soap.binder.request.documentwrapped.class% %besimple.soap.binder.response.documentwrapped.class% + diff --git a/Soap/SoapServerFactory.php b/Soap/SoapServerFactory.php index 1e18767..eee5fd2 100644 --- a/Soap/SoapServerFactory.php +++ b/Soap/SoapServerFactory.php @@ -11,6 +11,7 @@ namespace BeSimple\SoapBundle\Soap; use BeSimple\SoapBundle\Converter\ConverterRepository; +use BeSimple\SoapCommon\Cache; use Zend\Soap\Wsdl; /** @@ -39,7 +40,7 @@ class SoapServerFactory 'classmap' => $this->classmap, 'typemap' => $this->createSoapServerTypemap($request, $response), 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, - 'cache_wsdl' => $this->debug ? WSDL_CACHE_NONE : WSDL_CACHE_DISK, + 'cache_wsdl' => Cache::getType(), ) ); } From 2ea1704a1eb94b9a1f26a395e8fae885f1a5d97d Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sun, 4 Sep 2011 02:42:53 +0200 Subject: [PATCH 04/20] Added the possibility to choice an other type cache for a client --- DependencyInjection/BeSimpleSoapExtension.php | 46 ++++++++++++------- DependencyInjection/Configuration.php | 13 +++++- Resources/config/client.xml | 1 + 3 files changed, 41 insertions(+), 19 deletions(-) diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index 5abd6de..f44f2a5 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -67,23 +67,7 @@ class BeSimpleSoapExtension extends Extension { $loader->load('soap.xml'); - switch ($config['type']) { - case 'none': - $config['type'] = Cache::TYPE_NONE; - break; - - case 'disk': - $config['type'] = Cache::TYPE_DISK; - break; - - case 'memory': - $config['type'] = Cache::TYPE_MEMORY; - break; - - case 'disk_memory': - $config['type'] = Cache::TYPE_DISK_MEMORY; - break; - } + $config['type'] = $this->getCacheType($config['type']); foreach (array('type', 'lifetime', 'limit') as $key) { $container->setParameter('besimple.soap.cache.'.$key, $config[$key]); @@ -99,6 +83,17 @@ class BeSimpleSoapExtension extends Extension $context = $container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition); $definition->replaceArgument(0, $options['wsdl']); + + if (isset($options['cache_wsdl'])) { + $options['cache_wsdl'] = $this->getCacheType($options['cache_wsdl']); + + $defOptions = $container + ->getDefinition('besimple.soap.client') + ->getArgument(1); + + $defOptions['cache_wsdl'] = $options['cache_wsdl']; + $definition->replaceArgument(1, $defOptions); + } } } @@ -117,4 +112,21 @@ class BeSimpleSoapExtension extends Extension $definition->replaceArgument(4, array_merge($options, $config)); } + + private function getCacheType($type) + { + switch ($type) { + case 'none': + return Cache::TYPE_NONE; + + case 'disk': + return Cache::TYPE_DISK; + + case 'memory': + return Cache::TYPE_MEMORY; + + case 'disk_memory': + return Cache::TYPE_DISK_MEMORY; + } + } } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index dde299d..f856ee8 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -23,6 +23,8 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder; */ class Configuration { + private $cacheTypes = array('none', 'disk', 'memory', 'disk_memory'); + /** * Generates the configuration tree. * @@ -46,12 +48,13 @@ class Configuration $rootNode ->children() ->arrayNode('cache') + ->addDefaultsIfNotSet() ->children() ->scalarNode('type') ->defaultValue('disk') ->validate() - ->ifNotInArray(array('none', 'disk', 'memory', 'disk_memory')) - ->thenInvalid('The cache type has to be either "none", "disk", "memory" or "disk_memory"') + ->ifNotInArray($this->cacheTypes) + ->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes))) ->end() ->end() ->scalarNode('lifetime')->defaultNull()->end() @@ -73,6 +76,12 @@ class Configuration ->scalarNode('wsdl') ->isRequired() ->end() + ->scalarNode('cache_wsdl') + ->validate() + ->ifNotInArray($this->cacheTypes) + ->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes))) + ->end() + ->end() ->end() ->end() ->end() diff --git a/Resources/config/client.xml b/Resources/config/client.xml index 7869c80..72acfef 100644 --- a/Resources/config/client.xml +++ b/Resources/config/client.xml @@ -12,6 +12,7 @@ wsdl %kernel.debug% + null From b1da32bc97a6560e0a1afdac4512828722acb45f Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sun, 4 Sep 2011 12:24:51 +0200 Subject: [PATCH 05/20] Renamed client cache_wsdl option to cache_type --- DependencyInjection/BeSimpleSoapExtension.php | 6 +++--- DependencyInjection/Configuration.php | 2 +- Resources/config/client.xml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index f44f2a5..e14d6df 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -84,14 +84,14 @@ class BeSimpleSoapExtension extends Extension $definition->replaceArgument(0, $options['wsdl']); - if (isset($options['cache_wsdl'])) { - $options['cache_wsdl'] = $this->getCacheType($options['cache_wsdl']); + if (isset($options['cache_type'])) { + $options['cache_type'] = $this->getCacheType($options['cache_type']); $defOptions = $container ->getDefinition('besimple.soap.client') ->getArgument(1); - $defOptions['cache_wsdl'] = $options['cache_wsdl']; + $defOptions['cache_type'] = $options['cache_type']; $definition->replaceArgument(1, $defOptions); } } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index f856ee8..a15bc22 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -76,7 +76,7 @@ class Configuration ->scalarNode('wsdl') ->isRequired() ->end() - ->scalarNode('cache_wsdl') + ->scalarNode('cache_type') ->validate() ->ifNotInArray($this->cacheTypes) ->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes))) diff --git a/Resources/config/client.xml b/Resources/config/client.xml index 72acfef..d98220e 100644 --- a/Resources/config/client.xml +++ b/Resources/config/client.xml @@ -12,7 +12,7 @@ wsdl %kernel.debug% - null + null From 4e33819eca94b774aaf9c43957d2e2586b1986db Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sun, 4 Sep 2011 12:59:19 +0200 Subject: [PATCH 06/20] Added cache_type option for soap server definition --- DependencyInjection/BeSimpleSoapExtension.php | 4 +++ DependencyInjection/Configuration.php | 6 ++++ Resources/config/webservice.xml | 2 ++ Soap/SoapServerFactory.php | 36 ++++++++++++++++--- WebServiceContext.php | 5 ++- 5 files changed, 48 insertions(+), 5 deletions(-) diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index e14d6df..7625b57 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -106,6 +106,10 @@ class BeSimpleSoapExtension extends Extension $definition = new DefinitionDecorator('besimple.soap.context.'.$bindingSuffix); $context = $container->setDefinition($contextId, $definition); + if (isset($config['cache_type'])) { + $config['cache_type'] = $this->getCacheType($config['cache_type']); + } + $options = $container ->getDefinition('besimple.soap.context.'.$bindingSuffix) ->getArgument(4); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index a15bc22..cf95cc4 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -112,6 +112,12 @@ class Configuration ->thenInvalid("Service binding style has to be either 'rpc-literal' or 'document-wrapped'") ->end() ->end() + ->scalarNode('cache_type') + ->validate() + ->ifNotInArray($this->cacheTypes) + ->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes))) + ->end() + ->end() ->end() ->end() ->end() diff --git a/Resources/config/webservice.xml b/Resources/config/webservice.xml index 081e3b3..71adcfa 100644 --- a/Resources/config/webservice.xml +++ b/Resources/config/webservice.xml @@ -28,6 +28,7 @@ %besimple.soap.cache_dir% %kernel.debug% + null %besimple.soap.binder.request_header.rpcliteral.class% %besimple.soap.binder.request.rpcliteral.class% %besimple.soap.binder.response.rpcliteral.class% @@ -43,6 +44,7 @@ %besimple.soap.cache_dir% %kernel.debug% + null %besimple.soap.binder.request_header.documentwrapped.class% %besimple.soap.binder.request.documentwrapped.class% %besimple.soap.binder.response.documentwrapped.class% diff --git a/Soap/SoapServerFactory.php b/Soap/SoapServerFactory.php index eee5fd2..00d9204 100644 --- a/Soap/SoapServerFactory.php +++ b/Soap/SoapServerFactory.php @@ -22,14 +22,42 @@ class SoapServerFactory private $wsdlFile; private $classmap; private $converters; - private $debug; + private $options; - public function __construct($wsdlFile, array $classmap, ConverterRepository $converters, $debug = false) + public function __construct($wsdlFile, array $classmap, ConverterRepository $converters, array $options = array()) { $this->wsdlFile = $wsdlFile; $this->classmap = $this->fixSoapServerClassmap($classmap); $this->converters = $converters; - $this->debug = $debug; + $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) @@ -40,7 +68,7 @@ class SoapServerFactory 'classmap' => $this->classmap, 'typemap' => $this->createSoapServerTypemap($request, $response), 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, - 'cache_wsdl' => Cache::getType(), + 'cache_wsdl' => null !== $this->options['cache_type'] ? $this->options['cache_type'] : Cache::getType(), ) ); } diff --git a/WebServiceContext.php b/WebServiceContext.php index ccf1ad9..a5d4e4a 100644 --- a/WebServiceContext.php +++ b/WebServiceContext.php @@ -103,7 +103,10 @@ class WebServiceContext $this->getWsdlFile(), $this->serviceDefinition->getDefinitionComplexTypes(), $this->converterRepository, - $this->options['debug'] + array( + 'debug' => $this->options['debug'], + 'cache_type' => isset($this->options['cache_type']) ? $this->options['cache_type'] : null, + ) ); } From 294058a59c928c8e70a322e52e8d41aa0bdd18b5 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sun, 4 Sep 2011 23:43:20 +0200 Subject: [PATCH 07/20] Added namespace option in client definition --- DependencyInjection/BeSimpleSoapExtension.php | 2 ++ DependencyInjection/Configuration.php | 5 ++--- Resources/config/client.xml | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index 7625b57..a2840ba 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -92,6 +92,8 @@ class BeSimpleSoapExtension extends Extension ->getArgument(1); $defOptions['cache_type'] = $options['cache_type']; + $defOptions['namespace'] = $options['namespace']; + $definition->replaceArgument(1, $defOptions); } } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index cf95cc4..3b15368 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -73,9 +73,8 @@ class Configuration ->useAttributeAsKey('name') ->prototype('array') ->children() - ->scalarNode('wsdl') - ->isRequired() - ->end() + ->scalarNode('wsdl')->isRequired()->end() + ->scalarNode('namespace')->defaultNull()->end() ->scalarNode('cache_type') ->validate() ->ifNotInArray($this->cacheTypes) diff --git a/Resources/config/client.xml b/Resources/config/client.xml index d98220e..8ef5918 100644 --- a/Resources/config/client.xml +++ b/Resources/config/client.xml @@ -13,6 +13,7 @@ %kernel.debug% null + null From ecc3ec3c93217bd38289b88bb4ca1331f71746db Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sat, 10 Sep 2011 19:39:14 +0200 Subject: [PATCH 08/20] Updated besimple.soap.client service --- DependencyInjection/BeSimpleSoapExtension.php | 4 ++-- Resources/config/client.xml | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index a2840ba..b129e12 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -89,12 +89,12 @@ class BeSimpleSoapExtension extends Extension $defOptions = $container ->getDefinition('besimple.soap.client') - ->getArgument(1); + ->getArgument(2); $defOptions['cache_type'] = $options['cache_type']; $defOptions['namespace'] = $options['namespace']; - $definition->replaceArgument(1, $defOptions); + $definition->replaceArgument(2, $defOptions); } } } diff --git a/Resources/config/client.xml b/Resources/config/client.xml index 8ef5918..741bfc1 100644 --- a/Resources/config/client.xml +++ b/Resources/config/client.xml @@ -10,6 +10,7 @@ wsdl + null %kernel.debug% null From 864cf228951cb0bc4fc2a2c9789225d7da87d15c Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Tue, 13 Sep 2011 20:47:35 +0200 Subject: [PATCH 09/20] Used converters of BeSimple\SoapCommon for SoapServer --- Converter/ConverterRepository.php | 31 ------------- Converter/DateTimeTypeConverter.php | 44 ------------------- Converter/DateTypeConverter.php | 44 ------------------- Converter/TypeConverterInterface.php | 28 ------------ .../Compiler/TypeConverterPass.php | 6 +-- Resources/config/converters.xml | 8 ++-- Resources/config/webservice.xml | 4 +- Soap/SoapServerFactory.php | 15 ++++--- Tests/Converter/DateTimeTypeConverterTest.php | 43 ------------------ Tests/Converter/DateTypeConverterTest.php | 41 ----------------- WebServiceContext.php | 11 ++--- 11 files changed, 23 insertions(+), 252 deletions(-) delete mode 100644 Converter/ConverterRepository.php delete mode 100644 Converter/DateTimeTypeConverter.php delete mode 100644 Converter/DateTypeConverter.php delete mode 100644 Converter/TypeConverterInterface.php delete mode 100644 Tests/Converter/DateTimeTypeConverterTest.php delete mode 100644 Tests/Converter/DateTypeConverterTest.php diff --git a/Converter/ConverterRepository.php b/Converter/ConverterRepository.php deleted file mode 100644 index a3d9392..0000000 --- a/Converter/ConverterRepository.php +++ /dev/null @@ -1,31 +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\Converter; - -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * @author Christian Kerl - */ -class ConverterRepository -{ - private $typeConverters = array(); - - public function addTypeConverter(TypeConverterInterface $converter) - { - $this->typeConverters[] = $converter; - } - - public function getTypeConverters() - { - return $this->typeConverters; - } -} diff --git a/Converter/DateTimeTypeConverter.php b/Converter/DateTimeTypeConverter.php deleted file mode 100644 index 9f692fc..0000000 --- a/Converter/DateTimeTypeConverter.php +++ /dev/null @@ -1,44 +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\Converter; - -use BeSimple\SoapBundle\Soap\SoapRequest; -use BeSimple\SoapBundle\Soap\SoapResponse; -use BeSimple\SoapBundle\Util\String; - -/** - * @author Christian Kerl - */ -class DateTimeTypeConverter implements TypeConverterInterface -{ - public function getTypeNamespace() - { - return 'http://www.w3.org/2001/XMLSchema'; - } - - public function getTypeName() - { - return 'dateTime'; - } - - public function convertXmlToPhp(SoapRequest $request, $data) - { - $doc = new \DOMDocument(); - $doc->loadXML($data); - - return new \DateTime($doc->textContent); - } - - public function convertPhpToXml(SoapResponse $response, $data) - { - return sprintf('<%1$s>%2$s', $this->getTypeName(), $data->format('Y-m-d\TH:i:sP')); - } -} diff --git a/Converter/DateTypeConverter.php b/Converter/DateTypeConverter.php deleted file mode 100644 index 61f7119..0000000 --- a/Converter/DateTypeConverter.php +++ /dev/null @@ -1,44 +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\Converter; - -use BeSimple\SoapBundle\Soap\SoapRequest; -use BeSimple\SoapBundle\Soap\SoapResponse; -use BeSimple\SoapBundle\Util\String; - -/** - * @author Francis Besset - */ -class DateTypeConverter implements TypeConverterInterface -{ - public function getTypeNamespace() - { - return 'http://www.w3.org/2001/XMLSchema'; - } - - public function getTypeName() - { - return 'date'; - } - - public function convertXmlToPhp(SoapRequest $request, $data) - { - $doc = new \DOMDocument(); - $doc->loadXML($data); - - return new \DateTime($doc->textContent); - } - - public function convertPhpToXml(SoapResponse $response, $data) - { - return sprintf('<%1$s>%2$s', $this->getTypeName(), $data->format('Y-m-d')); - } -} diff --git a/Converter/TypeConverterInterface.php b/Converter/TypeConverterInterface.php deleted file mode 100644 index ae74ed3..0000000 --- a/Converter/TypeConverterInterface.php +++ /dev/null @@ -1,28 +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\Converter; - -use BeSimple\SoapBundle\Soap\SoapRequest; -use BeSimple\SoapBundle\Soap\SoapResponse; - -/** - * @author Christian Kerl - */ -interface TypeConverterInterface -{ - function getTypeNamespace(); - - function getTypeName(); - - function convertXmlToPhp(SoapRequest $request, $data); - - function convertPhpToXml(SoapResponse $response, $data); -} \ No newline at end of file diff --git a/DependencyInjection/Compiler/TypeConverterPass.php b/DependencyInjection/Compiler/TypeConverterPass.php index be97bb6..828c9c9 100644 --- a/DependencyInjection/Compiler/TypeConverterPass.php +++ b/DependencyInjection/Compiler/TypeConverterPass.php @@ -23,14 +23,14 @@ class TypeConverterPass implements CompilerPassInterface { public function process(ContainerBuilder $container) { - if (false === $container->hasDefinition('besimple.soap.converter.repository')) { + if (false === $container->hasDefinition('besimple.soap.converter.collection')) { return; } - $definition = $container->getDefinition('besimple.soap.converter.repository'); + $definition = $container->getDefinition('besimple.soap.converter.collection'); foreach ($container->findTaggedServiceIds('besimple.soap.converter') as $id => $attributes) { - $definition->addMethodCall('addTypeConverter', array(new Reference($id))); + $definition->addMethodCall('add', array(new Reference($id))); } } } diff --git a/Resources/config/converters.xml b/Resources/config/converters.xml index ec6e5c5..f3f9c52 100644 --- a/Resources/config/converters.xml +++ b/Resources/config/converters.xml @@ -5,13 +5,13 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - BeSimple\SoapBundle\Converter\ConverterRepository - BeSimple\SoapBundle\Converter\DateTimeTypeConverter - BeSimple\SoapBundle\Converter\DateTypeConverter + BeSimple\SoapCommon\Converter\TypeConverterCollection + BeSimple\SoapCommon\Converter\DateTimeTypeConverter + BeSimple\SoapCommon\Converter\DateTypeConverter - + diff --git a/Resources/config/webservice.xml b/Resources/config/webservice.xml index 71adcfa..d23f7ed 100644 --- a/Resources/config/webservice.xml +++ b/Resources/config/webservice.xml @@ -24,7 +24,7 @@ - + %besimple.soap.cache_dir% %kernel.debug% @@ -40,7 +40,7 @@ - + %besimple.soap.cache_dir% %kernel.debug% diff --git a/Soap/SoapServerFactory.php b/Soap/SoapServerFactory.php index 00d9204..8db8b85 100644 --- a/Soap/SoapServerFactory.php +++ b/Soap/SoapServerFactory.php @@ -10,8 +10,9 @@ namespace BeSimple\SoapBundle\Soap; -use BeSimple\SoapBundle\Converter\ConverterRepository; use BeSimple\SoapCommon\Cache; +use BeSimple\SoapCommon\Converter\TypeConverterCollection; + use Zend\Soap\Wsdl; /** @@ -24,7 +25,7 @@ class SoapServerFactory private $converters; private $options; - public function __construct($wsdlFile, array $classmap, ConverterRepository $converters, array $options = array()) + public function __construct($wsdlFile, array $classmap, TypeConverterCollection $converters, array $options = array()) { $this->wsdlFile = $wsdlFile; $this->classmap = $this->fixSoapServerClassmap($classmap); @@ -77,15 +78,15 @@ class SoapServerFactory { $typemap = array(); - foreach($this->converters->getTypeConverters() as $typeConverter) { + foreach($this->converters->all() as $typeConverter) { $typemap[] = array( 'type_name' => $typeConverter->getTypeName(), 'type_ns' => $typeConverter->getTypeNamespace(), - 'from_xml' => function($input) use ($request, $typeConverter) { - return $typeConverter->convertXmlToPhp($request, $input); + 'from_xml' => function($input) use ($typeConverter) { + return $typeConverter->convertXmlToPhp($input); }, - 'to_xml' => function($input) use ($response, $typeConverter) { - return $typeConverter->convertPhpToXml($response, $input); + 'to_xml' => function($input) use ($typeConverter) { + return $typeConverter->convertPhpToXml($input); }, ); } diff --git a/Tests/Converter/DateTimeTypeConverterTest.php b/Tests/Converter/DateTimeTypeConverterTest.php deleted file mode 100644 index b04acd3..0000000 --- a/Tests/Converter/DateTimeTypeConverterTest.php +++ /dev/null @@ -1,43 +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\Tests\Converter; - -use BeSimple\SoapBundle\Soap\SoapRequest; -use BeSimple\SoapBundle\Soap\SoapResponse; -use BeSimple\SoapBundle\Converter\DateTimeTypeConverter; - -/** - * UnitTest for \BeSimple\SoapBundle\Converter\DateTimeTypeConverter. - * - * @author Christian Kerl - */ -class DateTimeTypeConverterTest extends \PHPUnit_Framework_TestCase -{ - public function testConvertXmlToPhp() - { - $converter = new DateTimeTypeConverter(); - - $dateXml = '2002-10-10T12:00:00-05:00'; - $date = $converter->convertXmlToPhp(new SoapRequest(), $dateXml); - - $this->assertEquals(new \DateTime('2002-10-10T12:00:00-05:00'), $date); - } - - public function testConvertPhpToXml() - { - $converter = new DateTimeTypeConverter(); - - $date = new \DateTime('2002-10-10T12:00:00-05:00'); - $dateXml = $converter->convertPhpToXml(new SoapResponse(), $date); - - $this->assertEquals('2002-10-10T12:00:00-05:00', $dateXml); - } -} diff --git a/Tests/Converter/DateTypeConverterTest.php b/Tests/Converter/DateTypeConverterTest.php deleted file mode 100644 index db53dd1..0000000 --- a/Tests/Converter/DateTypeConverterTest.php +++ /dev/null @@ -1,41 +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\Tests\Converter; - -use BeSimple\SoapBundle\Soap\SoapRequest; -use BeSimple\SoapBundle\Soap\SoapResponse; -use BeSimple\SoapBundle\Converter\DateTypeConverter; - -/** - * UnitTest for \BeSimple\SoapBundle\Converter\DateTimeTypeConverter. - */ -class DateTypeConverterTest extends \PHPUnit_Framework_TestCase -{ - public function testConvertXmlToPhp() - { - $converter = new DateTypeConverter(); - - $dateXml = '2002-10-10'; - $date = $converter->convertXmlToPhp(new SoapRequest(), $dateXml); - - $this->assertEquals(new \DateTime('2002-10-10'), $date); - } - - public function testConvertPhpToXml() - { - $converter = new DateTypeConverter(); - - $date = new \DateTime('2002-10-10'); - $dateXml = $converter->convertPhpToXml(new SoapResponse(), $date); - - $this->assertEquals('2002-10-10', $dateXml); - } -} diff --git a/WebServiceContext.php b/WebServiceContext.php index a5d4e4a..e03b200 100644 --- a/WebServiceContext.php +++ b/WebServiceContext.php @@ -10,13 +10,14 @@ namespace BeSimple\SoapBundle; -use BeSimple\SoapBundle\Converter\ConverterRepository; 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\Converter\TypeConverterCollection; + use Symfony\Component\Config\ConfigCache; use Symfony\Component\Config\Loader\LoaderInterface; @@ -38,12 +39,12 @@ class WebServiceContext private $serviceBinder; private $serverFactory; - public function __construct(LoaderInterface $loader, DumperInterface $dumper, TypeRepository $typeRepository, ConverterRepository $converterRepository, array $options) { + public function __construct(LoaderInterface $loader, DumperInterface $dumper, TypeRepository $typeRepository, TypeConverterCollection $converters, array $options) { $this->loader = $loader; $this->wsdlFileDumper = $dumper; - $this->typeRepository = $typeRepository; - $this->converterRepository = $converterRepository; + $this->typeRepository = $typeRepository; + $this->converters = $converters; $this->options = $options; } @@ -102,7 +103,7 @@ class WebServiceContext $this->serverFactory = new SoapServerFactory( $this->getWsdlFile(), $this->serviceDefinition->getDefinitionComplexTypes(), - $this->converterRepository, + $this->converters, array( 'debug' => $this->options['debug'], 'cache_type' => isset($this->options['cache_type']) ? $this->options['cache_type'] : null, From 95c08c6edf0a40c9aa1dd026e66edaef5f0f227f Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Tue, 13 Sep 2011 20:50:16 +0200 Subject: [PATCH 10/20] Used converters of BeSimpleSoapCommon for SoapClient --- Resources/config/client.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Resources/config/client.xml b/Resources/config/client.xml index 741bfc1..4c2299d 100644 --- a/Resources/config/client.xml +++ b/Resources/config/client.xml @@ -9,8 +9,8 @@ - wsdl - null + + %kernel.debug% null From 3de0636bb8613c61158c65391ea496ac219ffebe Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Tue, 13 Sep 2011 21:08:33 +0200 Subject: [PATCH 11/20] Used TypeConverterCollection::getTypemap() to build the typemap for SoapServer --- Soap/SoapServerFactory.php | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/Soap/SoapServerFactory.php b/Soap/SoapServerFactory.php index 8db8b85..7282f09 100644 --- a/Soap/SoapServerFactory.php +++ b/Soap/SoapServerFactory.php @@ -67,33 +67,13 @@ class SoapServerFactory $this->wsdlFile, array( 'classmap' => $this->classmap, - 'typemap' => $this->createSoapServerTypemap($request, $response), + 'typemap' => $this->converters->getTypemap(), 'features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'cache_wsdl' => null !== $this->options['cache_type'] ? $this->options['cache_type'] : Cache::getType(), ) ); } - private function createSoapServerTypemap($request, $response) - { - $typemap = array(); - - foreach($this->converters->all() as $typeConverter) { - $typemap[] = array( - 'type_name' => $typeConverter->getTypeName(), - 'type_ns' => $typeConverter->getTypeNamespace(), - 'from_xml' => function($input) use ($typeConverter) { - return $typeConverter->convertXmlToPhp($input); - }, - 'to_xml' => function($input) use ($typeConverter) { - return $typeConverter->convertPhpToXml($input); - }, - ); - } - - return $typemap; - } - private function fixSoapServerClassmap($classmap) { $classmapFixed = array(); From 94a8a8fec1aafb4c78b60f4790e94324f33cf753 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sat, 8 Oct 2011 12:41:47 +0200 Subject: [PATCH 12/20] Updated SoapClient definition --- DependencyInjection/BeSimpleSoapExtension.php | 4 ++-- Resources/config/client.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index b129e12..a2840ba 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -89,12 +89,12 @@ class BeSimpleSoapExtension extends Extension $defOptions = $container ->getDefinition('besimple.soap.client') - ->getArgument(2); + ->getArgument(1); $defOptions['cache_type'] = $options['cache_type']; $defOptions['namespace'] = $options['namespace']; - $definition->replaceArgument(2, $defOptions); + $definition->replaceArgument(1, $defOptions); } } } diff --git a/Resources/config/client.xml b/Resources/config/client.xml index 4c2299d..102f34b 100644 --- a/Resources/config/client.xml +++ b/Resources/config/client.xml @@ -10,12 +10,12 @@ - %kernel.debug% null null + From 1d9bd2cdd376645d99846f92e851f00263e50bd0 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sat, 8 Oct 2011 18:03:27 +0200 Subject: [PATCH 13/20] Added besimple.soap.classmap service --- DependencyInjection/BeSimpleSoapExtension.php | 19 +++++++++++++++++++ DependencyInjection/Configuration.php | 4 ++++ Resources/config/client.xml | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index a2840ba..02bb008 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -96,9 +96,28 @@ class BeSimpleSoapExtension extends Extension $definition->replaceArgument(1, $defOptions); } + + if (!empty($options['classmap'])) { + $classmap = $this->createClientClassmap($client, $options['classmap'], $container); + $definition->replaceArgument(2, new Reference($classmap)); + } else { + $definition->replaceArgument(2, null); + } } } + private function createClientClassmap($client, array $classmap, ContainerBuilder $container) + { + $definition = new DefinitionDecorator('besimple.soap.classmap'); + $context = $container->setDefinition(sprintf('besimple.soap.classmap.%s', $client), $definition); + + $definition->setMethodCalls(array( + array('set', array($classmap)), + )); + + return sprintf('besimple.soap.classmap.%s', $client); + } + private function createWebServiceContext(array $config, ContainerBuilder $container) { $bindingSuffix = $this->bindingConfigToServiceSuffixMap[$config['binding']]; diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 3b15368..bb8bedf 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -81,6 +81,10 @@ class Configuration ->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes))) ->end() ->end() + ->arrayNode('classmap') + ->useAttributeAsKey('name') + ->prototype('scalar') + ->end() ->end() ->end() ->end() diff --git a/Resources/config/client.xml b/Resources/config/client.xml index 102f34b..efc63ca 100644 --- a/Resources/config/client.xml +++ b/Resources/config/client.xml @@ -5,6 +5,7 @@ BeSimple\SoapClient\SoapClient + BeSimple\SoapCommon\Classmap @@ -15,9 +16,12 @@ null null + + + From 6d2e9d763476398e71cc44a46eb5f395f67c3179 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sat, 8 Oct 2011 22:04:18 +0200 Subject: [PATCH 14/20] Added user_agent option --- DependencyInjection/BeSimpleSoapExtension.php | 19 +++++++++++-------- DependencyInjection/Configuration.php | 3 ++- Resources/config/client.xml | 2 -- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index 02bb008..c462bca 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -84,19 +84,22 @@ class BeSimpleSoapExtension extends Extension $definition->replaceArgument(0, $options['wsdl']); - if (isset($options['cache_type'])) { - $options['cache_type'] = $this->getCacheType($options['cache_type']); - - $defOptions = $container + $defOptions = $container ->getDefinition('besimple.soap.client') ->getArgument(1); - $defOptions['cache_type'] = $options['cache_type']; - $defOptions['namespace'] = $options['namespace']; - - $definition->replaceArgument(1, $defOptions); + foreach (array('cache_type', 'namespace', 'user_agent') as $key) { + if (isset($options[$key])) { + $defOptions[$key] = $options[$key]; + } } + if (isset($defOptions['cache_type'])) { + $$defOptions['cache_type'] = $this->getCacheType($defOptions['cache_type']); + } + + $definition->replaceArgument(1, $defOptions); + if (!empty($options['classmap'])) { $classmap = $this->createClientClassmap($client, $options['classmap'], $container); $definition->replaceArgument(2, new Reference($classmap)); diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index bb8bedf..658a283 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -74,7 +74,8 @@ class Configuration ->prototype('array') ->children() ->scalarNode('wsdl')->isRequired()->end() - ->scalarNode('namespace')->defaultNull()->end() + ->scalarNode('namespace')->end() + ->scalarNode('user_agent')->end() ->scalarNode('cache_type') ->validate() ->ifNotInArray($this->cacheTypes) diff --git a/Resources/config/client.xml b/Resources/config/client.xml index efc63ca..7ea688b 100644 --- a/Resources/config/client.xml +++ b/Resources/config/client.xml @@ -13,8 +13,6 @@ %kernel.debug% - null - null From d3c31116c7994624d670f57712a34265176f19aa Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Mon, 10 Oct 2011 22:19:43 +0200 Subject: [PATCH 15/20] Replaced soap.client by soap.client.builder --- DependencyInjection/BeSimpleSoapExtension.php | 20 +++-- DependencyInjection/Configuration.php | 1 - Resources/config/client.xml | 6 +- Soap/SoapClientBuilder.php | 77 +++++++++++++++++++ 4 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 Soap/SoapClientBuilder.php diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index c462bca..62fc3aa 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -79,23 +79,23 @@ class BeSimpleSoapExtension extends Extension $loader->load('client.xml'); foreach ($config as $client => $options) { - $definition = new DefinitionDecorator('besimple.soap.client'); - $context = $container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition); + $definition = new DefinitionDecorator('besimple.soap.client.builder'); + $context = $container->setDefinition(sprintf('besimple.soap.client.builder.%s', $client), $definition); $definition->replaceArgument(0, $options['wsdl']); $defOptions = $container - ->getDefinition('besimple.soap.client') + ->getDefinition('besimple.soap.client.builder') ->getArgument(1); - foreach (array('cache_type', 'namespace', 'user_agent') as $key) { + foreach (array('cache_type', 'user_agent') as $key) { if (isset($options[$key])) { $defOptions[$key] = $options[$key]; } } if (isset($defOptions['cache_type'])) { - $$defOptions['cache_type'] = $this->getCacheType($defOptions['cache_type']); + $defOptions['cache_type'] = $this->getCacheType($defOptions['cache_type']); } $definition->replaceArgument(1, $defOptions); @@ -106,6 +106,8 @@ class BeSimpleSoapExtension extends Extension } else { $definition->replaceArgument(2, null); } + + $this->createClient($client, $container); } } @@ -121,6 +123,14 @@ class BeSimpleSoapExtension extends Extension return sprintf('besimple.soap.classmap.%s', $client); } + private function createClient($client, ContainerBuilder $container) + { + $definition = new DefinitionDecorator('besimple.soap.client'); + $context = $container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition); + + $definition->setFactoryService(sprintf('besimple.soap.client.builder.%s', $client)); + } + private function createWebServiceContext(array $config, ContainerBuilder $container) { $bindingSuffix = $this->bindingConfigToServiceSuffixMap[$config['binding']]; diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 658a283..c56f3c9 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -74,7 +74,6 @@ class Configuration ->prototype('array') ->children() ->scalarNode('wsdl')->isRequired()->end() - ->scalarNode('namespace')->end() ->scalarNode('user_agent')->end() ->scalarNode('cache_type') ->validate() diff --git a/Resources/config/client.xml b/Resources/config/client.xml index 7ea688b..939e470 100644 --- a/Resources/config/client.xml +++ b/Resources/config/client.xml @@ -4,12 +4,12 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - BeSimple\SoapClient\SoapClient + BeSimple\SoapBundle\Soap\SoapClientBuilder BeSimple\SoapCommon\Classmap - + %kernel.debug% @@ -19,6 +19,8 @@ + + diff --git a/Soap/SoapClientBuilder.php b/Soap/SoapClientBuilder.php new file mode 100644 index 0000000..c21993f --- /dev/null +++ b/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) + )); + } + } +} \ No newline at end of file From 4a7ec164e5eed75073ad378d4d4958738935e0f8 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Tue, 11 Oct 2011 22:41:32 +0200 Subject: [PATCH 16/20] Updated Cache class --- Cache.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Cache.php b/Cache.php index 71d8927..f5a4f88 100644 --- a/Cache.php +++ b/Cache.php @@ -21,7 +21,9 @@ class Cache { public function __construct($disabled, $type, $directory, $lifetime = null, $limit = null) { - BaseCache::setEnabled(!$disabled); + $isEnabled = $disabled ? BaseCache::DISABLED : BaseCache::ENABLED; + + BaseCache::setEnabled($isEnabled); if (BaseCache::ENABLED == BaseCache::isEnabled()) { BaseCache::setType($type); From 70a85460c9a30be214485a19455fba7673ed0326 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Wed, 12 Oct 2011 21:08:59 +0200 Subject: [PATCH 17/20] Used BeSimple\SoapCommon\Classmap for the webservice context --- DependencyInjection/BeSimpleSoapExtension.php | 6 +++--- Resources/config/webservice.xml | 6 ++++++ ServiceDefinition/Dumper/WsdlDumper.php | 8 +++++-- ServiceDefinition/Dumper/WsdlTypeStrategy.php | 8 +++++-- ServiceDefinition/Strategy/ComplexType.php | 7 ++++++- Soap/SoapServerFactory.php | 21 ++++++------------- WebServiceContext.php | 7 +++++-- 7 files changed, 38 insertions(+), 25 deletions(-) diff --git a/DependencyInjection/BeSimpleSoapExtension.php b/DependencyInjection/BeSimpleSoapExtension.php index 62fc3aa..941cbf0 100644 --- a/DependencyInjection/BeSimpleSoapExtension.php +++ b/DependencyInjection/BeSimpleSoapExtension.php @@ -51,7 +51,7 @@ class BeSimpleSoapExtension extends Extension $this->registerCacheConfiguration($config['cache'], $container, $loader); - if (isset($config['clients'])) { + if (!empty($config['clients'])) { $this->registerClientConfiguration($config['clients'], $container, $loader); } @@ -146,9 +146,9 @@ class BeSimpleSoapExtension extends Extension $options = $container ->getDefinition('besimple.soap.context.'.$bindingSuffix) - ->getArgument(4); + ->getArgument(5); - $definition->replaceArgument(4, array_merge($options, $config)); + $definition->replaceArgument(5, array_merge($options, $config)); } private function getCacheType($type) diff --git a/Resources/config/webservice.xml b/Resources/config/webservice.xml index d23f7ed..95e97b6 100644 --- a/Resources/config/webservice.xml +++ b/Resources/config/webservice.xml @@ -15,6 +15,7 @@ BeSimple\SoapBundle\ServiceBinding\DocumentLiteralWrappedResponseMessageBinder BeSimple\SoapBundle\ServiceDefinition\Dumper\WsdlDumper BeSimple\SoapBundle\Converter\TypeRepository + BeSimple\SoapCommon\Classmap @@ -23,6 +24,7 @@ + @@ -39,6 +41,7 @@ + @@ -54,12 +57,15 @@ + %besimple.soap.definition.dumper.options.stylesheet% + + xsd diff --git a/ServiceDefinition/Dumper/WsdlDumper.php b/ServiceDefinition/Dumper/WsdlDumper.php index 97517f7..bf348e2 100644 --- a/ServiceDefinition/Dumper/WsdlDumper.php +++ b/ServiceDefinition/Dumper/WsdlDumper.php @@ -18,21 +18,25 @@ use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader; use BeSimple\SoapBundle\Util\Assert; use BeSimple\SoapBundle\Util\QName; +use BeSimple\SoapCommon\Classmap; + /** * @author Christian Kerl */ class WsdlDumper implements DumperInterface { private $loader; + private $classmap; private $typeRepository; private $options; private $wsdl; private $definition; - public function __construct(AnnotationComplexTypeLoader $loader, TypeRepository $typeRepository, array $options) + public function __construct(AnnotationComplexTypeLoader $loader, Classmap $classmap, TypeRepository $typeRepository, array $options) { $this->loader = $loader; + $this->classmap = $classmap; $this->typeRepository = $typeRepository; $this->options = $options; } @@ -42,7 +46,7 @@ class WsdlDumper implements DumperInterface Assert::thatArgumentNotNull('definition', $definition); $this->definition = $definition; - $this->wsdl = new Wsdl($this->typeRepository, $definition->getName(), $definition->getNamespace(), new WsdlTypeStrategy($this->loader, $definition)); + $this->wsdl = new Wsdl($this->typeRepository, $definition->getName(), $definition->getNamespace(), new WsdlTypeStrategy($this->loader, $this->classmap, $definition)); $port = $this->wsdl->addPortType($this->getPortTypeName()); $binding = $this->wsdl->addBinding($this->getBindingName(), $this->qualify($this->getPortTypeName())); diff --git a/ServiceDefinition/Dumper/WsdlTypeStrategy.php b/ServiceDefinition/Dumper/WsdlTypeStrategy.php index 62610e8..1d35d9c 100644 --- a/ServiceDefinition/Dumper/WsdlTypeStrategy.php +++ b/ServiceDefinition/Dumper/WsdlTypeStrategy.php @@ -15,6 +15,8 @@ use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader; use BeSimple\SoapBundle\ServiceDefinition\Strategy\ComplexType; use BeSimple\SoapBundle\Util\String; +use BeSimple\SoapCommon\Classmap; + use Zend\Soap\Exception; use Zend\Soap\Wsdl as BaseWsdl; use Zend\Soap\Wsdl\Strategy; @@ -30,14 +32,16 @@ class WsdlTypeStrategy implements Strategy private $context; private $loader; + private $classmap; private $definition; private $typeStrategy; private $arrayStrategy; - public function __construct(AnnotationComplexTypeLoader $loader, ServiceDefinition $definition) + public function __construct(AnnotationComplexTypeLoader $loader, Classmap $classmap, ServiceDefinition $definition) { $this->loader = $loader; + $this->classmap = $classmap; $this->definition = $definition; } @@ -86,7 +90,7 @@ class WsdlTypeStrategy implements Strategy private function getTypeStrategy() { if (!$this->typeStrategy) { - $this->typeStrategy = new ComplexType($this->loader, $this->definition); + $this->typeStrategy = new ComplexType($this->loader, $this->classmap, $this->definition); $this->typeStrategy->setContext($this->context); } diff --git a/ServiceDefinition/Strategy/ComplexType.php b/ServiceDefinition/Strategy/ComplexType.php index 8af3fb1..b608902 100644 --- a/ServiceDefinition/Strategy/ComplexType.php +++ b/ServiceDefinition/Strategy/ComplexType.php @@ -12,6 +12,7 @@ namespace BeSimple\SoapBundle\ServiceDefinition\Strategy; use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader; +use BeSimple\SoapCommon\Classmap; use Zend\Soap\Wsdl; use Zend\Soap\Wsdl\Strategy\AbstractStrategy; @@ -21,11 +22,13 @@ use Zend\Soap\Wsdl\Strategy\AbstractStrategy; class ComplexType extends AbstractStrategy { private $loader; + private $classmap; private $definition; - public function __construct(AnnotationComplexTypeLoader $loader, $definition) + public function __construct(AnnotationComplexTypeLoader $loader, Classmap $classmap, $definition) { $this->loader = $loader; + $this->classmap = $classmap; $this->definition = $definition; } @@ -50,6 +53,8 @@ class ComplexType extends AbstractStrategy $soapTypeName = Wsdl::translateType($type); $soapType = 'tns:'.$soapTypeName; + $this->classmap->add($soapTypeName, $type); + // Register type here to avoid recursion $this->getContext()->addType($type, $soapType); diff --git a/Soap/SoapServerFactory.php b/Soap/SoapServerFactory.php index 7282f09..caa133f 100644 --- a/Soap/SoapServerFactory.php +++ b/Soap/SoapServerFactory.php @@ -11,6 +11,7 @@ namespace BeSimple\SoapBundle\Soap; use BeSimple\SoapCommon\Cache; +use BeSimple\SoapCommon\Classmap; use BeSimple\SoapCommon\Converter\TypeConverterCollection; use Zend\Soap\Wsdl; @@ -25,11 +26,12 @@ class SoapServerFactory private $converters; private $options; - public function __construct($wsdlFile, array $classmap, TypeConverterCollection $converters, array $options = array()) + public function __construct($wsdlFile, Classmap $classmap, TypeConverterCollection $converters, array $options = array()) { $this->wsdlFile = $wsdlFile; - $this->classmap = $this->fixSoapServerClassmap($classmap); + $this->classmap = $classmap; $this->converters = $converters; + $this->setOptions($options); } @@ -66,22 +68,11 @@ class SoapServerFactory return new \SoapServer( $this->wsdlFile, array( - 'classmap' => $this->classmap, + '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(), ) ); } - - private function fixSoapServerClassmap($classmap) - { - $classmapFixed = array(); - - foreach ($classmap as $class => $definition) { - $classmapFixed[Wsdl::translateType($class)] = $class; - } - - return $classmapFixed; - } -} \ No newline at end of file +} diff --git a/WebServiceContext.php b/WebServiceContext.php index e03b200..666c806 100644 --- a/WebServiceContext.php +++ b/WebServiceContext.php @@ -16,6 +16,7 @@ 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 Symfony\Component\Config\ConfigCache; @@ -39,10 +40,12 @@ class WebServiceContext private $serviceBinder; private $serverFactory; - public function __construct(LoaderInterface $loader, DumperInterface $dumper, TypeRepository $typeRepository, TypeConverterCollection $converters, array $options) { + public function __construct(LoaderInterface $loader, DumperInterface $dumper, Classmap $classmap, TypeRepository $typeRepository, TypeConverterCollection $converters, array $options) { $this->loader = $loader; $this->wsdlFileDumper = $dumper; + $this->classmap = $classmap; + $this->typeRepository = $typeRepository; $this->converters = $converters; @@ -102,7 +105,7 @@ class WebServiceContext if (null === $this->serverFactory) { $this->serverFactory = new SoapServerFactory( $this->getWsdlFile(), - $this->serviceDefinition->getDefinitionComplexTypes(), + $this->classmap, $this->converters, array( 'debug' => $this->options['debug'], From 32259355d6def8b81dc61d1fd3d5a5237c7c5fbf Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Wed, 12 Oct 2011 22:01:50 +0200 Subject: [PATCH 18/20] Deleted SoapServerFactory and used BeSimple\SoapServer\SoapServerBuilder to build the SoapServer --- Controller/SoapWebServiceController.php | 8 ++- Soap/SoapServerFactory.php | 78 ------------------------- WebServiceContext.php | 30 +++++----- 3 files changed, 21 insertions(+), 95 deletions(-) delete mode 100644 Soap/SoapServerFactory.php 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 From 4abf5a59edddf3348f10f01df90e476793e7e164 Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sun, 13 Nov 2011 21:55:26 +0100 Subject: [PATCH 19/20] [Doc] Add the WSDL address --- Resources/doc/reference/configuration.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Resources/doc/reference/configuration.rst b/Resources/doc/reference/configuration.rst index 1ccd620..1662e86 100644 --- a/Resources/doc/reference/configuration.rst +++ b/Resources/doc/reference/configuration.rst @@ -50,4 +50,9 @@ Annotations for Controllers { return $this->container->get('besimple.soap.response')->setReturnValue(sprintf('Hello %s!', $name)); } - } \ No newline at end of file + } + +Get your WSDL +------------- + +To access your WSDL go to the following address: http://localhost/app_dev.php/ws/DemoApi?wsdl From 0ac7a78870468423f8bf0dd76d11424921c9ef4d Mon Sep 17 00:00:00 2001 From: Francis Besset Date: Sun, 13 Nov 2011 22:40:42 +0100 Subject: [PATCH 20/20] [Doc] Global update --- Resources/doc/cache.rst | 26 +++++++++++++ Resources/doc/index.rst | 24 ++++++++---- .../doc/{reference => }/installation.rst | 38 ++++++++++++++++++- .../configuration.rst | 0 .../doc/{ => soapserver}/tutorial/array.rst | 0 .../tutorial/complex_type.rst | 0 .../doc/{ => soapserver}/tutorial/header.rst | 0 Resources/doc/soapserver/tutorials.rst | 9 +++++ .../doc/{reference => soapserver}/types.rst | 0 9 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 Resources/doc/cache.rst rename Resources/doc/{reference => }/installation.rst (52%) rename Resources/doc/{reference => soapserver}/configuration.rst (100%) rename Resources/doc/{ => soapserver}/tutorial/array.rst (100%) rename Resources/doc/{ => soapserver}/tutorial/complex_type.rst (100%) rename Resources/doc/{ => soapserver}/tutorial/header.rst (100%) create mode 100644 Resources/doc/soapserver/tutorials.rst rename Resources/doc/{reference => soapserver}/types.rst (100%) diff --git a/Resources/doc/cache.rst b/Resources/doc/cache.rst new file mode 100644 index 0000000..0090361 --- /dev/null +++ b/Resources/doc/cache.rst @@ -0,0 +1,26 @@ +Cache +===== + +Configuration +------------- + +Configure the cache of PHP Soap WSDL in your config file: + +.. code-block:: yaml + + # app/config/config.yml + be_simple_soap: + cache: + type: disk + lifetime: 86400 + limit: 5 + +The cache type can be: **none**, **disk** (default value), **memory**, **disk_memory**. + +The lifetime in seconds of a WSDL file in the cache (**86400 is the default value by PHP**). + +The limit is the maximum number of in-memory cached WSDL files (**5 is the default value by PHP**). + +If you want more information you can visit the following page `PHP Soap runtime configuration`_. + +.. _`PHP Soap runtime configuration`: http://www.php.net/manual/en/soap.configuration.php \ No newline at end of file diff --git a/Resources/doc/index.rst b/Resources/doc/index.rst index 19be4f2..9182aa0 100644 --- a/Resources/doc/index.rst +++ b/Resources/doc/index.rst @@ -1,9 +1,11 @@ +================== BeSimpleSoapBundle ================== The BeSimpleSoapBundle is a Symfony2 bundle to build WSDL and SOAP based web services. It is based on the `ckWebServicePlugin`_ for symfony. +--------------- Reference Guide --------------- @@ -11,19 +13,25 @@ Reference Guide :maxdepth: 1 :numbered: - reference/installation - reference/configuration - reference/types + installation + cache -Tutorial --------- +---------- +SoapServer +---------- .. toctree:: :maxdepth: 1 :numbered: - tutorial/array - tutorial/complex_type - tutorial/header + soapserver/configuration + soapserver/types + soapserver/tutorials + +---------- +SoapClient +---------- + +Coming soon. .. _`ckWebServicePlugin`: http://www.symfony-project.org/plugins/ckWebServicePlugin \ No newline at end of file diff --git a/Resources/doc/reference/installation.rst b/Resources/doc/installation.rst similarity index 52% rename from Resources/doc/reference/installation.rst rename to Resources/doc/installation.rst index 495bec3..7a6c2e1 100644 --- a/Resources/doc/reference/installation.rst +++ b/Resources/doc/installation.rst @@ -4,8 +4,39 @@ Installation Requirements ------------ -Install and enable PHP's SOAP extension -Download `Zend\\Soap`_ and `Zend\\Mime`_ or add in `deps` file +Install and enable PHP's SOAP extension. + +Download `BeSimple\\SoapCommon`_ and `BeSimple\\SoapServer`_ (only for the server part) and/or `BeSimple\\SoapClient`_ (only for ther client part). + +.. code-block:: ini + + ; deps file + [BeSimple\SoapCommon] + git=http://github.com/BeSimple/SoapCommon + target=/besimple-soapcommon + + [BeSimple\SoapClient] + git=http://github.com/BeSimple/SoapClient + target=/besimple-soapclient + + [BeSimple\SoapServer] + git=http://github.com/BeSimple/SoapServer + target=/besimple-soapserver + + +Add `BeSimple` libraries in autoload.php + +.. code-block:: php + + // app/autoload.php + $loader->registerNamespaces(array( + 'BeSimple\\SoapCommon' => __DIR__.'/../vendor/besimple-soapcommon', + 'BeSimple\\SoapServer' => __DIR__.'/../vendor/besimple-soapserver', + 'BeSimple\\SoapClient' => __DIR__.'/../vendor/besimple-soapclient', + // your other namespaces + )); + +Download `Zend\\Soap`_ and `Zend\\Mime`_ or add in `deps` file. `Zend` library is required only for the server part. .. code-block:: ini @@ -67,4 +98,7 @@ Add `BeSimpleSoapBundle` in your Kernel class .. _`Zend\\Soap`: http://github.com/BeSimple/zend-soap .. _`Zend\\Mime`: http://github.com/BeSimple/zend-mime +.. _`BeSimple\\SoapCommon`: http://github.com/BeSimple/BeSimpleSoapCommon +.. _`BeSimple\\SoapServer`: http://github.com/BeSimple/BeSimpleSoapServer +.. _`BeSimple\\SoapClient`: http://github.com/BeSimple/BeSimpleSoapClient .. _`Download`: http://github.com/BeSimple/BeSimpleSoapBundle diff --git a/Resources/doc/reference/configuration.rst b/Resources/doc/soapserver/configuration.rst similarity index 100% rename from Resources/doc/reference/configuration.rst rename to Resources/doc/soapserver/configuration.rst diff --git a/Resources/doc/tutorial/array.rst b/Resources/doc/soapserver/tutorial/array.rst similarity index 100% rename from Resources/doc/tutorial/array.rst rename to Resources/doc/soapserver/tutorial/array.rst diff --git a/Resources/doc/tutorial/complex_type.rst b/Resources/doc/soapserver/tutorial/complex_type.rst similarity index 100% rename from Resources/doc/tutorial/complex_type.rst rename to Resources/doc/soapserver/tutorial/complex_type.rst diff --git a/Resources/doc/tutorial/header.rst b/Resources/doc/soapserver/tutorial/header.rst similarity index 100% rename from Resources/doc/tutorial/header.rst rename to Resources/doc/soapserver/tutorial/header.rst diff --git a/Resources/doc/soapserver/tutorials.rst b/Resources/doc/soapserver/tutorials.rst new file mode 100644 index 0000000..d1d36a4 --- /dev/null +++ b/Resources/doc/soapserver/tutorials.rst @@ -0,0 +1,9 @@ +Tutorials +========= + +.. toctree:: + :maxdepth: 1 + + tutorial/array + tutorial/complex_type + tutorial/header diff --git a/Resources/doc/reference/types.rst b/Resources/doc/soapserver/types.rst similarity index 100% rename from Resources/doc/reference/types.rst rename to Resources/doc/soapserver/types.rst