Skip to content

Commit 7a9119c

Browse files
committed
[SoapBundle] Added configuration to configure client proxy
1 parent 1a7f60b commit 7a9119c

File tree

3 files changed

+55
-4
lines changed

3 files changed

+55
-4
lines changed

src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,23 @@ private function registerClientConfiguration(array $config, ContainerBuilder $co
9898
}
9999
}
100100

101+
$proxy = $options['proxy'];
102+
if (false !== $proxy['host']) {
103+
if (null !== $proxy['auth']) {
104+
if ('basic' === $proxy['auth']) {
105+
$proxy['auth'] = \CURLAUTH_BASIC;
106+
} elseif ('ntlm' === $proxy['auth']) {
107+
$proxy['auth'] = \CURLAUTH_NTLM;
108+
}
109+
}
110+
111+
$definition->addMethodCall('withProxy', array(
112+
$proxy['host'], $proxy['port'],
113+
$proxy['login'], $proxy['password'],
114+
$proxy['auth']
115+
));
116+
}
117+
101118
if (isset($defOptions['cache_type'])) {
102119
$defOptions['cache_type'] = $this->getCacheType($defOptions['cache_type']);
103120
}

src/BeSimple/SoapBundle/DependencyInjection/Configuration.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
class Configuration
2525
{
2626
private $cacheTypes = array('none', 'disk', 'memory', 'disk_memory');
27+
private $proxyAuth = array('basic', 'ntlm');
2728

2829
/**
2930
* Generates the configuration tree.
@@ -85,12 +86,33 @@ private function addClientSection(ArrayNodeDefinition $rootNode)
8586
->scalarNode('cache_type')
8687
->validate()
8788
->ifNotInArray($this->cacheTypes)
88-
->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes)))
89+
->thenInvalid(sprintf('The cache type has to be either: %s', implode(', ', $this->cacheTypes)))
8990
->end()
9091
->end()
9192
->arrayNode('classmap')
9293
->useAttributeAsKey('name')->prototype('scalar')->end()
9394
->end()
95+
->arrayNode('proxy')
96+
->info('proxy configuration')
97+
->addDefaultsIfNotSet()
98+
->beforeNormalization()
99+
->ifTrue(function ($v) { return !is_array($v); })
100+
->then(function ($v) { return array('host' => null === $v ? false : $v); })
101+
->end()
102+
->children()
103+
->scalarNode('host')->defaultFalse()->end()
104+
->scalarNode('port')->defaultValue(3128)->end()
105+
->scalarNode('login')->defaultNull()->end()
106+
->scalarNode('password')->defaultNull()->end()
107+
->scalarNode('auth')
108+
->defaultNull()
109+
->validate()
110+
->ifNotInArray($this->proxyAuth)
111+
->thenInvalid(sprintf('The proxy auth has to be either: %s', implode(', ', $this->proxyAuth)))
112+
->end()
113+
->end()
114+
->end()
115+
->end()
94116
->end()
95117
->end()
96118
->end()

src/BeSimple/SoapBundle/Resources/doc/soapclient/configuration.rst

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Configuration
22
=============
33

4-
Minimal client configuration
5-
----------------------------
4+
Client configuration
5+
--------------------
66

77
Configure your first client in your config file:
88

@@ -12,8 +12,20 @@ Configure your first client in your config file:
1212
be_simple_soap:
1313
clients:
1414
DemoApi:
15-
wsdl: http://localhost:8086/app_dev.php/ws/DemoApi?wsdl
15+
# required
16+
wsdl: http://localhost/app_dev.php/ws/DemoApi?wsdl
1617
18+
# classmap (optional)
19+
classmap:
20+
type_name: "Full\Class\Name"
21+
22+
# proxy (optional)
23+
proxy:
24+
host: proxy.domain.name # required to enable proxy configuration
25+
port: 3128
26+
login: ~
27+
password: ~
28+
auth: ~ # can be 'basic' or 'ntlm'
1729
1830
Using client
1931
------------

0 commit comments

Comments
 (0)