diff --git a/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php b/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php
index 4e2b47a..413e1ca 100644
--- a/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php
+++ b/src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php
@@ -14,6 +14,8 @@ 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;
@@ -41,6 +43,7 @@ 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');
@@ -53,8 +56,8 @@ class BeSimpleSoapExtension extends Extension
$this->registerCacheConfiguration($config['cache'], $container, $loader);
- if (!empty($config['clients'])) {
- $this->registerClientConfiguration($config['clients'], $container, $loader);
+ if ( ! empty($config['clients'])) {
+ $this->registerClientConfiguration($config, $container, $loader);
}
$container->setParameter('besimple.soap.definition.dumper.options.stylesheet', $config['wsdl_dumper']['stylesheet']);
@@ -69,11 +72,9 @@ 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', 'lifetime', 'limit') as $key) {
+ foreach (array('type', 'file') as $key) {
$container->setParameter('besimple.soap.cache.'.$key, $config[$key]);
}
}
@@ -82,22 +83,33 @@ class BeSimpleSoapExtension extends Extension
{
$loader->load('client.xml');
- foreach ($config as $client => $options) {
- $definition = new DefinitionDecorator('besimple.soap.client.builder');
- $container->setDefinition(sprintf('besimple.soap.client.builder.%s', $client), $definition);
+ foreach ($config['clients'] as $client => $options) {
+ $soapClientOpts = new DefinitionDecorator('besimple.soap.client_options');
+ $soapOpts = new DefinitionDecorator('besimple.soap.options');
- $definition->replaceArgument(0, $options['wsdl']);
+ $soapClientOptsService = sprintf('besimple.soap.client_options.%s', $client);
+ $soapOptsService = sprintf('besimple.soap.options.%s', $client);
- $defOptions = $container
- ->getDefinition('besimple.soap.client.builder')
- ->getArgument(1);
+ // configure SoapClient
+ $definition = new DefinitionDecorator('besimple.soap.client');
- foreach (array('cache_type', 'user_agent') as $key) {
- if (isset($options[$key])) {
- $defOptions[$key] = $options[$key];
- }
- }
+ $container->setDefinition(
+ sprintf('besimple.soap.client.%s', $client),
+ $definition
+ );
+ $container->setDefinition(
+ $soapClientOptsService,
+ $soapClientOpts
+ );
+ $container->setDefinition(
+ $soapOptsService,
+ $soapOpts
+ );
+ $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']) {
@@ -108,49 +120,58 @@ class BeSimpleSoapExtension extends Extension
}
}
- $definition->addMethodCall('withProxy', array(
- $proxy['host'], $proxy['port'],
- $proxy['login'], $proxy['password'],
- $proxy['auth']
- ));
+ $proxy = $this->createClientProxy($client, $proxy, $container);
+ $soapClientOpts->setFactory([
+ '%besimple.soap.client_options_builder.class%',
+ 'createWithProxy'
+ ]);
+ $soapClientOpts->setArgument(0, new Reference($proxy));
}
- if (isset($defOptions['cache_type'])) {
- $defOptions['cache_type'] = $this->getCacheType($defOptions['cache_type']);
+ // 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'
+ ]);
}
-
- $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('set', array($classmap)),
+ array('__construct', array($classmap)),
));
}
return sprintf('besimple.soap.classmap.%s', $client);
}
- private function createClient($client, ContainerBuilder $container)
+ private function createClientProxy($client, array $proxy, ContainerBuilder $container)
{
- $definition = new DefinitionDecorator('besimple.soap.client');
- $container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition);
+ $definition = new DefinitionDecorator('besimple.soap.client.proxy');
+ $container->setDefinition(sprintf('besimple.soap.client.proxy.%s', $client), $definition);
- $definition->setFactory(array(
- new Reference(sprintf('besimple.soap.client.builder.%s', $client)),
- 'build'
- ));
+ 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);
}
private function createWebServiceContext(array $config, ContainerBuilder $container)
diff --git a/src/BeSimple/SoapBundle/DependencyInjection/Configuration.php b/src/BeSimple/SoapBundle/DependencyInjection/Configuration.php
index 9374bff..dd22b42 100644
--- a/src/BeSimple/SoapBundle/DependencyInjection/Configuration.php
+++ b/src/BeSimple/SoapBundle/DependencyInjection/Configuration.php
@@ -64,6 +64,10 @@ 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/Resources/config/client.xml b/src/BeSimple/SoapBundle/Resources/config/client.xml
index b1e1d3e..87b2f37 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\SoapBundle\Soap\SoapClientBuilder
- BeSimple\SoapCommon\Classmap
+ BeSimple\SoapClient\SoapClientBuilder
+ BeSimple\SoapClient\SoapClient
+ BeSimple\SoapClient\SoapServerProxy\SoapServerProxy
-
-
-
- %kernel.debug%
-
-
-
-
+
+
+
+
+
-
-
+
+
+
+
+
+
-
-
diff --git a/src/BeSimple/SoapBundle/Resources/config/soap.xml b/src/BeSimple/SoapBundle/Resources/config/soap.xml
index 28a7b1b..4ed2e29 100644
--- a/src/BeSimple/SoapBundle/Resources/config/soap.xml
+++ b/src/BeSimple/SoapBundle/Resources/config/soap.xml
@@ -1,20 +1,31 @@
+ 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\SoapBundle\Cache
- %kernel.cache_dir%/besimple/soap
+ BeSimple\SoapCommon\ClassMap
+ BeSimple\SoapClient\SoapOptions\SoapClientOptions
+ BeSimple\SoapClient\SoapClientOptionsBuilder
+ BeSimple\SoapCommon\SoapOptions\SoapOptions
+ BeSimple\SoapCommon\SoapOptionsBuilder
+ %kernel.cache_dir%
-
- %kernel.debug%
+
+
+
+
+
+
+
+
+
+ %besimple.soap.cache.file%
+
%besimple.soap.cache.type%
- %besimple.soap.cache.dir%/cache
- %besimple.soap.cache.lifetime%
- %besimple.soap.cache.limit%
+ %besimple.soap.cache.dir%
diff --git a/src/BeSimple/SoapBundle/Resources/config/webservice.xml b/src/BeSimple/SoapBundle/Resources/config/webservice.xml
index 343885c..de24fce 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\SoapServer\Classmap
+ BeSimple\SoapCommon\ClassMap
diff --git a/src/BeSimple/SoapClient/SoapClientOptionsBuilder.php b/src/BeSimple/SoapClient/SoapClientOptionsBuilder.php
index 0e84761..7d93844 100644
--- a/src/BeSimple/SoapClient/SoapClientOptionsBuilder.php
+++ b/src/BeSimple/SoapClient/SoapClientOptionsBuilder.php
@@ -45,6 +45,18 @@ class SoapClientOptionsBuilder
);
}
+ public static function createWithProxy($proxy)
+ {
+ return new SoapClientOptions(
+ SoapClientOptions::SOAP_CLIENT_TRACE_ON,
+ SoapClientOptions::SOAP_CLIENT_EXCEPTIONS_ON,
+ CurlOptions::DEFAULT_USER_AGENT,
+ SoapClientOptions::SOAP_CLIENT_COMPRESSION_NONE,
+ SoapClientOptions::SOAP_CLIENT_AUTHENTICATION_NONE,
+ $proxy
+ );
+ }
+
public static function createWithEndpointLocation($endpointLocation)
{
return new SoapClientOptions(
diff --git a/src/BeSimple/SoapCommon/Definition/Type/TypeRepository.php b/src/BeSimple/SoapCommon/Definition/Type/TypeRepository.php
index 38d0f30..3a47986 100644
--- a/src/BeSimple/SoapCommon/Definition/Type/TypeRepository.php
+++ b/src/BeSimple/SoapCommon/Definition/Type/TypeRepository.php
@@ -12,7 +12,7 @@
namespace BeSimple\SoapCommon\Definition\Type;
-use BeSimple\SoapCommon\Classmap;
+use BeSimple\SoapCommon\ClassMap;
/**
* @author Christian Kerl
@@ -27,7 +27,7 @@ class TypeRepository
protected $classmap;
- public function __construct(Classmap $classmap = null)
+ public function __construct(ClassMap $classmap = null)
{
$this->classmap = $classmap;
}
@@ -77,7 +77,7 @@ class TypeRepository
$phpType = $type->getPhpType();
$this->types[$phpType] = $type;
- $this->addClassmap($type->getXmlType(), $phpType);
+ $this->addClassMap($type->getXmlType(), $phpType);
}
public function hasType($type)
@@ -119,12 +119,12 @@ class TypeRepository
return $match[1];
}
- public function getClassmap()
+ public function getClassMap()
{
return $this->classmap;
}
- protected function addClassmap($xmlType, $phpType)
+ protected function addClassMap($xmlType, $phpType)
{
if (!$this->classmap) {
return;