Skip to content

Commit bbd4c26

Browse files
committed
Merge branch '0.2'
2 parents 294a9fe + 2917057 commit bbd4c26

16 files changed

+180
-72
lines changed

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/Resources/config/client.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
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

2122
<service id="besimple.soap.client" factory-service="besimple.soap.client.builder" factory-method="build" class="%besimple.soap.client.builder.class%" abstract="true" />

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

src/BeSimple/SoapClient/SoapClient.php

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,6 @@ class SoapClient extends \SoapClient
4141
*/
4242
protected $tracingEnabled = false;
4343

44-
/**
45-
* Work around missing header/php://input access in PHP cli webserver by
46-
* setting headers additionally as GET parameters and SOAP request body
47-
* explicitly as POST variable.
48-
*
49-
* @var boolean
50-
*/
51-
private $cliWebserverWorkaround = false;
52-
5344
/**
5445
* cURL instance.
5546
*
@@ -108,10 +99,7 @@ public function __construct($wsdl, array $options = array())
10899
if (isset($options['soap_version'])) {
109100
$this->soapVersion = $options['soap_version'];
110101
}
111-
// activate cli webserver workaround
112-
if (isset($options['cli_webserver_workaround'])) {
113-
$this->cliWebserverWorkaround = $options['cli_webserver_workaround'];
114-
}
102+
115103
$this->curl = new Curl($options);
116104

117105
if (isset($options['extra_options'])) {
@@ -158,25 +146,6 @@ private function __doHttpRequest(SoapRequest $soapRequest)
158146

159147
$location = $soapRequest->getLocation();
160148
$content = $soapRequest->getContent();
161-
/*
162-
* Work around missing header/php://input access in PHP cli webserver by
163-
* setting headers additionally as GET parameters and SOAP request body
164-
* explicitly as POST variable
165-
*/
166-
if ($this->cliWebserverWorkaround === true) {
167-
if (strpos($location, '?') === false) {
168-
$location .= '?';
169-
} else {
170-
$location .= '&';
171-
}
172-
$location .= SoapMessage::CONTENT_TYPE_HEADER.'='.urlencode($soapRequest->getContentType());
173-
$location .= '&';
174-
$location .= SoapMessage::SOAP_ACTION_HEADER.'='.urlencode($soapRequest->getAction());
175-
176-
$content = http_build_query(array('request' => $content));
177-
178-
$headers = array();
179-
}
180149

181150
$headers = $this->filterRequestHeaders($soapRequest, $headers);
182151

@@ -189,6 +158,7 @@ private function __doHttpRequest(SoapRequest $soapRequest)
189158
$headers,
190159
$options
191160
);
161+
192162
// tracing enabled: store last request header and body
193163
if ($this->tracingEnabled === true) {
194164
$this->lastRequestHeaders = $this->curl->getRequestHeaders();

src/BeSimple/SoapClient/Tests/ServerInterop/MTOMClient.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
1919
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
2020
),
21-
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
2221
'connection_timeout' => 1,
2322
);
2423

src/BeSimple/SoapClient/Tests/ServerInterop/MtomServerInteropTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class MtomServerInteropTest extends TestCase
2020
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
2121
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
2222
),
23-
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
2423
);
2524

2625
public function testAttachment()

src/BeSimple/SoapClient/Tests/ServerInterop/SwaClient.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile',
2525
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse',
2626
),
27-
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
2827
);
2928

3029
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $options);

src/BeSimple/SoapClient/Tests/ServerInterop/SwaServerInteropTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class SwaServerInteropTest extends TestCase
2323
'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile',
2424
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse',
2525
),
26-
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
2726
);
2827

2928
public function testUploadDownloadText()

0 commit comments

Comments
 (0)