Added soap client

This commit is contained in:
Francis Besset 2011-09-03 21:17:57 +02:00
parent e9864b1d02
commit 17fdd64489
3 changed files with 53 additions and 0 deletions

View File

@ -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']];

View File

@ -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

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
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">
<parameters>
<parameter key="besimple.soap.client.class">BeSimple\SoapClient\Soap\SoapClient</parameter>
</parameters>
<services>
<service id="besimple.soap.client" class="%besimple.soap.client.class%" abstract="true">
<argument>wsdl</argument>
<argument type="collection">
<argument key="debug">%kernel.debug%</argument>
</argument>
</service>
</services>
</container>