Skip to content

Commit ff09e68

Browse files
author
Douglas Greenshields
committed
Merge remote-tracking branch 'upstream/master'
2 parents 8963043 + 27ebf0f commit ff09e68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+573
-245
lines changed

.travis.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ php:
44
- 5.3
55
- 5.4
66
- 5.5
7+
- 5.6
78

89
env:
9-
- SYMFONY_VERSION=2.0.*
10-
- SYMFONY_VERSION=2.1.*
11-
- SYMFONY_VERSION=2.2.*
12-
- SYMFONY_VERSION=2.3.*
13-
- SYMFONY_VERSION=dev-master
10+
- SYMFONY_VERSION=2.6.*
11+
- SYMFONY_VERSION="dev-master symfony/debug:~2.7@dev symfony/http-kernel:~2.7@dev"
1412

1513
before_script:
16-
- composer require symfony/http-foundation:${SYMFONY_VERSION} --no-interaction --prefer-source
14+
- composer self-update
15+
- composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update
16+
- composer update --no-interaction --prefer-source
1717
- ./src/BeSimple/SoapClient/Tests/bin/phpwebserver.sh
1818
- ./src/BeSimple/SoapClient/Tests/bin/axis.sh
1919

@@ -22,4 +22,4 @@ script:
2222

2323
matrix:
2424
allow_failures:
25-
- env: SYMFONY_VERSION=dev-master
25+
- env: SYMFONY_VERSION="dev-master symfony/debug:~2.7@dev symfony/http-kernel:~2.7@dev"

composer.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"ext-soap": "*",
2525
"ext-curl": "*",
2626
"ass/xmlsecurity": "~1.0",
27-
"symfony/framework-bundle": "~2.0",
28-
"symfony/twig-bundle": "~2.0",
27+
"symfony/framework-bundle": "~2.6",
28+
"symfony/twig-bundle": "~2.6",
2929
"zendframework/zend-mime": "2.2.*"
3030
},
3131
"replace": {
@@ -37,17 +37,16 @@
3737
},
3838
"require-dev": {
3939
"ext-mcrypt": "*",
40-
"mikey179/vfsStream": "dev-master",
40+
"mikey179/vfsStream": "~1.0",
4141
"symfony/filesystem": "~2.3",
4242
"symfony/process": "~2.3"
4343
},
4444
"autoload": {
4545
"psr-0": { "BeSimple\\": "src/" }
4646
},
47-
"minimum-stability": "dev",
4847
"extra": {
4948
"branch-alias": {
50-
"dev-master": "0.2-dev"
49+
"dev-master": "0.3-dev"
5150
}
5251
}
5352
}

src/BeSimple/SoapBundle/Cache.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,15 @@ public function __construct($cacheDisabled, $type, $directory, $lifetime = null,
2525

2626
BaseCache::setEnabled($isEnabled);
2727

28-
if (BaseCache::ENABLED == BaseCache::isEnabled()) {
29-
BaseCache::setType($type);
30-
BaseCache::setDirectory($directory);
28+
BaseCache::setType($type);
29+
BaseCache::setDirectory($directory);
3130

32-
if (null !== $lifetime) {
33-
BaseCache::setLifetime($lifetime);
34-
}
31+
if (null !== $lifetime) {
32+
BaseCache::setLifetime($lifetime);
33+
}
3534

36-
if (null !== $limit) {
37-
BaseCache::setLimit($limit);
38-
}
35+
if (null !== $limit) {
36+
BaseCache::setLimit($limit);
3937
}
4038
}
41-
}
39+
}

src/BeSimple/SoapBundle/DependencyInjection/BeSimpleSoapExtension.php

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,31 @@ 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
}
104121

105122
$definition->replaceArgument(1, $defOptions);
106123

107-
if (!empty($options['classmap'])) {
108-
$classmap = $this->createClientClassmap($client, $options['classmap'], $container);
109-
$definition->replaceArgument(2, new Reference($classmap));
110-
} else {
111-
$definition->replaceArgument(2, null);
112-
}
124+
$classmap = $this->createClientClassmap($client, $options['classmap'], $container);
125+
$definition->replaceArgument(2, new Reference($classmap));
113126

114127
$this->createClient($client, $container);
115128
}
@@ -120,9 +133,11 @@ private function createClientClassmap($client, array $classmap, ContainerBuilder
120133
$definition = new DefinitionDecorator('besimple.soap.classmap');
121134
$container->setDefinition(sprintf('besimple.soap.classmap.%s', $client), $definition);
122135

123-
$definition->setMethodCalls(array(
124-
array('set', array($classmap)),
125-
));
136+
if (!empty($classmap)) {
137+
$definition->setMethodCalls(array(
138+
array('set', array($classmap)),
139+
));
140+
}
126141

127142
return sprintf('besimple.soap.classmap.%s', $client);
128143
}
@@ -132,7 +147,10 @@ private function createClient($client, ContainerBuilder $container)
132147
$definition = new DefinitionDecorator('besimple.soap.client');
133148
$container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition);
134149

135-
$definition->setFactoryService(sprintf('besimple.soap.client.builder.%s', $client));
150+
$definition->setFactory(array(
151+
new Reference(sprintf('besimple.soap.client.builder.%s', $client)),
152+
'build'
153+
));
136154
}
137155

138156
private function createWebServiceContext(array $config, ContainerBuilder $container)

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/EventListener/SoapExceptionListener.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public function onKernelException(GetResponseForExceptionEvent $event)
5151
}
5252

5353
$request = $event->getRequest();
54-
if ('soap' !== $request->getRequestFormat()) {
54+
if (!in_array($request->getRequestFormat(), array('soap', 'xml'))) {
55+
return;
56+
} elseif ('xml' === $request->getRequestFormat() && '_webservice_call' !== $request->attributes->get('_route')) {
5557
return;
5658
}
5759

src/BeSimple/SoapBundle/Resources/config/client.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
</argument>
1717
<argument type="service" id="besimple.soap.classmap" />
1818
<argument type="service" id="besimple.soap.converter.collection" />
19+
<argument type="service" id="besimple.soap.cache" /> <!-- hack to load besimple cache configuration -->
1920
</service>
2021

21-
<service id="besimple.soap.client" factory-service="besimple.soap.client.builder" factory-method="build" class="%besimple.soap.client.builder.class%" abstract="true" />
22+
<service id="besimple.soap.client" class="%besimple.soap.client.builder.class%" abstract="true">
23+
<factory class="besimple.soap.client.builder" method="build" />
24+
</service>
2225

2326
<service id="besimple.soap.classmap" class="%besimple.soap.classmap.class%" abstract="true" />
2427
</services>

src/BeSimple/SoapBundle/Resources/config/soap.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<service id="besimple.soap.cache" class="%besimple.soap.cache.class%">
1313
<argument>%kernel.debug%</argument>
1414
<argument>%besimple.soap.cache.type%</argument>
15-
<argument>%besimple.soap.cache.dir%/php</argument>
15+
<argument>%besimple.soap.cache.dir%/cache</argument>
1616
<argument>%besimple.soap.cache.lifetime%</argument>
1717
<argument>%besimple.soap.cache.limit%</argument>
1818
</service>

src/BeSimple/SoapBundle/Resources/doc/index.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,8 @@ SoapServer
3333
SoapClient
3434
----------
3535

36-
Coming soon.
36+
.. toctree::
37+
:maxdepth: 1
38+
:numbered:
39+
40+
soapclient/configuration
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
Configuration
2+
=============
3+
4+
Client configuration
5+
--------------------
6+
7+
Configure your first client in your config file:
8+
9+
.. code-block:: yaml
10+
11+
# app/config/config.yml
12+
be_simple_soap:
13+
clients:
14+
DemoApi:
15+
# required
16+
wsdl: http://localhost/app_dev.php/ws/DemoApi?wsdl
17+
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'
29+
30+
Using client
31+
------------
32+
33+
.. code-block:: php
34+
35+
namespace Acme\DemoBundle\Controller;
36+
37+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
38+
39+
class DemoController extends Controller
40+
{
41+
public function helloAction($name)
42+
{
43+
// The client service name is `besimple.soap.client.demoapi`:
44+
// `besimple.soap.client.`: is the base name of your client
45+
// `demoapi`: is the name specified in your config file converted to lowercase
46+
$client = $this->container->get('besimple.soap.client.demoapi');
47+
48+
// call `hello` method on WebService with the string parameter `$name`
49+
$helloResult = $client->hello($name);
50+
51+
return $this->render('AcmeDemoBundle:Demo:hello.html.twig', array(
52+
'hello' => $helloResult,
53+
));
54+
}
55+
}
56+
57+
Classmap
58+
--------
59+
60+
Configuration
61+
~~~~~~~~~~~~~
62+
63+
.. code-block:: yaml
64+
65+
# app/config/config.yml
66+
be_simple_soap:
67+
clients:
68+
DemoApi:
69+
# ...
70+
classmap:
71+
User: Acme\DemoBundle\Api\UserApi
72+
# add other type_name: classname
73+
74+
UserApi class
75+
~~~~~~~~~~~~~
76+
77+
.. code-block:: php
78+
79+
namespace Acme\DemoBundle\Api;
80+
81+
class UserApi
82+
{
83+
private $username;
84+
85+
private $firstname;
86+
87+
private $lastname;
88+
89+
public function __construct($username)
90+
{
91+
$this->username = $username;
92+
}
93+
94+
public function getFirstname()
95+
{
96+
return $this->firstname;
97+
}
98+
99+
public function getLastname()
100+
{
101+
return $this->lastname;
102+
}
103+
}
104+
105+
Usage
106+
~~~~~
107+
108+
.. code-block:: php
109+
110+
namespace Acme\DemoBundle\Controller;
111+
112+
use Acme\DemoBundle\Api\UserApi;
113+
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
114+
115+
class DemoController extends Controller
116+
{
117+
public function userAction($username)
118+
{
119+
// The client service name is `besimple.soap.client.demoapi`:
120+
// `besimple.soap.client.`: is the base name of your client
121+
// `demoapi`: is the name specified in your config file converted to lowercase
122+
$client = $this->container->get('besimple.soap.client.demoapi');
123+
124+
// call `getUser` method on WebService with an instance of UserApi
125+
// if the `getUserByUsername` method return a `User` type then `$userResult` is an instance of UserApi
126+
$userResult = $client->getUserByUsername($username);
127+
128+
return $this->render('AcmeDemoBundle:Demo:user.html.twig', array(
129+
'user' => $userResult,
130+
));
131+
}
132+
}
133+
134+
Without classmap configuration the `$userResult` is an instance of `stdClass`:
135+
136+
.. code-block:: text
137+
138+
object(stdClass)#5561 (3) {
139+
["username"]=>
140+
string(6) "FooBar"
141+
["firstname"]=>
142+
string(3) "Foo"
143+
["lastname"]=>
144+
string(3) "Bar"
145+
}
146+
147+
With classmap configuration the `$userResult` is an instance of `Acme\DemoBundle\Api\UserApi`:
148+
149+
.. code-block:: text
150+
151+
object(Acme\DemoBundle\Api\UserApi)#208 (3) {
152+
["username":"Acme\DemoBundle\Api\UserApi":private]=>
153+
string(6) "FooBar"
154+
["firstname":"Acme\DemoBundle\Api\UserApi":private]=>
155+
string(3) "Foo"
156+
["lastname":"Acme\DemoBundle\Api\UserApi":private]=>
157+
string(3) "Bar"
158+
}

0 commit comments

Comments
 (0)