Compare commits
204 Commits
Author | SHA1 | Date | |
---|---|---|---|
1fa5c8a15e | |||
813dd52d70 | |||
8a40d23a94 | |||
5d335f2ca9 | |||
9d6468d0a6 | |||
9786f291b0 | |||
750db6692b | |||
|
9f7b7f40b8 | ||
|
87947a1e7b | ||
e024833d48 | |||
fc44014790 | |||
7ba9c4048c | |||
f0733bd671 | |||
f5e1be09de | |||
df3d75047f | |||
87350704d3 | |||
85f86469ab | |||
e1a35d1e1e | |||
30850d7a01 | |||
77403fcfbb | |||
dc63ba20e4 | |||
dad2b76165 | |||
a1695680ae | |||
95706abbd7 | |||
6d5f9ff9e5 | |||
914acccf1d | |||
0c94185907 | |||
aa0b750f47 | |||
|
cc83e1e6db | ||
|
412e7f16c9 | ||
|
729a2bc8df | ||
|
b8bf76aeb9 | ||
|
a3d691261c | ||
|
6cf62100a4 | ||
|
2e9dc9a34d | ||
|
95a91bb8bb | ||
|
ec0004ea36 | ||
|
00101ff7fb | ||
|
ef81da77ea | ||
|
54e9e0ed05 | ||
|
679b44ba13 | ||
|
a7a49b793a | ||
|
d1f5c1f674 | ||
|
fea1093bed | ||
|
9fc58e4388 | ||
|
a7c610b767 | ||
|
2b8f75b4ae | ||
|
6718703ba5 | ||
|
f9f47b913d | ||
|
ca4991a9f6 | ||
|
cdf77dacd8 | ||
|
7802a0d19f | ||
|
c4118855de | ||
|
2771991fc0 | ||
|
ceb69d97c3 | ||
|
19326bccdd | ||
|
22bde386ab | ||
|
2d36e5f060 | ||
|
873dc0ae08 | ||
|
0e24ffe23d | ||
|
d0f53bc806 | ||
|
0cb00e71b5 | ||
|
cc888bf168 | ||
|
bb95a6cb45 | ||
|
3f2a99adf6 | ||
|
ad93b5ca49 | ||
|
cdeab44c2c | ||
|
e046be22eb | ||
|
b10b5431e5 | ||
|
408d88f164 | ||
|
0e4034a093 | ||
|
fd64676312 | ||
|
4d66d072ec | ||
|
735f6a5826 | ||
|
498012697d | ||
|
b96b65cc49 | ||
|
0748b23630 | ||
|
63111261e7 | ||
|
2b91f94b8d | ||
|
1af0828b15 | ||
|
0ca2fe1fd5 | ||
|
fd923e032e | ||
|
e32514abe4 | ||
|
7322bfefd0 | ||
|
e232b1d8b9 | ||
|
1b87b4d212 | ||
|
ae746087e6 | ||
|
9312e4af6a | ||
|
c3da1d545a | ||
|
ad2bd7bc7a | ||
|
e58927469c | ||
|
45cce3a41c | ||
|
e6beef5a80 | ||
|
69a7005c35 | ||
|
073028f160 | ||
|
a9f11beb83 | ||
|
7ab8771989 | ||
|
d68c25daad | ||
|
6e117940a3 | ||
|
0c47f5a8d4 | ||
|
75a0489cce | ||
|
de5d6a2647 | ||
|
6970b7bbef | ||
|
b650254d54 | ||
|
668f2dd258 | ||
|
a8bc834077 | ||
|
f74e4b08ce | ||
|
dcd5ff5234 | ||
|
7bd8481a4e | ||
|
c82288d641 | ||
|
bb20882ade | ||
|
2264e329a1 | ||
|
b9e36b4900 | ||
|
d495f22413 | ||
|
8db9b374e4 | ||
|
f669c18c7f | ||
|
524d1f3fd7 | ||
|
ecffdc18fd | ||
|
b45202f40a | ||
|
ab83642f06 | ||
|
564005da93 | ||
|
311f9e6d08 | ||
|
e67d5aa84b | ||
|
d3023b1a5a | ||
|
21d705bbfa | ||
|
0e2c33faf8 | ||
|
cf6e147c26 | ||
|
f276a30a47 | ||
|
4edc46e67f | ||
|
a76526a5b6 | ||
|
baf32c1350 | ||
|
5c0bf914e3 | ||
|
01d10b89fd | ||
|
e1b50ce914 | ||
|
68b41acc46 | ||
|
30a9707c59 | ||
|
aee034791e | ||
|
00ddf149b0 | ||
|
476813e9bb | ||
|
f57239ad0d | ||
|
10caf27da3 | ||
|
51d1abab48 | ||
|
1224f5f40f | ||
|
f4a4619fe6 | ||
|
052ab20d67 | ||
|
dd7b6904b6 | ||
|
c4d993585f | ||
|
bd1fbf9cfc | ||
|
5fbcfb3e22 | ||
|
84c37b1d24 | ||
|
8d033f9afc | ||
|
bf494a42b5 | ||
|
969709cae5 | ||
|
155aa029ce | ||
|
3c0f731086 | ||
|
374c64538a | ||
|
4d7894b66e | ||
|
0a157748a8 | ||
|
c4a9b58b08 | ||
|
fc15bf36ab | ||
|
8462233a08 | ||
|
03227295f6 | ||
|
f285adfa14 | ||
|
2ecdbe9714 | ||
|
e5c54164c1 | ||
|
27ebf0fbce | ||
|
855e382590 | ||
|
2974a4f838 | ||
|
fb56d51bd8 | ||
|
f2a8a7ebb3 | ||
|
7a9119cef1 | ||
|
1a7f60b679 | ||
|
70db0c42fd | ||
|
960c9f557a | ||
|
33d641de4e | ||
|
bbd4c26134 | ||
|
29170576c2 | ||
|
50ab5a93ad | ||
|
1290573285 | ||
|
f5675f6ece | ||
|
15b208d861 | ||
|
294a9fe90e | ||
|
313840d5a4 | ||
|
8e4d8b0300 | ||
|
621b2080e0 | ||
|
fe67cff5ff | ||
|
e676eb0432 | ||
|
fd402731af | ||
|
f5d6f5e759 | ||
|
726ee89936 | ||
|
36a368e695 | ||
|
e2de214ea5 | ||
|
3cfeea8371 | ||
|
c24e8775bf | ||
|
b3c6353af8 | ||
|
10bba6a3bd | ||
|
a122f2a0f6 | ||
|
8d13d2dd5c | ||
|
1c1cd377f1 | ||
|
1efa348ae5 | ||
|
ccc4d57501 | ||
|
740f146bad | ||
|
5e8e669299 | ||
|
f9e230400d |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,6 @@
|
|||||||
/vendor/
|
/vendor/
|
||||||
composer.lock
|
composer.lock
|
||||||
|
composer.phar
|
||||||
phpunit.xml
|
phpunit.xml
|
||||||
|
.idea
|
||||||
|
.php_cs.cache
|
||||||
|
20
.travis.yml
20
.travis.yml
@ -1,19 +1,19 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 5.3
|
- 5.6
|
||||||
- 5.4
|
- 7.0
|
||||||
- 5.5
|
- 7.1
|
||||||
|
|
||||||
env:
|
env:
|
||||||
- SYMFONY_VERSION=2.0.*
|
- SYMFONY_VERSION=2.8.*
|
||||||
- SYMFONY_VERSION=2.1.*
|
- SYMFONY_VERSION="dev-master symfony/debug:~2.8@dev symfony/http-kernel:~2.8@dev"
|
||||||
- SYMFONY_VERSION=2.2.*
|
|
||||||
- SYMFONY_VERSION=2.3.*
|
|
||||||
- SYMFONY_VERSION=dev-master
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer require symfony/http-foundation:${SYMFONY_VERSION} --no-interaction --prefer-source
|
- phpenv config-add myphp.ini
|
||||||
|
- composer self-update
|
||||||
|
- composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update
|
||||||
|
- composer update --no-interaction --prefer-source
|
||||||
- ./src/BeSimple/SoapClient/Tests/bin/phpwebserver.sh
|
- ./src/BeSimple/SoapClient/Tests/bin/phpwebserver.sh
|
||||||
- ./src/BeSimple/SoapClient/Tests/bin/axis.sh
|
- ./src/BeSimple/SoapClient/Tests/bin/axis.sh
|
||||||
|
|
||||||
@ -22,4 +22,4 @@ script:
|
|||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
- env: SYMFONY_VERSION=dev-master
|
- env: SYMFONY_VERSION="dev-master symfony/debug:~2.8@dev symfony/http-kernel:~2.8@dev"
|
||||||
|
154
README.md
154
README.md
@ -1,56 +1,146 @@
|
|||||||
# BeSimpleSoap
|
# BeSimpleSoap (Symfony 3.4 / 4.x)
|
||||||
|
|
||||||
Build SOAP and WSDL based web services
|
This fork provides the BeSimpleSoap bundle, updated to be compatible with Symfony 3.4 and 4.x (as well as with PHP 7.0-7.4).
|
||||||
|
|
||||||
|
We forked the official [BeSimpleSoap](https://github.com/BeSimple/BeSimpleSoap) repository in order to sucessfully maintain some of our projects.
|
||||||
|
|
||||||
|
We now have integrated changes and fixes from sub-forks (thank you guys!), and we should be up to date now :)
|
||||||
|
|
||||||
|
This fork is maintained by people from [Cadoles](https://www.cadoles.com/).
|
||||||
|
|
||||||
|
# Contributing
|
||||||
|
|
||||||
|
We do welcome pull requests :) please include tests if you can.
|
||||||
|
|
||||||
|
Running tests can be done by running `php vendor/bin/phpunit`.
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
If you do not yet have composer, follow instructions on the [Composer website](https://getcomposer.org/download/) to install it.
|
||||||
|
|
||||||
|
Then just running:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ composer require cadoles/soap
|
||||||
|
```
|
||||||
|
|
||||||
|
should be enough to get you up and running.
|
||||||
|
|
||||||
# Components
|
# Components
|
||||||
|
|
||||||
BeSimpleSoap consists of five components ...
|
BeSimpleSoap consists of five components ...
|
||||||
|
|
||||||
## BeSimpleSoapBundle
|
|
||||||
|
|
||||||
The BeSimpleSoapBundle is a Symfony2 bundle to build WSDL and SOAP based web services.
|
|
||||||
For further information see the [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapBundle/README.md).
|
|
||||||
|
|
||||||
## BeSimpleSoapClient
|
## BeSimpleSoapClient
|
||||||
|
|
||||||
The BeSimpleSoapClient is a component that extends the native PHP SoapClient with further features like SwA, MTOM and WS-Security.
|
**Refactored** BeSimpleSoapClient is a component that extends the native PHP SoapClient with further features like SwA and WS-Security.
|
||||||
For further information see the [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapClient/README.md).
|
|
||||||
|
|
||||||
## BeSimpleSoapCommon
|
|
||||||
|
|
||||||
The BeSimpleSoapCommon component contains functionylity shared by both the server and client implementations.
|
|
||||||
For further information see the [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapCommon/README.md).
|
|
||||||
|
|
||||||
|
|
||||||
## BeSimpleSoapServer
|
## BeSimpleSoapServer
|
||||||
|
|
||||||
The BeSimpleSoapServer is a component that extends the native PHP SoapServer with further features like SwA, MTOM and WS-Security.
|
**Refactored** BeSimpleSoapServer is a component that extends the native PHP SoapServer with further features like SwA and WS-Security.
|
||||||
For further information see the [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapServer/README.md).
|
|
||||||
|
## BeSimpleSoapCommon
|
||||||
|
|
||||||
|
**Refactored** BeSimpleSoapCommon component contains functionality shared by both the server and client implementations.
|
||||||
|
|
||||||
## BeSimpleSoapWsdl
|
## BeSimpleSoapWsdl
|
||||||
|
|
||||||
For further information see the [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapWsdl/README.md).
|
**Untouched!**
|
||||||
|
The component is not affected by refactoring so it should work properly.
|
||||||
|
For further information see the original [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapWsdl/README.md).
|
||||||
|
|
||||||
# Installation
|
## BeSimpleSoapBundle
|
||||||
|
|
||||||
If you do not yet have composer, install it like this:
|
**Unsupported!**
|
||||||
|
The BeSimpleSoapBundle is a Symfony2 bundle to build WSDL and SOAP based web services.
|
||||||
|
For further information see the the original [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapBundle/README.md).
|
||||||
|
*Will not work since the Symfony libraries were removed and usages of other components were not refactored. Feel free to fork this repository and fix it!*
|
||||||
|
|
||||||
```sh
|
# How to use
|
||||||
curl -s http://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin
|
|
||||||
|
You can investigate the unit tests dir ``tests`` in order to get a clue.
|
||||||
|
Forget about associative arrays, vague configurations, multiple extension and silent errors!
|
||||||
|
This may look a bit more complex at the first sight,
|
||||||
|
but it will guide you to configure and set up your client or server properly.
|
||||||
|
|
||||||
|
## Example of soap client call
|
||||||
|
|
||||||
|
```php
|
||||||
|
$soapClientBuilder = new SoapClientBuilder();
|
||||||
|
$soapClient = $soapClientBuilder->build(
|
||||||
|
SoapClientOptionsBuilder::createWithDefaults(),
|
||||||
|
SoapOptionsBuilder::createWithDefaults('http://path/to/wsdlfile.wsdl')
|
||||||
|
);
|
||||||
|
$myRequest = new MyRequest();
|
||||||
|
$myRequest->attribute = 'string value';
|
||||||
|
$soapResponse = $soapClient->soapCall('myMethod', [$myRequest]);
|
||||||
|
|
||||||
|
var_dump($soapResponse); // Contains Response, Attachments
|
||||||
```
|
```
|
||||||
|
|
||||||
Create a `composer.json` file:
|
### Something wrong?!
|
||||||
|
|
||||||
```json
|
Turn on the tracking and catch `SoapFaultWithTracingData` exception to get some sweets :)
|
||||||
|
|
||||||
|
```php
|
||||||
|
try {
|
||||||
|
$soapResponse = $soapClient->soapCall('myMethod', [$myRequest]);
|
||||||
|
} catch (SoapFaultWithTracingData $fault) {
|
||||||
|
var_dump($fault->getSoapResponseTracingData()->getLastRequest());
|
||||||
|
}
|
||||||
|
```
|
||||||
|
In this example, a ``MyRequest`` object has been used to describe request.
|
||||||
|
Using a ClassMap, you help SoapClient to turn it into XML request.
|
||||||
|
|
||||||
|
## Example of soap server handling
|
||||||
|
|
||||||
|
Starting a SOAP server is a bit more complex.
|
||||||
|
I recommend you to inspect SoapServer unit tests for inspiration.
|
||||||
|
|
||||||
|
```php
|
||||||
|
$dummyService = new DummyService();
|
||||||
|
$classMap = new ClassMap();
|
||||||
|
foreach ($dummyService->getClassMap() as $type => $className) {
|
||||||
|
$classMap->add($type, $className);
|
||||||
|
}
|
||||||
|
$soapServerBuilder = new SoapServerBuilder();
|
||||||
|
$soapServerOptions = SoapServerOptionsBuilder::createWithDefaults($dummyService);
|
||||||
|
$soapOptions = SoapOptionsBuilder::createWithClassMap($dummyService->getWsdlPath(), $classMap);
|
||||||
|
$soapServer = $soapServerBuilder->build($soapServerOptions, $soapOptions);
|
||||||
|
|
||||||
|
$request = $soapServer->createRequest(
|
||||||
|
$dummyService->getEndpoint(),
|
||||||
|
'DummyService.dummyServiceMethod',
|
||||||
|
'text/xml;charset=UTF-8',
|
||||||
|
'<received><soap><request><here /></request></soap></received>'
|
||||||
|
);
|
||||||
|
$response = $soapServer->handleRequest($request);
|
||||||
|
|
||||||
|
var_dump($response); // Contains Response, Attachments
|
||||||
|
```
|
||||||
|
|
||||||
|
In this example, a ``DummyService`` service has been used to handle request.
|
||||||
|
Using a service can help you create coherent SoapServer endpoints.
|
||||||
|
Service can hold an endpoint URL, WSDL path and a class map as associative array.
|
||||||
|
You can hold a class map as ``ClassMap`` object directly in the ``DummyService`` instead of array.
|
||||||
|
|
||||||
|
In the service you should describe SOAP methods from given WSDL.
|
||||||
|
In the example, the dummyServiceMethod is called.
|
||||||
|
The method will receive request object and return response object that are matched according to the class map.
|
||||||
|
|
||||||
|
See a simplified implementation of ``dummyServiceMethod`` to get a clue:
|
||||||
|
|
||||||
|
```php
|
||||||
|
/**
|
||||||
|
* @param DummyServiceRequest $dummyServiceRequest
|
||||||
|
* @return DummyServiceResponse
|
||||||
|
*/
|
||||||
|
public function dummyServiceMethod(DummyServiceRequest $dummyServiceRequest)
|
||||||
{
|
{
|
||||||
"require": {
|
$response = new DummyServiceResponse();
|
||||||
"besimple/soap": "0.2.*@dev"
|
$response->status = true;
|
||||||
}
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
Now you are ready to install the library:
|
For further information and getting inspiration for your implementation, see the unit tests in ``tests`` dir.
|
||||||
|
|
||||||
```sh
|
|
||||||
php /usr/local/bin/composer.phar install
|
|
||||||
```
|
|
@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "besimple/soap",
|
"name": "cadoles/soap",
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"description": "Build and consume SOAP and WSDL based web services",
|
"description": "Build and consume SOAP and WSDL based web services",
|
||||||
"keywords": ["soap"],
|
"keywords": ["soap"],
|
||||||
"homepage": "http://besim.pl",
|
"homepage": "https://github.com/Cadoles/BeSimpleSoap",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@ -20,34 +20,34 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.0",
|
"php": ">=7.0",
|
||||||
"ext-soap": "*",
|
"ext-soap": "*",
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"ass/xmlsecurity": "~1.0",
|
"ass/xmlsecurity": "~1.0",
|
||||||
"symfony/framework-bundle": "~2.0",
|
"symfony/framework-bundle": "~3.4|~4.0",
|
||||||
"symfony/twig-bundle": "~2.0",
|
"symfony/twig-bundle": "~3.4|~4.0",
|
||||||
"zendframework/zend-mime": "2.1.*"
|
"laminas/laminas-mime": "~2.1"
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
"besimple/soap-bundle": "self.version",
|
"besimple/soap-bundle": "self.version",
|
||||||
"besimple/soap-client": "self.version",
|
"besimple/soap-client": "self.version",
|
||||||
"besimple/soap-common": "self.version",
|
"besimple/soap-common": "self.version",
|
||||||
"besimple/soap-server": "self.version",
|
"besimple/soap-server": "self.version",
|
||||||
"besimple/soap-wsdl": "self.version"
|
"besimple/soap-wsdl": "self.version",
|
||||||
|
"cocciagialla/soap": "self.version"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-mcrypt": "*",
|
"mikey179/vfsstream": "~1.6.5",
|
||||||
"mikey179/vfsStream": "dev-master",
|
|
||||||
"symfony/filesystem": "~2.3",
|
"symfony/filesystem": "~2.3",
|
||||||
"symfony/process": "~2.3"
|
"symfony/process": "~2.3",
|
||||||
|
"phpunit/phpunit": "^5.7"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": { "BeSimple\\": "src/" }
|
"psr-0": { "BeSimple\\": "src/" }
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "0.2-dev"
|
"dev-master": "5.2.0-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1
src/BeSimple/SoapBundle/.gitignore
vendored
1
src/BeSimple/SoapBundle/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
vendor/
|
vendor/
|
||||||
composer.lock
|
composer.lock
|
||||||
phpunit.xml
|
phpunit.xml
|
||||||
|
.idea/
|
||||||
|
@ -25,7 +25,6 @@ class Cache
|
|||||||
|
|
||||||
BaseCache::setEnabled($isEnabled);
|
BaseCache::setEnabled($isEnabled);
|
||||||
|
|
||||||
if (BaseCache::ENABLED == BaseCache::isEnabled()) {
|
|
||||||
BaseCache::setType($type);
|
BaseCache::setType($type);
|
||||||
BaseCache::setDirectory($directory);
|
BaseCache::setDirectory($directory);
|
||||||
|
|
||||||
@ -38,4 +37,3 @@ class Cache
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
@ -15,21 +15,26 @@ namespace BeSimple\SoapBundle\Controller;
|
|||||||
use BeSimple\SoapBundle\Handler\ExceptionHandler;
|
use BeSimple\SoapBundle\Handler\ExceptionHandler;
|
||||||
use BeSimple\SoapBundle\Soap\SoapRequest;
|
use BeSimple\SoapBundle\Soap\SoapRequest;
|
||||||
use BeSimple\SoapBundle\Soap\SoapResponse;
|
use BeSimple\SoapBundle\Soap\SoapResponse;
|
||||||
|
use BeSimple\SoapBundle\WebServiceContext;
|
||||||
use BeSimple\SoapServer\SoapServerBuilder;
|
use BeSimple\SoapServer\SoapServerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\FlattenException;
|
use Symfony\Component\Debug\Exception\FlattenException;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||||
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
||||||
|
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christian Kerl <christian-kerl@web.de>
|
* @author Christian Kerl <christian-kerl@web.de>
|
||||||
* @author Francis Besset <francis.besset@gmail.com>
|
* @author Francis Besset <francis.besset@gmail.com>
|
||||||
*/
|
*/
|
||||||
class SoapWebServiceController extends ContainerAware
|
class SoapWebServiceController implements ContainerAwareInterface
|
||||||
{
|
{
|
||||||
|
use ContainerAwareTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var \SoapServer
|
* @var \SoapServer
|
||||||
*/
|
*/
|
||||||
@ -53,18 +58,19 @@ class SoapWebServiceController extends ContainerAware
|
|||||||
/**
|
/**
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
private $headers = array();
|
private $headers = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return \BeSimple\SoapBundle\Soap\SoapResponse
|
* @return \BeSimple\SoapBundle\Soap\SoapResponse
|
||||||
*/
|
*/
|
||||||
public function callAction($webservice)
|
public function callAction($webservice)
|
||||||
{
|
{
|
||||||
|
/** @var WebServiceContext $webServiceContext */
|
||||||
$webServiceContext = $this->getWebServiceContext($webservice);
|
$webServiceContext = $this->getWebServiceContext($webservice);
|
||||||
|
|
||||||
$this->serviceBinder = $webServiceContext->getServiceBinder();
|
$this->serviceBinder = $webServiceContext->getServiceBinder();
|
||||||
|
|
||||||
$this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request'));
|
$this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request_stack')->getCurrentRequest());
|
||||||
$this->soapServer = $webServiceContext
|
$this->soapServer = $webServiceContext
|
||||||
->getServerBuilder()
|
->getServerBuilder()
|
||||||
->withSoapVersion11()
|
->withSoapVersion11()
|
||||||
@ -83,19 +89,26 @@ class SoapWebServiceController extends ContainerAware
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Symfony\Component\HttpFoundation\Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function definitionAction($webservice)
|
public function definitionAction($webservice)
|
||||||
{
|
{
|
||||||
|
$routeName = $webservice.'_webservice_call';
|
||||||
|
$result = $this->container->get('router')->getRouteCollection()->get($routeName);
|
||||||
|
if (null === $result) {
|
||||||
|
$routeName = '_webservice_call';
|
||||||
|
}
|
||||||
|
|
||||||
$response = new Response($this->getWebServiceContext($webservice)->getWsdlFileContent(
|
$response = new Response($this->getWebServiceContext($webservice)->getWsdlFileContent(
|
||||||
$this->container->get('router')->generate(
|
$this->container->get('router')->generate(
|
||||||
'_webservice_call',
|
$routeName,
|
||||||
array('webservice' => $webservice),
|
['webservice' => $webservice],
|
||||||
true
|
UrlGeneratorInterface::ABSOLUTE_URL
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$request = $this->container->get('request');
|
/** @var Request $request */
|
||||||
|
$request = $this->container->get('request_stack')->getCurrentRequest();
|
||||||
$query = $request->query;
|
$query = $request->query;
|
||||||
if ($query->has('wsdl') || $query->has('WSDL')) {
|
if ($query->has('wsdl') || $query->has('WSDL')) {
|
||||||
$request->setRequestFormat('wsdl');
|
$request->setRequestFormat('wsdl');
|
||||||
@ -121,14 +134,14 @@ class SoapWebServiceController extends ContainerAware
|
|||||||
throw new \LogicException(sprintf('The parameter "%s" is required in Request::$query parameter bag to generate the SoapFault.', '_besimple_soap_webservice'), null, $e);
|
throw new \LogicException(sprintf('The parameter "%s" is required in Request::$query parameter bag to generate the SoapFault.', '_besimple_soap_webservice'), null, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = 'TwigBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error').'.txt.twig';
|
$view = '@Twig/Exception/'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error').'.txt.twig';
|
||||||
$code = $exception->getStatusCode();
|
$code = $exception->getStatusCode();
|
||||||
$details = $this->container->get('templating')->render($view, array(
|
$details = $this->container->get('twig')->render($view, [
|
||||||
'status_code' => $code,
|
'status_code' => $code,
|
||||||
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
|
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
|
||||||
'exception' => $exception,
|
'exception' => $exception,
|
||||||
'logger' => $logger,
|
'logger' => $logger,
|
||||||
));
|
]);
|
||||||
|
|
||||||
$handler = new ExceptionHandler($exception, $details);
|
$handler = new ExceptionHandler($exception, $details);
|
||||||
if ($soapFault = $request->query->get('_besimple_soap_fault')) {
|
if ($soapFault = $request->query->get('_besimple_soap_fault')) {
|
||||||
@ -220,7 +233,7 @@ class SoapWebServiceController extends ContainerAware
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the SoapResponse
|
* Set the SoapResponse.
|
||||||
*
|
*
|
||||||
* @param Response $response A response to check and set
|
* @param Response $response A response to check and set
|
||||||
*
|
*
|
||||||
@ -237,7 +250,7 @@ class SoapWebServiceController extends ContainerAware
|
|||||||
return $this->soapResponse = $response;
|
return $this->soapResponse = $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getWebServiceContext($webservice)
|
protected function getWebServiceContext($webservice)
|
||||||
{
|
{
|
||||||
$context = sprintf('besimple.soap.context.%s', $webservice);
|
$context = sprintf('besimple.soap.context.%s', $webservice);
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ namespace BeSimple\SoapBundle\Converter;
|
|||||||
|
|
||||||
use BeSimple\SoapBundle\Soap\SoapRequest;
|
use BeSimple\SoapBundle\Soap\SoapRequest;
|
||||||
use BeSimple\SoapBundle\Soap\SoapResponse;
|
use BeSimple\SoapBundle\Soap\SoapResponse;
|
||||||
use BeSimple\SoapBundle\Util\String;
|
use BeSimple\SoapBundle\Util\BsString;
|
||||||
use BeSimple\SoapCommon\Converter\TypeConverterInterface;
|
use BeSimple\SoapCommon\Converter\TypeConverterInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +40,7 @@ class XopIncludeTypeConverter implements TypeConverterInterface
|
|||||||
|
|
||||||
$ref = $include->getAttribute('href');
|
$ref = $include->getAttribute('href');
|
||||||
|
|
||||||
if (String::startsWith($ref, 'cid:')) {
|
if (BsString::startsWith($ref, 'cid:')) {
|
||||||
$cid = urldecode(substr($ref, 4));
|
$cid = urldecode(substr($ref, 4));
|
||||||
|
|
||||||
return $request->getSoapAttachments()->get($cid)->getContent();
|
return $request->getSoapAttachments()->get($cid)->getContent();
|
||||||
|
@ -17,10 +17,11 @@ use BeSimple\SoapCommon\Cache;
|
|||||||
use Symfony\Component\Config\Definition\Processor;
|
use Symfony\Component\Config\Definition\Processor;
|
||||||
use Symfony\Component\Config\FileLocator;
|
use Symfony\Component\Config\FileLocator;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
use Symfony\Component\DependencyInjection\Reference;
|
||||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||||
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BeSimpleSoapExtension.
|
* BeSimpleSoapExtension.
|
||||||
@ -80,10 +81,14 @@ class BeSimpleSoapExtension extends Extension
|
|||||||
|
|
||||||
private function registerClientConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
private function registerClientConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
||||||
{
|
{
|
||||||
|
if (3 === Kernel::MAJOR_VERSION) {
|
||||||
|
$loader->load('client3.xml');
|
||||||
|
} else {
|
||||||
$loader->load('client.xml');
|
$loader->load('client.xml');
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($config as $client => $options) {
|
foreach ($config as $client => $options) {
|
||||||
$definition = new DefinitionDecorator('besimple.soap.client.builder');
|
$definition = new ChildDefinition('besimple.soap.client.builder');
|
||||||
$container->setDefinition(sprintf('besimple.soap.client.builder.%s', $client), $definition);
|
$container->setDefinition(sprintf('besimple.soap.client.builder.%s', $client), $definition);
|
||||||
|
|
||||||
$definition->replaceArgument(0, $options['wsdl']);
|
$definition->replaceArgument(0, $options['wsdl']);
|
||||||
@ -98,6 +103,23 @@ class BeSimpleSoapExtension extends Extension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$proxy = $options['proxy'];
|
||||||
|
if (false !== $proxy['host']) {
|
||||||
|
if (null !== $proxy['auth']) {
|
||||||
|
if ('basic' === $proxy['auth']) {
|
||||||
|
$proxy['auth'] = \CURLAUTH_BASIC;
|
||||||
|
} elseif ('ntlm' === $proxy['auth']) {
|
||||||
|
$proxy['auth'] = \CURLAUTH_NTLM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$definition->addMethodCall('withProxy', array(
|
||||||
|
$proxy['host'], $proxy['port'],
|
||||||
|
$proxy['login'], $proxy['password'],
|
||||||
|
$proxy['auth']
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($defOptions['cache_type'])) {
|
if (isset($defOptions['cache_type'])) {
|
||||||
$defOptions['cache_type'] = $this->getCacheType($defOptions['cache_type']);
|
$defOptions['cache_type'] = $this->getCacheType($defOptions['cache_type']);
|
||||||
}
|
}
|
||||||
@ -113,7 +135,7 @@ class BeSimpleSoapExtension extends Extension
|
|||||||
|
|
||||||
private function createClientClassmap($client, array $classmap, ContainerBuilder $container)
|
private function createClientClassmap($client, array $classmap, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$definition = new DefinitionDecorator('besimple.soap.classmap');
|
$definition = new ChildDefinition('besimple.soap.classmap');
|
||||||
$container->setDefinition(sprintf('besimple.soap.classmap.%s', $client), $definition);
|
$container->setDefinition(sprintf('besimple.soap.classmap.%s', $client), $definition);
|
||||||
|
|
||||||
if (!empty($classmap)) {
|
if (!empty($classmap)) {
|
||||||
@ -127,11 +149,19 @@ class BeSimpleSoapExtension extends Extension
|
|||||||
|
|
||||||
private function createClient($client, ContainerBuilder $container)
|
private function createClient($client, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
$definition = new DefinitionDecorator('besimple.soap.client');
|
$definition = new ChildDefinition('besimple.soap.client');
|
||||||
$container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition);
|
$container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition);
|
||||||
|
|
||||||
|
if (Kernel::MAJOR_VERSION >= 3) {
|
||||||
|
$definition->setFactory(array(
|
||||||
|
new Reference(sprintf('besimple.soap.client.builder.%s', $client)),
|
||||||
|
'build'
|
||||||
|
));
|
||||||
|
$definition->setPublic(true);
|
||||||
|
} else {
|
||||||
$definition->setFactoryService(sprintf('besimple.soap.client.builder.%s', $client));
|
$definition->setFactoryService(sprintf('besimple.soap.client.builder.%s', $client));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function createWebServiceContext(array $config, ContainerBuilder $container)
|
private function createWebServiceContext(array $config, ContainerBuilder $container)
|
||||||
{
|
{
|
||||||
@ -139,7 +169,7 @@ class BeSimpleSoapExtension extends Extension
|
|||||||
unset($config['binding']);
|
unset($config['binding']);
|
||||||
|
|
||||||
$contextId = 'besimple.soap.context.'.$config['name'];
|
$contextId = 'besimple.soap.context.'.$config['name'];
|
||||||
$definition = new DefinitionDecorator('besimple.soap.context.'.$bindingSuffix);
|
$definition = new ChildDefinition('besimple.soap.context.'.$bindingSuffix);
|
||||||
$container->setDefinition($contextId, $definition);
|
$container->setDefinition($contextId, $definition);
|
||||||
|
|
||||||
if (isset($config['cache_type'])) {
|
if (isset($config['cache_type'])) {
|
||||||
@ -148,6 +178,7 @@ class BeSimpleSoapExtension extends Extension
|
|||||||
|
|
||||||
$options = $container
|
$options = $container
|
||||||
->getDefinition('besimple.soap.context.'.$bindingSuffix)
|
->getDefinition('besimple.soap.context.'.$bindingSuffix)
|
||||||
|
->setPublic(true)
|
||||||
->getArgument(2);
|
->getArgument(2);
|
||||||
|
|
||||||
$definition->replaceArgument(2, array_merge($options, $config));
|
$definition->replaceArgument(2, array_merge($options, $config));
|
||||||
|
@ -24,6 +24,7 @@ use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
|||||||
class Configuration
|
class Configuration
|
||||||
{
|
{
|
||||||
private $cacheTypes = array('none', 'disk', 'memory', 'disk_memory');
|
private $cacheTypes = array('none', 'disk', 'memory', 'disk_memory');
|
||||||
|
private $proxyAuth = array('basic', 'ntlm');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the configuration tree.
|
* Generates the configuration tree.
|
||||||
@ -85,12 +86,37 @@ class Configuration
|
|||||||
->scalarNode('cache_type')
|
->scalarNode('cache_type')
|
||||||
->validate()
|
->validate()
|
||||||
->ifNotInArray($this->cacheTypes)
|
->ifNotInArray($this->cacheTypes)
|
||||||
->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes)))
|
->thenInvalid(sprintf('The cache type has to be either: %s', implode(', ', $this->cacheTypes)))
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->arrayNode('classmap')
|
->arrayNode('classmap')
|
||||||
->useAttributeAsKey('name')->prototype('scalar')->end()
|
->useAttributeAsKey('name')->prototype('scalar')->end()
|
||||||
->end()
|
->end()
|
||||||
|
->arrayNode('proxy')
|
||||||
|
->info('proxy configuration')
|
||||||
|
->addDefaultsIfNotSet()
|
||||||
|
->beforeNormalization()
|
||||||
|
->ifTrue(function ($v) {
|
||||||
|
return !is_array($v);
|
||||||
|
})
|
||||||
|
->then(function ($v) {
|
||||||
|
return array('host' => null === $v ? false : $v);
|
||||||
|
})
|
||||||
|
->end()
|
||||||
|
->children()
|
||||||
|
->scalarNode('host')->defaultFalse()->end()
|
||||||
|
->scalarNode('port')->defaultValue(3128)->end()
|
||||||
|
->scalarNode('login')->defaultNull()->end()
|
||||||
|
->scalarNode('password')->defaultNull()->end()
|
||||||
|
->scalarNode('auth')
|
||||||
|
->defaultNull()
|
||||||
|
->validate()
|
||||||
|
->ifNotInArray($this->proxyAuth)
|
||||||
|
->thenInvalid(sprintf('The proxy auth has to be either: %s', implode(', ', $this->proxyAuth)))
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
->end()
|
->end()
|
||||||
|
@ -51,7 +51,9 @@ class SoapExceptionListener extends ExceptionListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
$request = $event->getRequest();
|
$request = $event->getRequest();
|
||||||
if ('soap' !== $request->getRequestFormat()) {
|
if (!in_array($request->getRequestFormat(), array('soap', 'xml'))) {
|
||||||
|
return;
|
||||||
|
} elseif ('xml' === $request->getRequestFormat() && '_webservice_call' !== $request->attributes->get('_route')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
namespace BeSimple\SoapBundle\Handler;
|
namespace BeSimple\SoapBundle\Handler;
|
||||||
|
|
||||||
use BeSimple\SoapServer\Exception\ReceiverSoapFault;
|
use BeSimple\SoapServer\Exception\ReceiverSoapFault;
|
||||||
|
use Symfony\Component\Debug\Exception\FlattenException;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Exception\FlattenException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Francis Besset <francis.besset@gmail.com>
|
* @author Francis Besset <francis.besset@gmail.com>
|
||||||
|
@ -16,9 +16,12 @@
|
|||||||
</argument>
|
</argument>
|
||||||
<argument type="service" id="besimple.soap.classmap" />
|
<argument type="service" id="besimple.soap.classmap" />
|
||||||
<argument type="service" id="besimple.soap.converter.collection" />
|
<argument type="service" id="besimple.soap.converter.collection" />
|
||||||
|
<argument type="service" id="besimple.soap.cache" /> <!-- hack to load besimple cache configuration -->
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="besimple.soap.client" factory-service="besimple.soap.client.builder" factory-method="build" class="%besimple.soap.client.builder.class%" abstract="true" />
|
<service id="besimple.soap.client" class="%besimple.soap.client.builder.class%" abstract="true">
|
||||||
|
<factory service="besimple.soap.client.builder" method="build" />
|
||||||
|
</service>
|
||||||
|
|
||||||
<service id="besimple.soap.classmap" class="%besimple.soap.classmap.class%" abstract="true" />
|
<service id="besimple.soap.classmap" class="%besimple.soap.classmap.class%" abstract="true" />
|
||||||
</services>
|
</services>
|
||||||
|
29
src/BeSimple/SoapBundle/Resources/config/client3.xml
Normal file
29
src/BeSimple/SoapBundle/Resources/config/client3.xml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<?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.builder.class">BeSimple\SoapBundle\Soap\SoapClientBuilder</parameter>
|
||||||
|
<parameter key="besimple.soap.classmap.class">BeSimple\SoapCommon\Classmap</parameter>
|
||||||
|
</parameters>
|
||||||
|
|
||||||
|
<services>
|
||||||
|
<service id="besimple.soap.client.builder" class="%besimple.soap.client.builder.class%" abstract="true">
|
||||||
|
<argument /> <!-- wsdl URI -->
|
||||||
|
<argument type="collection">
|
||||||
|
<argument key="debug">%kernel.debug%</argument>
|
||||||
|
</argument>
|
||||||
|
<argument type="service" id="besimple.soap.classmap" />
|
||||||
|
<argument type="service" id="besimple.soap.converter.collection" />
|
||||||
|
<argument type="service" id="besimple.soap.cache" /> <!-- hack to load besimple cache configuration -->
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="besimple.soap.client" class="%besimple.soap.client.builder.class%" abstract="true">
|
||||||
|
<factory service="besimple.soap.client.builder" method="build" />
|
||||||
|
</service>
|
||||||
|
|
||||||
|
<service id="besimple.soap.classmap" class="%besimple.soap.classmap.class%" abstract="true" />
|
||||||
|
</services>
|
||||||
|
|
||||||
|
</container>
|
@ -4,15 +4,13 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
|
||||||
|
|
||||||
<route id="_webservice_call" pattern="/{webservice}">
|
<route id="_webservice_call" path="/{webservice}" methods="POST">
|
||||||
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default>
|
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default>
|
||||||
<default key="_format">xml</default>
|
<default key="_format">xml</default>
|
||||||
<requirement key="_method">POST</requirement>
|
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
<route id="_webservice_definition" pattern="/{webservice}">
|
<route id="_webservice_definition" path="/{webservice}" methods="GET">
|
||||||
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default>
|
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default>
|
||||||
<default key="_format">xml</default>
|
<default key="_format">xml</default>
|
||||||
<requirement key="_method">GET</requirement>
|
|
||||||
</route>
|
</route>
|
||||||
</routes>
|
</routes>
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
<service id="besimple.soap.cache" class="%besimple.soap.cache.class%">
|
<service id="besimple.soap.cache" class="%besimple.soap.cache.class%">
|
||||||
<argument>%kernel.debug%</argument>
|
<argument>%kernel.debug%</argument>
|
||||||
<argument>%besimple.soap.cache.type%</argument>
|
<argument>%besimple.soap.cache.type%</argument>
|
||||||
<argument>%besimple.soap.cache.dir%/php</argument>
|
<argument>%besimple.soap.cache.dir%/cache</argument>
|
||||||
<argument>%besimple.soap.cache.lifetime%</argument>
|
<argument>%besimple.soap.cache.lifetime%</argument>
|
||||||
<argument>%besimple.soap.cache.limit%</argument>
|
<argument>%besimple.soap.cache.limit%</argument>
|
||||||
</service>
|
</service>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
</parameters>
|
</parameters>
|
||||||
|
|
||||||
<services>
|
<services>
|
||||||
<service id="besimple.soap.response" class="%besimple.soap.response.class%" />
|
<service id="besimple.soap.response" class="%besimple.soap.response.class%" public="true" />
|
||||||
|
|
||||||
<service id="besimple.soap.response.listener" class="%besimple.soap.response.listener.class%">
|
<service id="besimple.soap.response.listener" class="%besimple.soap.response.listener.class%">
|
||||||
<tag name="kernel.event_listener" event="kernel.view" method="onKernelView" />
|
<tag name="kernel.event_listener" event="kernel.view" method="onKernelView" />
|
||||||
@ -96,6 +96,14 @@
|
|||||||
<argument>dateTime</argument>
|
<argument>dateTime</argument>
|
||||||
<argument>xsd:dateTime</argument>
|
<argument>xsd:dateTime</argument>
|
||||||
</call>
|
</call>
|
||||||
|
<call method="addType">
|
||||||
|
<argument>base64Binary</argument>
|
||||||
|
<argument>xsd:base64Binary</argument>
|
||||||
|
</call>
|
||||||
|
<call method="addType">
|
||||||
|
<argument>hexBinary</argument>
|
||||||
|
<argument>xsd:hexBinary</argument>
|
||||||
|
</call>
|
||||||
</service>
|
</service>
|
||||||
</services>
|
</services>
|
||||||
|
|
||||||
|
@ -33,4 +33,8 @@ SoapServer
|
|||||||
SoapClient
|
SoapClient
|
||||||
----------
|
----------
|
||||||
|
|
||||||
Coming soon.
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
:numbered:
|
||||||
|
|
||||||
|
soapclient/configuration
|
||||||
|
@ -0,0 +1,158 @@
|
|||||||
|
Configuration
|
||||||
|
=============
|
||||||
|
|
||||||
|
Client configuration
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Configure your first client in your config file:
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
# app/config/config.yml
|
||||||
|
be_simple_soap:
|
||||||
|
clients:
|
||||||
|
DemoApi:
|
||||||
|
# required
|
||||||
|
wsdl: http://localhost/app_dev.php/ws/DemoApi?wsdl
|
||||||
|
|
||||||
|
# classmap (optional)
|
||||||
|
classmap:
|
||||||
|
type_name: "Full\Class\Name"
|
||||||
|
|
||||||
|
# proxy (optional)
|
||||||
|
proxy:
|
||||||
|
host: proxy.domain.name # required to enable proxy configuration
|
||||||
|
port: 3128
|
||||||
|
login: ~
|
||||||
|
password: ~
|
||||||
|
auth: ~ # can be 'basic' or 'ntlm'
|
||||||
|
|
||||||
|
Using client
|
||||||
|
------------
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Acme\DemoBundle\Controller;
|
||||||
|
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
|
||||||
|
class DemoController extends Controller
|
||||||
|
{
|
||||||
|
public function helloAction($name)
|
||||||
|
{
|
||||||
|
// The client service name is `besimple.soap.client.demoapi`:
|
||||||
|
// `besimple.soap.client.`: is the base name of your client
|
||||||
|
// `demoapi`: is the name specified in your config file converted to lowercase
|
||||||
|
$client = $this->container->get('besimple.soap.client.demoapi');
|
||||||
|
|
||||||
|
// call `hello` method on WebService with the string parameter `$name`
|
||||||
|
$helloResult = $client->hello($name);
|
||||||
|
|
||||||
|
return $this->render('AcmeDemoBundle:Demo:hello.html.twig', array(
|
||||||
|
'hello' => $helloResult,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Classmap
|
||||||
|
--------
|
||||||
|
|
||||||
|
Configuration
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. code-block:: yaml
|
||||||
|
|
||||||
|
# app/config/config.yml
|
||||||
|
be_simple_soap:
|
||||||
|
clients:
|
||||||
|
DemoApi:
|
||||||
|
# ...
|
||||||
|
classmap:
|
||||||
|
User: Acme\DemoBundle\Api\UserApi
|
||||||
|
# add other type_name: classname
|
||||||
|
|
||||||
|
UserApi class
|
||||||
|
~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Acme\DemoBundle\Api;
|
||||||
|
|
||||||
|
class UserApi
|
||||||
|
{
|
||||||
|
private $username;
|
||||||
|
|
||||||
|
private $firstname;
|
||||||
|
|
||||||
|
private $lastname;
|
||||||
|
|
||||||
|
public function __construct($username)
|
||||||
|
{
|
||||||
|
$this->username = $username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFirstname()
|
||||||
|
{
|
||||||
|
return $this->firstname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLastname()
|
||||||
|
{
|
||||||
|
return $this->lastname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Usage
|
||||||
|
~~~~~
|
||||||
|
|
||||||
|
.. code-block:: php
|
||||||
|
|
||||||
|
namespace Acme\DemoBundle\Controller;
|
||||||
|
|
||||||
|
use Acme\DemoBundle\Api\UserApi;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
|
||||||
|
class DemoController extends Controller
|
||||||
|
{
|
||||||
|
public function userAction($username)
|
||||||
|
{
|
||||||
|
// The client service name is `besimple.soap.client.demoapi`:
|
||||||
|
// `besimple.soap.client.`: is the base name of your client
|
||||||
|
// `demoapi`: is the name specified in your config file converted to lowercase
|
||||||
|
$client = $this->container->get('besimple.soap.client.demoapi');
|
||||||
|
|
||||||
|
// call `getUser` method on WebService with an instance of UserApi
|
||||||
|
// if the `getUserByUsername` method return a `User` type then `$userResult` is an instance of UserApi
|
||||||
|
$userResult = $client->getUserByUsername($username);
|
||||||
|
|
||||||
|
return $this->render('AcmeDemoBundle:Demo:user.html.twig', array(
|
||||||
|
'user' => $userResult,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Without classmap configuration the `$userResult` is an instance of `stdClass`:
|
||||||
|
|
||||||
|
.. code-block:: text
|
||||||
|
|
||||||
|
object(stdClass)#5561 (3) {
|
||||||
|
["username"]=>
|
||||||
|
string(6) "FooBar"
|
||||||
|
["firstname"]=>
|
||||||
|
string(3) "Foo"
|
||||||
|
["lastname"]=>
|
||||||
|
string(3) "Bar"
|
||||||
|
}
|
||||||
|
|
||||||
|
With classmap configuration the `$userResult` is an instance of `Acme\DemoBundle\Api\UserApi`:
|
||||||
|
|
||||||
|
.. code-block:: text
|
||||||
|
|
||||||
|
object(Acme\DemoBundle\Api\UserApi)#208 (3) {
|
||||||
|
["username":"Acme\DemoBundle\Api\UserApi":private]=>
|
||||||
|
string(6) "FooBar"
|
||||||
|
["firstname":"Acme\DemoBundle\Api\UserApi":private]=>
|
||||||
|
string(3) "Foo"
|
||||||
|
["lastname":"Acme\DemoBundle\Api\UserApi":private]=>
|
||||||
|
string(3) "Bar"
|
||||||
|
}
|
@ -47,9 +47,9 @@ Controller
|
|||||||
/**
|
/**
|
||||||
* @Soap\Method("sendAssocArray")
|
* @Soap\Method("sendAssocArray")
|
||||||
* @Soap\Param("assocArray", phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
|
* @Soap\Param("assocArray", phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
|
||||||
* @Soap\Return(phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
|
* @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
|
||||||
*/
|
*/
|
||||||
public function assocArrayOfStringAction(array $assocArray)
|
public function sendAssocArrayOfStringAction(array $assocArray)
|
||||||
{
|
{
|
||||||
// The $assocArray it's a real associative array
|
// The $assocArray it's a real associative array
|
||||||
// var_dump($assocArray);die;
|
// var_dump($assocArray);die;
|
||||||
@ -97,3 +97,4 @@ How to create my Associative Array?
|
|||||||
'user2' => new User('user2', 'user2@user.com'),
|
'user2' => new User('user2', 'user2@user.com'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -86,6 +86,16 @@ You can expose only the properties (public, protected or private) of a complex t
|
|||||||
*/
|
*/
|
||||||
private $newsletter;
|
private $newsletter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Soap\ComplexType("date")
|
||||||
|
*/
|
||||||
|
private $createdAt:
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Soap\ComplexType("datetime")
|
||||||
|
*/
|
||||||
|
private $updatedAt;
|
||||||
|
|
||||||
public function getId()
|
public function getId()
|
||||||
{
|
{
|
||||||
return $this->id;
|
return $this->id;
|
||||||
@ -128,7 +138,27 @@ You can expose only the properties (public, protected or private) of a complex t
|
|||||||
|
|
||||||
public function setNewsletter($newsletter)
|
public function setNewsletter($newsletter)
|
||||||
{
|
{
|
||||||
$this->newletter = (Boolean) $newsletter
|
$this->newletter = (Boolean) $newsletter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getCreatedAt()
|
||||||
|
{
|
||||||
|
return $this->createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setCreatedAt(\DateTime $createdAt)
|
||||||
|
{
|
||||||
|
$this->createdAt = $createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUpdatedAt()
|
||||||
|
{
|
||||||
|
return this->updatedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUpdatedAt(\DateTime $updatedAt)
|
||||||
|
{
|
||||||
|
$this->updatedAt = $updatedAt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
/*
|
||||||
|
* This file is part of the BeSimpleSoapBundle.
|
||||||
|
*
|
||||||
|
* (c) Christian Kerl <christian-kerl@web.de>
|
||||||
|
*
|
||||||
|
* This source file is subject to the MIT license that is bundled
|
||||||
|
* with this source code in the file LICENSE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace BeSimple\SoapBundle\ServiceBinding;
|
||||||
|
|
||||||
|
use BeSimple\SoapBundle\ServiceDefinition\Method;
|
||||||
|
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Francis Besset <francis.besset@gmail.com>
|
||||||
|
*/
|
||||||
|
class DocumentLiteralWrappedRequestHeaderMessageBinder extends DocumentLiteralWrappedRequestMessageBinder
|
||||||
|
{
|
||||||
|
private $header;
|
||||||
|
|
||||||
|
public function setHeader($header)
|
||||||
|
{
|
||||||
|
$this->header = $header;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository)
|
||||||
|
{
|
||||||
|
$headerDefinition = $messageDefinition->getHeaders()->get($this->header);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
@ -11,13 +11,14 @@
|
|||||||
namespace BeSimple\SoapBundle\ServiceBinding;
|
namespace BeSimple\SoapBundle\ServiceBinding;
|
||||||
|
|
||||||
use BeSimple\SoapBundle\ServiceDefinition\Method;
|
use BeSimple\SoapBundle\ServiceDefinition\Method;
|
||||||
|
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christian Kerl <christian-kerl@web.de>
|
* @author Christian Kerl <christian-kerl@web.de>
|
||||||
*/
|
*/
|
||||||
class DocumentLiteralWrappedRequestMessageBinder implements MessageBinderInterface
|
class DocumentLiteralWrappedRequestMessageBinder implements MessageBinderInterface
|
||||||
{
|
{
|
||||||
public function processMessage(Method $messageDefinition, $message)
|
public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository)
|
||||||
{
|
{
|
||||||
if (count($message) > 1) {
|
if (count($message) > 1) {
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
@ -26,8 +27,8 @@ class DocumentLiteralWrappedRequestMessageBinder implements MessageBinderInterfa
|
|||||||
$result = array();
|
$result = array();
|
||||||
$message = $message[0];
|
$message = $message[0];
|
||||||
|
|
||||||
foreach($messageDefinition->getArguments() as $argument) {
|
foreach ($messageDefinition->getInput()->all() as $argument) {
|
||||||
$result[$argument->getName()] = $message->{$argument->getName()};
|
$result[$argument->getName()] = $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
|
@ -11,17 +11,15 @@
|
|||||||
namespace BeSimple\SoapBundle\ServiceBinding;
|
namespace BeSimple\SoapBundle\ServiceBinding;
|
||||||
|
|
||||||
use BeSimple\SoapBundle\ServiceDefinition\Method;
|
use BeSimple\SoapBundle\ServiceDefinition\Method;
|
||||||
|
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christian Kerl <christian-kerl@web.de>
|
* @author Christian Kerl <christian-kerl@web.de>
|
||||||
*/
|
*/
|
||||||
class DocumentLiteralWrappedResponseMessageBinder implements MessageBinderInterface
|
class DocumentLiteralWrappedResponseMessageBinder implements MessageBinderInterface
|
||||||
{
|
{
|
||||||
public function processMessage(Method $messageDefinition, $message)
|
public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository)
|
||||||
{
|
{
|
||||||
$result = new \stdClass();
|
return $message;
|
||||||
$result->{$messageDefinition->getName().'Result'} = $message;
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,5 +24,5 @@ interface MessageBinderInterface
|
|||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository);
|
public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository);
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,10 @@ class RpcLiteralResponseMessageBinder implements MessageBinderInterface
|
|||||||
{
|
{
|
||||||
$this->typeRepository = $typeRepository;
|
$this->typeRepository = $typeRepository;
|
||||||
|
|
||||||
return $this->processType($messageDefinition->getOutput()->get('return')->getType(), $message);
|
$parts = $messageDefinition->getOutput()->all();
|
||||||
|
$part = array_shift($parts);
|
||||||
|
|
||||||
|
return $this->processType($part->getType(), $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function processType($phpType, $message)
|
private function processType($phpType, $message)
|
||||||
|
@ -44,7 +44,8 @@ class ServiceBinder
|
|||||||
* @param MessageBinderInterface $requestMessageBinder
|
* @param MessageBinderInterface $requestMessageBinder
|
||||||
* @param MessageBinderInterface $responseMessageBinder
|
* @param MessageBinderInterface $responseMessageBinder
|
||||||
*/
|
*/
|
||||||
public function __construct(Definition $definition, MessageBinderInterface $requestHeaderMessageBinder, MessageBinderInterface $requestMessageBinder, MessageBinderInterface $responseMessageBinder) {
|
public function __construct(Definition $definition, MessageBinderInterface $requestHeaderMessageBinder, MessageBinderInterface $requestMessageBinder, MessageBinderInterface $responseMessageBinder)
|
||||||
|
{
|
||||||
$this->definition = $definition;
|
$this->definition = $definition;
|
||||||
|
|
||||||
$this->requestHeaderMessageBinder = $requestHeaderMessageBinder;
|
$this->requestHeaderMessageBinder = $requestHeaderMessageBinder;
|
||||||
|
@ -18,6 +18,7 @@ class ComplexType extends Configuration
|
|||||||
private $name;
|
private $name;
|
||||||
private $value;
|
private $value;
|
||||||
private $isNillable = false;
|
private $isNillable = false;
|
||||||
|
private $minOccurs = 1;
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
@ -34,6 +35,11 @@ class ComplexType extends Configuration
|
|||||||
return $this->isNillable;
|
return $this->isNillable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getIsNillable()
|
||||||
|
{
|
||||||
|
return $this->isNillable;
|
||||||
|
}
|
||||||
|
|
||||||
public function setName($name)
|
public function setName($name)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
@ -49,6 +55,21 @@ class ComplexType extends Configuration
|
|||||||
$this->isNillable = (bool) $isNillable;
|
$this->isNillable = (bool) $isNillable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setIsNillable($isNillable)
|
||||||
|
{
|
||||||
|
$this->isNillable = (bool) $isNillable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMinOccurs($minOccurs)
|
||||||
|
{
|
||||||
|
$this->minOccurs = $minOccurs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMinOccurs()
|
||||||
|
{
|
||||||
|
return $this->minOccurs;
|
||||||
|
}
|
||||||
|
|
||||||
public function getAliasName()
|
public function getAliasName()
|
||||||
{
|
{
|
||||||
return 'complextype';
|
return 'complextype';
|
||||||
|
@ -22,5 +22,5 @@ interface ConfigurationInterface
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getAliasName();
|
public function getAliasName();
|
||||||
}
|
}
|
@ -12,8 +12,8 @@ namespace BeSimple\SoapBundle\ServiceDefinition\Annotation;
|
|||||||
|
|
||||||
interface TypedElementInterface
|
interface TypedElementInterface
|
||||||
{
|
{
|
||||||
function getPhpType();
|
public function getPhpType();
|
||||||
function getXmlType();
|
public function getXmlType();
|
||||||
function setPhpType($phpType);
|
public function setPhpType($phpType);
|
||||||
function setXmlType($xmlType);
|
public function setXmlType($xmlType);
|
||||||
}
|
}
|
@ -20,6 +20,7 @@ class ComplexType
|
|||||||
private $name;
|
private $name;
|
||||||
private $value;
|
private $value;
|
||||||
private $isNillable = false;
|
private $isNillable = false;
|
||||||
|
private $minOccurs = 1;
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
{
|
{
|
||||||
@ -50,4 +51,14 @@ class ComplexType
|
|||||||
{
|
{
|
||||||
$this->isNillable = (bool) $isNillable;
|
$this->isNillable = (bool) $isNillable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setMinOccurs($minOccurs)
|
||||||
|
{
|
||||||
|
$this->minOccurs = $minOccurs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMinOccurs()
|
||||||
|
{
|
||||||
|
return $this->minOccurs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,6 +96,7 @@ class AnnotationClassLoader extends Loader
|
|||||||
}
|
}
|
||||||
|
|
||||||
$serviceReturn = $annotation->getPhpType();
|
$serviceReturn = $annotation->getPhpType();
|
||||||
|
$serviceXmlReturn = $annotation->getXmlType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +117,11 @@ class AnnotationClassLoader extends Loader
|
|||||||
throw new \LogicException(sprintf('@Soap\Result non-existent for "%s".', $method->getName()));
|
throw new \LogicException(sprintf('@Soap\Result non-existent for "%s".', $method->getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$serviceMethod->setOutput($this->loadType($serviceReturn));
|
if (!isset($serviceXmlReturn) || !$serviceXmlReturn) {
|
||||||
|
$serviceXmlReturn = 'return';
|
||||||
|
}
|
||||||
|
|
||||||
|
$serviceMethod->setOutput($this->loadType($serviceReturn), $serviceXmlReturn);
|
||||||
|
|
||||||
$definition->addMethod($serviceMethod);
|
$definition->addMethod($serviceMethod);
|
||||||
}
|
}
|
||||||
@ -155,7 +160,7 @@ class AnnotationClassLoader extends Loader
|
|||||||
$loaded = $complexTypeResolver->load($phpType);
|
$loaded = $complexTypeResolver->load($phpType);
|
||||||
$complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType);
|
$complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType);
|
||||||
foreach ($loaded['properties'] as $name => $property) {
|
foreach ($loaded['properties'] as $name => $property) {
|
||||||
$complexType->add($name, $this->loadType($property->getValue()), $property->isNillable());
|
$complexType->add($name, $this->loadType($property->getValue()), $property->isNillable(), $property->getMinOccurs());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->typeRepository->addComplexType($complexType);
|
$this->typeRepository->addComplexType($complexType);
|
||||||
|
@ -43,7 +43,7 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
|
|||||||
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
|
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
|
||||||
}
|
}
|
||||||
|
|
||||||
$annotations = array();
|
$annotations = [];
|
||||||
|
|
||||||
$class = new \ReflectionClass($class);
|
$class = new \ReflectionClass($class);
|
||||||
if ($alias = $this->reader->getClassAnnotation($class, $this->aliasClass)) {
|
if ($alias = $this->reader->getClassAnnotation($class, $this->aliasClass)) {
|
||||||
@ -59,6 +59,7 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
|
|||||||
$propertyComplexType->setValue($complexType->getValue());
|
$propertyComplexType->setValue($complexType->getValue());
|
||||||
$propertyComplexType->setNillable($complexType->isNillable());
|
$propertyComplexType->setNillable($complexType->isNillable());
|
||||||
$propertyComplexType->setName($property->getName());
|
$propertyComplexType->setName($property->getName());
|
||||||
|
$propertyComplexType->setMinOccurs($complexType->getMinOccurs());
|
||||||
$annotations['properties']->add($propertyComplexType);
|
$annotations['properties']->add($propertyComplexType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,7 +73,7 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
|
|||||||
* @param mixed $resource A resource
|
* @param mixed $resource A resource
|
||||||
* @param string $type The resource type
|
* @param string $type The resource type
|
||||||
*
|
*
|
||||||
* @return Boolean True if this class supports the given resource, false otherwise
|
* @return bool True if this class supports the given resource, false otherwise
|
||||||
*/
|
*/
|
||||||
public function supports($resource, $type = null)
|
public function supports($resource, $type = null)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ namespace BeSimple\SoapBundle\Soap;
|
|||||||
|
|
||||||
use BeSimple\SoapBundle\Util\Collection;
|
use BeSimple\SoapBundle\Util\Collection;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Zend\Mime\Message;
|
use Laminas\Mime\Message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SoapRequest.
|
* SoapRequest.
|
||||||
|
@ -16,66 +16,70 @@ use BeSimple\SoapBundle\ServiceBinding\RpcLiteralRequestMessageBinder;
|
|||||||
use BeSimple\SoapBundle\ServiceDefinition as Definition;
|
use BeSimple\SoapBundle\ServiceDefinition as Definition;
|
||||||
use BeSimple\SoapBundle\Tests\fixtures\ServiceBinding as Fixtures;
|
use BeSimple\SoapBundle\Tests\fixtures\ServiceBinding as Fixtures;
|
||||||
use BeSimple\SoapBundle\Util\Collection;
|
use BeSimple\SoapBundle\Util\Collection;
|
||||||
|
use BeSimple\SoapCommon\Definition\Type\ComplexType;
|
||||||
|
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
|
||||||
|
|
||||||
class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @dataProvider messageProvider
|
* @dataProvider messageProvider
|
||||||
*/
|
*/
|
||||||
public function testProcessMessage(Definition\Method $method, $message, $assert)
|
public function testProcessMessage(Definition\Method $method, array $message, array $assert)
|
||||||
{
|
{
|
||||||
$messageBinder = new RpcLiteralRequestMessageBinder();
|
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||||
$result = $messageBinder->processMessage($method, $message);
|
$result = $messageBinder->processMessage($method, $message, $this->getTypeRepository());
|
||||||
|
|
||||||
$this->assertSame($assert, $result);
|
$this->assertSame($assert, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testProcessMessageWithComplexType()
|
public function testProcessMessageWithComplexType()
|
||||||
{
|
{
|
||||||
|
$typeRepository = $this->addComplexTypes($this->getTypeRepository());
|
||||||
$messageBinder = new RpcLiteralRequestMessageBinder();
|
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||||
|
|
||||||
|
$method = new Definition\Method('complextype_argument', null);
|
||||||
|
$method->addInput('foo', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo');
|
||||||
|
|
||||||
$foo = new Fixtures\Foo('foobar', 19395);
|
$foo = new Fixtures\Foo('foobar', 19395);
|
||||||
$result = $messageBinder->processMessage(
|
$result = $messageBinder->processMessage(
|
||||||
new Definition\Method('complextype_argument', null, array(), array(
|
$method,
|
||||||
new Definition\Argument('foo', new Definition\Type('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo')),
|
|
||||||
)),
|
|
||||||
array($foo),
|
array($foo),
|
||||||
$this->getDefinitionComplexTypes()
|
$typeRepository
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(array('foo' => $foo), $result);
|
$this->assertEquals(array('foo' => $foo), $result);
|
||||||
|
|
||||||
|
|
||||||
$foo1 = new Fixtures\Foo('foobar', 29291);
|
$foo1 = new Fixtures\Foo('foobar', 29291);
|
||||||
$foo2 = new Fixtures\Foo('barfoo', 39392);
|
$foo2 = new Fixtures\Foo('barfoo', 39392);
|
||||||
$foos = new \stdClass();
|
$foos = new \stdClass();
|
||||||
$foos->item = array($foo1, $foo2);
|
$foos->item = array($foo1, $foo2);
|
||||||
|
|
||||||
|
$method = new Definition\Method('complextype_argument', null);
|
||||||
|
$method->addInput('foos', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo[]');
|
||||||
|
|
||||||
$result = $messageBinder->processMessage(
|
$result = $messageBinder->processMessage(
|
||||||
new Definition\Method('complextype_argument', null, array(), array(
|
$method,
|
||||||
new Definition\Argument('foos', new Definition\Type('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo[]')),
|
|
||||||
)),
|
|
||||||
array($foos),
|
array($foos),
|
||||||
$this->getDefinitionComplexTypes()
|
$typeRepository
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(array('foos' => array($foo1, $foo2)), $result);
|
$this->assertEquals(array('foos' => array($foo1, $foo2)), $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException SoapFault
|
|
||||||
*/
|
|
||||||
public function testProcessMessageSoapFault()
|
public function testProcessMessageSoapFault()
|
||||||
{
|
{
|
||||||
$messageBinder = new RpcLiteralRequestMessageBinder();
|
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||||
|
|
||||||
|
$method = new Definition\Method('complextype_argument', null);
|
||||||
|
$method->addInput('foo', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo');
|
||||||
|
|
||||||
$foo = new Fixtures\Foo('foo', null);
|
$foo = new Fixtures\Foo('foo', null);
|
||||||
$result = $messageBinder->processMessage(
|
|
||||||
new Definition\Method('complextype_argument', null, array(), array(
|
$this->setExpectedException('SoapFault');
|
||||||
new Definition\Argument('foo', new Definition\Type('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo')),
|
$messageBinder->processMessage(
|
||||||
)),
|
$method,
|
||||||
array($foo),
|
array($foo),
|
||||||
$this->getDefinitionComplexTypes()
|
$this->addComplexTypes($this->getTypeRepository())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,16 +87,17 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$messageBinder = new RpcLiteralRequestMessageBinder();
|
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||||
|
|
||||||
|
$method = new Definition\Method('complextype_argument', null);
|
||||||
|
$method->addInput('foos', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo[]');
|
||||||
|
|
||||||
$foo = new Fixtures\Foo('foo', 2499104);
|
$foo = new Fixtures\Foo('foo', 2499104);
|
||||||
$foos = new \stdClass();
|
$foos = new \stdClass();
|
||||||
$foos->item = array($foo, $foo);
|
$foos->item = array($foo, $foo);
|
||||||
|
|
||||||
$result = $messageBinder->processMessage(
|
$result = $messageBinder->processMessage(
|
||||||
new Definition\Method('complextype_argument', null, array(), array(
|
$method,
|
||||||
new Definition\Argument('foos', new Definition\Type('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo[]')),
|
|
||||||
)),
|
|
||||||
array($foos),
|
array($foos),
|
||||||
$this->getDefinitionComplexTypes()
|
$this->addComplexTypes($this->getTypeRepository())
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(array('foos' => array($foo, $foo)), $result);
|
$this->assertEquals(array('foos' => array($foo, $foo)), $result);
|
||||||
@ -102,16 +107,17 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$messageBinder = new RpcLiteralRequestMessageBinder();
|
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||||
|
|
||||||
|
$method = new Definition\Method('complextype_argument', null);
|
||||||
|
$method->addInput('fooBar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooBar');
|
||||||
|
|
||||||
$foo = new Fixtures\Foo('foo', 38845);
|
$foo = new Fixtures\Foo('foo', 38845);
|
||||||
$bar = new Fixtures\Bar('bar', null);
|
$bar = new Fixtures\Bar('bar', null);
|
||||||
$fooBar = new Fixtures\FooBar($foo, $bar);
|
$fooBar = new Fixtures\FooBar($foo, $bar);
|
||||||
|
|
||||||
$result = $messageBinder->processMessage(
|
$result = $messageBinder->processMessage(
|
||||||
new Definition\Method('complextype_argument', null, array(), array(
|
$method,
|
||||||
new Definition\Argument('fooBar', new Definition\Type('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooBar')),
|
|
||||||
)),
|
|
||||||
array($fooBar),
|
array($fooBar),
|
||||||
$this->getDefinitionComplexTypes()
|
$this->addComplexTypes($this->getTypeRepository())
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(array('fooBar' => $fooBar), $result);
|
$this->assertEquals(array('fooBar' => $fooBar), $result);
|
||||||
@ -121,17 +127,18 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$messageBinder = new RpcLiteralRequestMessageBinder();
|
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||||
|
|
||||||
|
$method = new Definition\Method('complextype_with_array', null);
|
||||||
|
$method->addInput('simple_arrays', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\SimpleArrays');
|
||||||
|
|
||||||
$array = array(1, 2, 3, 4);
|
$array = array(1, 2, 3, 4);
|
||||||
$stdClass = new \stdClass();
|
$stdClass = new \stdClass();
|
||||||
$stdClass->item = $array;
|
$stdClass->item = $array;
|
||||||
$simpleArrays = new Fixtures\SimpleArrays(null, new \stdClass(), $stdClass);
|
$simpleArrays = new Fixtures\SimpleArrays(null, new \stdClass(), $stdClass);
|
||||||
|
|
||||||
$result = $messageBinder->processMessage(
|
$result = $messageBinder->processMessage(
|
||||||
new Definition\Method('complextype_with_array', null, array(), array(
|
$method,
|
||||||
new Definition\Argument('simple_arrays', new Definition\Type('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\SimpleArrays')),
|
|
||||||
)),
|
|
||||||
array($simpleArrays),
|
array($simpleArrays),
|
||||||
$this->getDefinitionComplexTypes()
|
$this->addComplexTypes($this->getTypeRepository())
|
||||||
);
|
);
|
||||||
|
|
||||||
$result = $result['simple_arrays'];
|
$result = $result['simple_arrays'];
|
||||||
@ -144,12 +151,13 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$messageBinder = new RpcLiteralRequestMessageBinder();
|
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||||
|
|
||||||
|
$method = new Definition\Method('empty_array_complex_type', null);
|
||||||
|
$method->addInput('foo', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo[]');
|
||||||
|
|
||||||
$result = $messageBinder->processMessage(
|
$result = $messageBinder->processMessage(
|
||||||
new Definition\Method('empty_array_complex_type', null, array(), array(
|
$method,
|
||||||
new Definition\Argument('foo', new Definition\Type('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo[]')),
|
|
||||||
)),
|
|
||||||
array(new \stdClass()),
|
array(new \stdClass()),
|
||||||
$this->getDefinitionComplexTypes()
|
$this->addComplexTypes($this->getTypeRepository())
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(array('foo' => array()), $result);
|
$this->assertEquals(array('foo' => array()), $result);
|
||||||
@ -159,16 +167,17 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
$messageBinder = new RpcLiteralRequestMessageBinder();
|
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||||
|
|
||||||
|
$method = new Definition\Method('prevent_infinite_recursion', null);
|
||||||
|
$method->addInput('foo_recursive', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive');
|
||||||
|
|
||||||
$foo = new Fixtures\FooRecursive('foo', '');
|
$foo = new Fixtures\FooRecursive('foo', '');
|
||||||
$bar = new Fixtures\BarRecursive($foo, 10394);
|
$bar = new Fixtures\BarRecursive($foo, 10394);
|
||||||
$foo->bar = $bar;
|
$foo->bar = $bar;
|
||||||
|
|
||||||
$result = $messageBinder->processMessage(
|
$result = $messageBinder->processMessage(
|
||||||
new Definition\Method('prevent_infinite_recursion', null, array(), array(
|
$method,
|
||||||
new Definition\Argument('foo_recursive', new Definition\Type('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive')),
|
|
||||||
)),
|
|
||||||
array($foo),
|
array($foo),
|
||||||
$this->getDefinitionComplexTypes()
|
$this->addComplexTypes($this->getTypeRepository())
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(array('foo_recursive' => $foo), $result);
|
$this->assertEquals(array('foo_recursive' => $foo), $result);
|
||||||
@ -179,43 +188,43 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
|||||||
$messages = array();
|
$messages = array();
|
||||||
|
|
||||||
$messages[] = array(
|
$messages[] = array(
|
||||||
new Definition\Method('no_argument'),
|
new Definition\Method('no_argument', null),
|
||||||
array(),
|
array(),
|
||||||
array(),
|
array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$method = new Definition\Method('string_argument', null);
|
||||||
|
$method->addInput('foo', 'string');
|
||||||
$messages[] = array(
|
$messages[] = array(
|
||||||
new Definition\Method('string_argument', null, array(), array(
|
$method,
|
||||||
new Definition\Argument('foo', new Definition\Type('string')),
|
|
||||||
)),
|
|
||||||
array('bar'),
|
array('bar'),
|
||||||
array('foo' => 'bar'),
|
array('foo' => 'bar'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$method = new Definition\Method('string_int_arguments', null);
|
||||||
|
$method->addInput('foo', 'string');
|
||||||
|
$method->addInput('bar', 'int');
|
||||||
$messages[] = array(
|
$messages[] = array(
|
||||||
new Definition\Method('string_int_arguments', null, array(), array(
|
$method,
|
||||||
new Definition\Argument('foo', new Definition\Type('string')),
|
|
||||||
new Definition\Argument('bar', new Definition\Type('int')),
|
|
||||||
)),
|
|
||||||
array('test', 20),
|
array('test', 20),
|
||||||
array('foo' => 'test', 'bar' => 20),
|
array('foo' => 'test', 'bar' => 20),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$method = new Definition\Method('array_string_arguments', null);
|
||||||
|
$method->addInput('foo', 'string[]');
|
||||||
|
$method->addInput('bar', 'int');
|
||||||
$strings = new \stdClass();
|
$strings = new \stdClass();
|
||||||
$strings->item = array('foo', 'bar', 'barfoo');
|
$strings->item = array('foo', 'bar', 'barfoo');
|
||||||
$messages[] = array(
|
$messages[] = array(
|
||||||
new Definition\Method('array_string_arguments', null, array(), array(
|
$method,
|
||||||
new Definition\Argument('foo', new Definition\Type('string[]')),
|
|
||||||
new Definition\Argument('bar', new Definition\Type('int')),
|
|
||||||
)),
|
|
||||||
array($strings, 4),
|
array($strings, 4),
|
||||||
array('foo' => array('foo', 'bar', 'barfoo'), 'bar' => 4),
|
array('foo' => array('foo', 'bar', 'barfoo'), 'bar' => 4),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$method = new Definition\Method('empty_array', null);
|
||||||
|
$method->addInput('foo', 'string[]');
|
||||||
$messages[] = array(
|
$messages[] = array(
|
||||||
new Definition\Method('empty_array', null, array(), array(
|
$method,
|
||||||
new Definition\Argument('foo', new Definition\Type('string[]')),
|
|
||||||
)),
|
|
||||||
array(new \stdClass()),
|
array(new \stdClass()),
|
||||||
array('foo' => array()),
|
array('foo' => array()),
|
||||||
);
|
);
|
||||||
@ -223,40 +232,38 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
|||||||
return $messages;
|
return $messages;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDefinitionComplexTypes()
|
private function addComplexTypes(TypeRepository $typeRepository)
|
||||||
{
|
{
|
||||||
$definitionComplexTypes = array();
|
$foo = new ComplexType('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo', 'Foo');
|
||||||
|
$foo->add('foo', 'string');
|
||||||
|
$foo->add('bar', 'int');
|
||||||
|
$typeRepository->addComplexType($foo);
|
||||||
|
|
||||||
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo'] = $this->createComplexTypeCollection(array(
|
$bar = new ComplexType('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Bar', 'Bar');
|
||||||
array('foo', 'string'),
|
$bar->add('foo', 'string');
|
||||||
array('bar', 'int'),
|
$bar->add('bar', 'int', true);
|
||||||
));
|
$typeRepository->addComplexType($bar);
|
||||||
|
|
||||||
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Bar'] = $this->createComplexTypeCollection(array(
|
$fooBar = new ComplexType('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooBar', 'FooBar');
|
||||||
array('foo', 'string'),
|
$fooBar->add('foo', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo');
|
||||||
array('bar', 'int', true),
|
$fooBar->add('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Bar');
|
||||||
));
|
$typeRepository->addComplexType($fooBar);
|
||||||
|
|
||||||
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooBar'] = $this->createComplexTypeCollection(array(
|
$simpleArrays = new ComplexType('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\SimpleArrays', 'SimpleArrays');
|
||||||
array('foo', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Foo'),
|
$simpleArrays->add('array1', 'string[]', true);
|
||||||
array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Bar'),
|
$simpleArrays->add('array2', 'string[]');
|
||||||
));
|
$simpleArrays->add('array3', 'string[]');
|
||||||
|
$typeRepository->addComplexType($simpleArrays);
|
||||||
|
|
||||||
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\SimpleArrays'] = $this->createComplexTypeCollection(array(
|
$fooRecursive = new ComplexType('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive', 'FooRecursive');
|
||||||
array('array1', 'string[]', true),
|
$fooRecursive->add('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\BarRecursive');
|
||||||
array('array2', 'string[]'),
|
$typeRepository->addComplexType($fooRecursive);
|
||||||
array('array3', 'string[]'),
|
|
||||||
));
|
|
||||||
|
|
||||||
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive'] = $this->createComplexTypeCollection(array(
|
$barRecursive = new ComplexType('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\BarRecursive', 'BarRecursive');
|
||||||
array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\BarRecursive'),
|
$barRecursive->add('foo', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive');
|
||||||
));
|
$typeRepository->addComplexType($barRecursive);
|
||||||
|
|
||||||
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\BarRecursive'] = $this->createComplexTypeCollection(array(
|
return $typeRepository;
|
||||||
array('foo', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive'),
|
|
||||||
));
|
|
||||||
|
|
||||||
return $definitionComplexTypes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createComplexTypeCollection(array $properties)
|
private function createComplexTypeCollection(array $properties)
|
||||||
@ -277,4 +284,18 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
return array('properties' => $collection);
|
return array('properties' => $collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getTypeRepository()
|
||||||
|
{
|
||||||
|
$typeRepository = new TypeRepository();
|
||||||
|
$typeRepository->addXmlNamespace('xsd', 'http://www.w3.org/2001/XMLSchema');
|
||||||
|
$typeRepository->addType('string', 'xsd:string');
|
||||||
|
$typeRepository->addType('boolean', 'xsd:boolean');
|
||||||
|
$typeRepository->addType('int', 'xsd:int');
|
||||||
|
$typeRepository->addType('float', 'xsd:float');
|
||||||
|
$typeRepository->addType('date', 'xsd:date');
|
||||||
|
$typeRepository->addType('dateTime', 'xsd:dateTime');
|
||||||
|
|
||||||
|
return $typeRepository;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,8 @@ class SoapRequestTest extends \PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
public function testMtomMessage()
|
public function testMtomMessage()
|
||||||
{
|
{
|
||||||
|
$this->markTestSkipped('Skip because I\'m not sure that SoapRequest is used in a HTTP Request process.');
|
||||||
|
|
||||||
$content = $this->loadRequestContentFixture('mtom/simple.txt');
|
$content = $this->loadRequestContentFixture('mtom/simple.txt');
|
||||||
|
|
||||||
$request = new SoapRequest(array(), array(), array(), array(), array(), array(), $content);
|
$request = new SoapRequest(array(), array(), array(), array(), array(), array(), $content);
|
||||||
|
@ -15,7 +15,7 @@ namespace BeSimple\SoapBundle\Util;
|
|||||||
*
|
*
|
||||||
* @author Christian Kerl <christian-kerl@web.de>
|
* @author Christian Kerl <christian-kerl@web.de>
|
||||||
*/
|
*/
|
||||||
class String
|
class BsString
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Checks if a string starts with a given string.
|
* Checks if a string starts with a given string.
|
@ -44,7 +44,7 @@ class WebServiceContext
|
|||||||
if (null === $this->serviceDefinition) {
|
if (null === $this->serviceDefinition) {
|
||||||
$cache = new ConfigCache(sprintf('%s/%s.definition.php', $this->options['cache_dir'], $this->options['name']), $this->options['debug']);
|
$cache = new ConfigCache(sprintf('%s/%s.definition.php', $this->options['cache_dir'], $this->options['name']), $this->options['debug']);
|
||||||
if ($cache->isFresh()) {
|
if ($cache->isFresh()) {
|
||||||
$this->serviceDefinition = include (string) $cache;
|
$this->serviceDefinition = include $cache->getPath();
|
||||||
} else {
|
} else {
|
||||||
if (!$this->loader->supports($this->options['resource'], $this->options['resource_type'])) {
|
if (!$this->loader->supports($this->options['resource'], $this->options['resource_type'])) {
|
||||||
throw new \LogicException(sprintf('Cannot load "%s" (%s)', $this->options['resource'], $this->options['resource_type']));
|
throw new \LogicException(sprintf('Cannot load "%s" (%s)', $this->options['resource'], $this->options['resource_type']));
|
||||||
@ -82,7 +82,7 @@ class WebServiceContext
|
|||||||
$cache->write($dumper->dump());
|
$cache->write($dumper->dump());
|
||||||
}
|
}
|
||||||
|
|
||||||
return (string) $cache;
|
return $cache->getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getServiceBinder()
|
public function getServiceBinder()
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
"besimple/soap-common": "0.2.*",
|
"besimple/soap-common": "0.2.*",
|
||||||
"besimple/soap-wsdl": "0.2.*",
|
"besimple/soap-wsdl": "0.2.*",
|
||||||
"ass/xmlsecurity": "~1.0",
|
"ass/xmlsecurity": "~1.0",
|
||||||
"symfony/framework-bundle": "~2.0",
|
"symfony/framework-bundle": "~2.0|~3.0",
|
||||||
"symfony/twig-bundle": "~2.0",
|
"symfony/twig-bundle": "~2.0|~3.0",
|
||||||
"zendframework/zend-mime": "2.1.*"
|
"zendframework/zend-mime": "2.1.*"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
@ -37,7 +37,6 @@
|
|||||||
"psr-0": { "BeSimple\\SoapBundle": "" }
|
"psr-0": { "BeSimple\\SoapBundle": "" }
|
||||||
},
|
},
|
||||||
"target-dir": "BeSimple/SoapBundle",
|
"target-dir": "BeSimple/SoapBundle",
|
||||||
"minimum-stability": "dev",
|
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "0.2-dev"
|
"dev-master": "0.2-dev"
|
||||||
|
@ -77,16 +77,27 @@ class Curl
|
|||||||
if (isset($options['compression']) && !($options['compression'] & SOAP_COMPRESSION_ACCEPT)) {
|
if (isset($options['compression']) && !($options['compression'] & SOAP_COMPRESSION_ACCEPT)) {
|
||||||
curl_setopt($this->ch, CURLOPT_ENCODING, 'identity');
|
curl_setopt($this->ch, CURLOPT_ENCODING, 'identity');
|
||||||
}
|
}
|
||||||
if (isset($options['connection_timeout'])) {
|
|
||||||
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, $options['connection_timeout']);
|
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 10);
|
||||||
}
|
|
||||||
if (isset($options['proxy_host'])) {
|
if (isset($options['proxy_host'])) {
|
||||||
$port = isset($options['proxy_port']) ? $options['proxy_port'] : 8080;
|
if (false !== $options['proxy_host']) {
|
||||||
curl_setopt($this->ch, CURLOPT_PROXY, $options['proxy_host'] . ':' . $port);
|
$proxyHost = $options['proxy_host'].(isset($options['proxy_port']) ? $options['proxy_port'] : 8080);
|
||||||
|
} else {
|
||||||
|
$proxyHost = false;
|
||||||
}
|
}
|
||||||
if (isset($options['proxy_user'])) {
|
|
||||||
curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_user'] . ':' . $options['proxy_password']);
|
curl_setopt($this->ch, CURLOPT_PROXY, $proxyHost);
|
||||||
|
|
||||||
|
if (false !== $proxyHost && isset($options['proxy_login'])) {
|
||||||
|
curl_setopt($this->ch, CURLOPT_PROXYUSERPWD, $options['proxy_login'].':'.$options['proxy_password']);
|
||||||
|
|
||||||
|
if (isset($options['proxy_auth'])) {
|
||||||
|
curl_setopt($this->ch, CURLOPT_PROXYAUTH, $options['proxy_auth']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($options['login'])) {
|
if (isset($options['login'])) {
|
||||||
curl_setopt($this->ch, CURLOPT_HTTPAUTH, isset($options['extra_options']['http_auth']) ? $options['extra_options']['http_auth'] : CURLAUTH_ANY);
|
curl_setopt($this->ch, CURLOPT_HTTPAUTH, isset($options['extra_options']['http_auth']) ? $options['extra_options']['http_auth'] : CURLAUTH_ANY);
|
||||||
curl_setopt($this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password']);
|
curl_setopt($this->ch, CURLOPT_USERPWD, $options['login'].':'.$options['password']);
|
||||||
@ -118,10 +129,11 @@ class Curl
|
|||||||
* @param string $location HTTP location
|
* @param string $location HTTP location
|
||||||
* @param string $request Request body
|
* @param string $request Request body
|
||||||
* @param array $requestHeaders Request header strings
|
* @param array $requestHeaders Request header strings
|
||||||
|
* @param array $requestOptions An array of request options
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function exec($location, $request = null, $requestHeaders = array())
|
public function exec($location, $request = null, $requestHeaders = array(), $requestOptions = array())
|
||||||
{
|
{
|
||||||
curl_setopt($this->ch, CURLOPT_URL, $location);
|
curl_setopt($this->ch, CURLOPT_URL, $location);
|
||||||
|
|
||||||
@ -134,6 +146,10 @@ class Curl
|
|||||||
curl_setopt($this->ch, CURLOPT_HTTPHEADER, $requestHeaders);
|
curl_setopt($this->ch, CURLOPT_HTTPHEADER, $requestHeaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (count($requestOptions) > 0) {
|
||||||
|
curl_setopt_array($this->ch, $requestOptions);
|
||||||
|
}
|
||||||
|
|
||||||
$this->response = $this->execManualRedirect();
|
$this->response = $this->execManualRedirect();
|
||||||
|
|
||||||
return ($this->response === false) ? false : true;
|
return ($this->response === false) ? false : true;
|
||||||
@ -150,7 +166,6 @@ class Curl
|
|||||||
private function execManualRedirect($redirects = 0)
|
private function execManualRedirect($redirects = 0)
|
||||||
{
|
{
|
||||||
if ($redirects > $this->followLocationMaxRedirects) {
|
if ($redirects > $this->followLocationMaxRedirects) {
|
||||||
|
|
||||||
// TODO Redirection limit reached, aborting
|
// TODO Redirection limit reached, aborting
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -188,7 +203,7 @@ class Curl
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Error code mapping from cURL error codes to PHP ext/soap error messages
|
* Error code mapping from cURL error codes to PHP ext/soap error messages
|
||||||
* (where applicable)
|
* (where applicable).
|
||||||
*
|
*
|
||||||
* http://curl.haxx.se/libcurl/c/libcurl-errors.html
|
* http://curl.haxx.se/libcurl/c/libcurl-errors.html
|
||||||
*
|
*
|
||||||
@ -234,7 +249,6 @@ class Curl
|
|||||||
$errorCodeMapping = $this->getErrorCodeMapping();
|
$errorCodeMapping = $this->getErrorCodeMapping();
|
||||||
$errorNumber = curl_errno($this->ch);
|
$errorNumber = curl_errno($this->ch);
|
||||||
if (isset($errorCodeMapping[$errorNumber])) {
|
if (isset($errorCodeMapping[$errorNumber])) {
|
||||||
|
|
||||||
return $errorCodeMapping[$errorNumber];
|
return $errorCodeMapping[$errorNumber];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,15 +41,6 @@ class SoapClient extends \SoapClient
|
|||||||
*/
|
*/
|
||||||
protected $tracingEnabled = false;
|
protected $tracingEnabled = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Work around missing header/php://input access in PHP cli webserver by
|
|
||||||
* setting headers additionally as GET parameters and SOAP request body
|
|
||||||
* explicitly as POST variable.
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
private $cliWebserverWorkaround = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* cURL instance.
|
* cURL instance.
|
||||||
*
|
*
|
||||||
@ -108,10 +99,7 @@ class SoapClient extends \SoapClient
|
|||||||
if (isset($options['soap_version'])) {
|
if (isset($options['soap_version'])) {
|
||||||
$this->soapVersion = $options['soap_version'];
|
$this->soapVersion = $options['soap_version'];
|
||||||
}
|
}
|
||||||
// activate cli webserver workaround
|
|
||||||
if (isset($options['cli_webserver_workaround'])) {
|
|
||||||
$this->cliWebserverWorkaround = $options['cli_webserver_workaround'];
|
|
||||||
}
|
|
||||||
$this->curl = new Curl($options);
|
$this->curl = new Curl($options);
|
||||||
|
|
||||||
if (isset($options['extra_options'])) {
|
if (isset($options['extra_options'])) {
|
||||||
@ -158,34 +146,19 @@ class SoapClient extends \SoapClient
|
|||||||
|
|
||||||
$location = $soapRequest->getLocation();
|
$location = $soapRequest->getLocation();
|
||||||
$content = $soapRequest->getContent();
|
$content = $soapRequest->getContent();
|
||||||
/*
|
|
||||||
* Work around missing header/php://input access in PHP cli webserver by
|
|
||||||
* setting headers additionally as GET parameters and SOAP request body
|
|
||||||
* explicitly as POST variable
|
|
||||||
*/
|
|
||||||
if ($this->cliWebserverWorkaround === true) {
|
|
||||||
if (strpos($location, '?') === false) {
|
|
||||||
$location .= '?';
|
|
||||||
} else {
|
|
||||||
$location .= '&';
|
|
||||||
}
|
|
||||||
$location .= SoapMessage::CONTENT_TYPE_HEADER.'='.urlencode($soapRequest->getContentType());
|
|
||||||
$location .= '&';
|
|
||||||
$location .= SoapMessage::SOAP_ACTION_HEADER.'='.urlencode($soapRequest->getAction());
|
|
||||||
|
|
||||||
$content = http_build_query(array('request' => $content));
|
|
||||||
|
|
||||||
$headers = array();
|
|
||||||
}
|
|
||||||
|
|
||||||
$headers = $this->filterRequestHeaders($soapRequest, $headers);
|
$headers = $this->filterRequestHeaders($soapRequest, $headers);
|
||||||
|
|
||||||
|
$options = $this->filterRequestOptions($soapRequest);
|
||||||
|
|
||||||
// execute HTTP request with cURL
|
// execute HTTP request with cURL
|
||||||
$responseSuccessfull = $this->curl->exec(
|
$responseSuccessfull = $this->curl->exec(
|
||||||
$location,
|
$location,
|
||||||
$content,
|
$content,
|
||||||
$headers
|
$headers,
|
||||||
|
$options
|
||||||
);
|
);
|
||||||
|
|
||||||
// tracing enabled: store last request header and body
|
// tracing enabled: store last request header and body
|
||||||
if ($this->tracingEnabled === true) {
|
if ($this->tracingEnabled === true) {
|
||||||
$this->lastRequestHeaders = $this->curl->getRequestHeaders();
|
$this->lastRequestHeaders = $this->curl->getRequestHeaders();
|
||||||
@ -273,6 +246,18 @@ class SoapClient extends \SoapClient
|
|||||||
return $headers;
|
return $headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds additional cURL options for the request
|
||||||
|
*
|
||||||
|
* @param SoapRequest $soapRequest SOAP request object
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function filterRequestOptions(SoapRequest $soapRequest)
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get last request HTTP headers.
|
* Get last request HTTP headers.
|
||||||
*
|
*
|
||||||
|
@ -175,19 +175,28 @@ class SoapClientBuilder extends AbstractSoapBuilder
|
|||||||
*
|
*
|
||||||
* @param string $host Host
|
* @param string $host Host
|
||||||
* @param int $port Port
|
* @param int $port Port
|
||||||
* @param string $username Username
|
* @param string $login Login
|
||||||
* @param string $password Password
|
* @param string $password Password
|
||||||
|
* @param int $auth Authentication method
|
||||||
*
|
*
|
||||||
* @return \BeSimple\SoapClient\SoapClientBuilder
|
* @return \BeSimple\SoapClient\SoapClientBuilder
|
||||||
*/
|
*/
|
||||||
public function withProxy($host, $port, $username = null, $password = null)
|
public function withProxy($host, $port, $login = null, $password = null, $auth = null)
|
||||||
{
|
{
|
||||||
$this->soapOptions['proxy_host'] = $host;
|
$this->soapOptions['proxy_host'] = $host;
|
||||||
$this->soapOptions['proxy_port'] = $port;
|
$this->soapOptions['proxy_port'] = $port;
|
||||||
|
|
||||||
if ($username) {
|
if ($login) {
|
||||||
$this->soapOptions['proxy_login'] = $username;
|
$this->soapOptions['proxy_login'] = $login;
|
||||||
$this->soapOptions['proxy_password'] = $password;
|
$this->soapOptions['proxy_password'] = $password;
|
||||||
|
|
||||||
|
if ($auth) {
|
||||||
|
if (!in_array($auth, array(\CURLAUTH_BASIC, \CURLAUTH_NTLM), true)) {
|
||||||
|
throw new \InvalidArgumentException('Invalid authentication method: CURLAUTH_BASIC or CURLAUTH_NTLM constants are availables.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->soapOptions['proxy_auth'] = $auth;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -23,8 +23,7 @@ abstract class AbstractWebServerTest extends \PHPUnit_Framework_TestCase
|
|||||||
/**
|
/**
|
||||||
* @var ProcessBuilder
|
* @var ProcessBuilder
|
||||||
*/
|
*/
|
||||||
static protected $webserver;
|
protected static $webserver;
|
||||||
static protected $websererPortLength;
|
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass()
|
||||||
{
|
{
|
||||||
@ -44,8 +43,6 @@ abstract class AbstractWebServerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
self::$webserver->start();
|
self::$webserver->start();
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
|
|
||||||
self::$websererPortLength = strlen(WEBSERVER_PORT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function tearDownAfterClass()
|
public static function tearDownAfterClass()
|
||||||
|
@ -28,6 +28,7 @@ class MtomAxisInteropTest extends TestCase
|
|||||||
'base64Binary' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\base64Binary',
|
'base64Binary' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\base64Binary',
|
||||||
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\AttachmentRequest',
|
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\AttachmentRequest',
|
||||||
),
|
),
|
||||||
|
'proxy_host' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testAttachment()
|
public function testAttachment()
|
||||||
|
@ -37,6 +37,7 @@ class SwaAxisInteropTest extends TestCase
|
|||||||
'uploadFile' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\uploadFile',
|
'uploadFile' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\uploadFile',
|
||||||
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\uploadFileResponse',
|
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\uploadFileResponse',
|
||||||
),
|
),
|
||||||
|
'proxy_host' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testUploadDownloadText()
|
public function testUploadDownloadText()
|
||||||
|
@ -32,6 +32,7 @@ class WsAddressingAxisInteropTest extends TestCase
|
|||||||
private $options = array(
|
private $options = array(
|
||||||
'soap_version' => SOAP_1_2,
|
'soap_version' => SOAP_1_2,
|
||||||
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
|
'features' => SOAP_SINGLE_ELEMENT_ARRAYS, // make sure that result is array for size=1
|
||||||
|
'proxy_host' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testSession()
|
public function testSession()
|
||||||
|
@ -64,6 +64,7 @@ class WsSecuritySigEncAxisInteropTest extends TestCase
|
|||||||
'addBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBookResponse',
|
'addBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBookResponse',
|
||||||
'BookInformation' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation',
|
'BookInformation' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation',
|
||||||
),
|
),
|
||||||
|
'proxy_host' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testSigEnc()
|
public function testSigEnc()
|
||||||
|
@ -40,6 +40,7 @@ class WsSecurityUserPassAxisInteropTest extends TestCase
|
|||||||
'addBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBookResponse',
|
'addBookResponse' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\addBookResponse',
|
||||||
'BookInformation' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation',
|
'BookInformation' => 'BeSimple\SoapClient\Tests\AxisInterop\Fixtures\BookInformation',
|
||||||
),
|
),
|
||||||
|
'proxy_host' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testUserPassText()
|
public function testUserPassText()
|
||||||
|
@ -21,7 +21,9 @@ class CurlTest extends AbstractWebserverTest
|
|||||||
{
|
{
|
||||||
public function testExec()
|
public function testExec()
|
||||||
{
|
{
|
||||||
$curl = new Curl();
|
$curl = new Curl(array(
|
||||||
|
'proxy_host' => false,
|
||||||
|
));
|
||||||
|
|
||||||
$this->assertTrue($curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)));
|
$this->assertTrue($curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT)));
|
||||||
$this->assertTrue($curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT)));
|
$this->assertTrue($curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT)));
|
||||||
@ -29,7 +31,9 @@ class CurlTest extends AbstractWebserverTest
|
|||||||
|
|
||||||
public function testGetErrorMessage()
|
public function testGetErrorMessage()
|
||||||
{
|
{
|
||||||
$curl = new Curl();
|
$curl = new Curl(array(
|
||||||
|
'proxy_host' => false,
|
||||||
|
));
|
||||||
|
|
||||||
$curl->exec('http://unknown/curl.txt');
|
$curl->exec('http://unknown/curl.txt');
|
||||||
$this->assertEquals('Could not connect to host', $curl->getErrorMessage());
|
$this->assertEquals('Could not connect to host', $curl->getErrorMessage());
|
||||||
@ -41,24 +45,14 @@ class CurlTest extends AbstractWebserverTest
|
|||||||
$this->assertEquals('Unable to parse URL', $curl->getErrorMessage());
|
$this->assertEquals('Unable to parse URL', $curl->getErrorMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetRequestHeaders()
|
|
||||||
{
|
|
||||||
$curl = new Curl();
|
|
||||||
|
|
||||||
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
|
||||||
$this->assertEquals(132 + self::$websererPortLength, strlen($curl->getRequestHeaders()));
|
|
||||||
|
|
||||||
$curl->exec(sprintf('http://localhost:%s/404.txt', WEBSERVER_PORT));
|
|
||||||
$this->assertEquals(131 + self::$websererPortLength, strlen($curl->getRequestHeaders()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetResponse()
|
public function testGetResponse()
|
||||||
{
|
{
|
||||||
$curl = new Curl();
|
$curl = new Curl(array(
|
||||||
|
'proxy_host' => false,
|
||||||
|
));
|
||||||
|
|
||||||
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
||||||
$this->assertSame('OK', $curl->getResponseStatusMessage());
|
$this->assertSame('OK', $curl->getResponseStatusMessage());
|
||||||
$this->assertEquals(145 + self::$websererPortLength, strlen($curl->getResponse()));
|
|
||||||
|
|
||||||
$curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT));
|
$curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT));
|
||||||
$this->assertSame('Not Found', $curl->getResponseStatusMessage());
|
$this->assertSame('Not Found', $curl->getResponseStatusMessage());
|
||||||
@ -66,7 +60,9 @@ class CurlTest extends AbstractWebserverTest
|
|||||||
|
|
||||||
public function testGetResponseBody()
|
public function testGetResponseBody()
|
||||||
{
|
{
|
||||||
$curl = new Curl();
|
$curl = new Curl(array(
|
||||||
|
'proxy_host' => false,
|
||||||
|
));
|
||||||
|
|
||||||
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
||||||
$this->assertEquals('This is a testfile for cURL.', $curl->getResponseBody());
|
$this->assertEquals('This is a testfile for cURL.', $curl->getResponseBody());
|
||||||
@ -74,7 +70,9 @@ class CurlTest extends AbstractWebserverTest
|
|||||||
|
|
||||||
public function testGetResponseContentType()
|
public function testGetResponseContentType()
|
||||||
{
|
{
|
||||||
$curl = new Curl();
|
$curl = new Curl(array(
|
||||||
|
'proxy_host' => false,
|
||||||
|
));
|
||||||
|
|
||||||
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
||||||
$this->assertEquals('text/plain; charset=UTF-8', $curl->getResponseContentType());
|
$this->assertEquals('text/plain; charset=UTF-8', $curl->getResponseContentType());
|
||||||
@ -83,20 +81,11 @@ class CurlTest extends AbstractWebserverTest
|
|||||||
$this->assertEquals('text/html; charset=UTF-8', $curl->getResponseContentType());
|
$this->assertEquals('text/html; charset=UTF-8', $curl->getResponseContentType());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetResponseHeaders()
|
|
||||||
{
|
|
||||||
$curl = new Curl();
|
|
||||||
|
|
||||||
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
|
||||||
$this->assertEquals(117 + self::$websererPortLength, strlen($curl->getResponseHeaders()));
|
|
||||||
|
|
||||||
$curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT));
|
|
||||||
$this->assertEquals(124 + self::$websererPortLength, strlen($curl->getResponseHeaders()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetResponseStatusCode()
|
public function testGetResponseStatusCode()
|
||||||
{
|
{
|
||||||
$curl = new Curl();
|
$curl = new Curl(array(
|
||||||
|
'proxy_host' => false,
|
||||||
|
));
|
||||||
|
|
||||||
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
||||||
$this->assertEquals(200, $curl->getResponseStatusCode());
|
$this->assertEquals(200, $curl->getResponseStatusCode());
|
||||||
|
@ -18,7 +18,6 @@ $options = array(
|
|||||||
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
|
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
|
||||||
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
|
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
|
||||||
'connection_timeout' => 1,
|
'connection_timeout' => 1,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -37,7 +36,6 @@ try {
|
|||||||
$attachment->binaryData = $b64;
|
$attachment->binaryData = $b64;
|
||||||
|
|
||||||
var_dump($sc->attachment($attachment));
|
var_dump($sc->attachment($attachment));
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
var_dump($e);
|
var_dump($e);
|
||||||
}
|
}
|
||||||
|
@ -14,13 +14,13 @@ $options = array(
|
|||||||
'cache_wsdl' => WSDL_CACHE_NONE,
|
'cache_wsdl' => WSDL_CACHE_NONE,
|
||||||
'classmap' => array(
|
'classmap' => array(
|
||||||
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
|
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
|
||||||
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
|
'AttachmentType' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
class Mtom
|
class Mtom
|
||||||
{
|
{
|
||||||
public function attachment(AttachmentRequest $attachment)
|
public function attachment(Fixtures\AttachmentRequest $attachment)
|
||||||
{
|
{
|
||||||
$b64 = $attachment->binaryData;
|
$b64 = $attachment->binaryData;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class MtomServerInteropTest extends TestCase
|
|||||||
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
|
'base64Binary' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\base64Binary',
|
||||||
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
|
'AttachmentRequest' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\AttachmentRequest',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
'proxy_host' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testAttachment()
|
public function testAttachment()
|
||||||
|
@ -24,13 +24,11 @@ $options = array(
|
|||||||
'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile',
|
'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile',
|
||||||
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse',
|
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $options);
|
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $options);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$upload = new uploadFile();
|
$upload = new uploadFile();
|
||||||
$upload->name = 'upload.txt';
|
$upload->name = 'upload.txt';
|
||||||
$upload->data = 'This is a test. :)';
|
$upload->data = 'This is a test. :)';
|
||||||
|
@ -23,7 +23,7 @@ class SwaServerInteropTest extends TestCase
|
|||||||
'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile',
|
'uploadFile' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFile',
|
||||||
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse',
|
'uploadFileResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\uploadFileResponse',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
'proxy_host' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testUploadDownloadText()
|
public function testUploadDownloadText()
|
||||||
@ -42,6 +42,8 @@ class SwaServerInteropTest extends TestCase
|
|||||||
$result = $sc->downloadFile($download);
|
$result = $sc->downloadFile($download);
|
||||||
|
|
||||||
$this->assertEquals($upload->data, $result->data);
|
$this->assertEquals($upload->data, $result->data);
|
||||||
|
|
||||||
|
unlink(__DIR__.'/../ServerInterop/'.$download->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUploadDownloadImage()
|
public function testUploadDownloadImage()
|
||||||
@ -60,5 +62,7 @@ class SwaServerInteropTest extends TestCase
|
|||||||
$result = $sc->downloadFile($download);
|
$result = $sc->downloadFile($download);
|
||||||
|
|
||||||
$this->assertEquals($upload->data, $result->data);
|
$this->assertEquals($upload->data, $result->data);
|
||||||
|
|
||||||
|
unlink(__DIR__.'/../ServerInterop/'.$download->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -31,7 +31,6 @@ $options = array(
|
|||||||
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
||||||
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecuritySigEnc.wsdl', $options);
|
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecuritySigEnc.wsdl', $options);
|
||||||
@ -70,7 +69,6 @@ try {
|
|||||||
$ab->type = 'scifi';
|
$ab->type = 'scifi';
|
||||||
|
|
||||||
var_dump($sc->addBook($ab));
|
var_dump($sc->addBook($ab));
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
var_dump($e);
|
var_dump($e);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ class WsSecuritySigEncServerInteropTest extends TestCase
|
|||||||
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
||||||
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
'proxy_host' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testSigEnc()
|
public function testSigEnc()
|
||||||
|
@ -28,7 +28,6 @@ $options = array(
|
|||||||
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
||||||
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $options);
|
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $options);
|
||||||
@ -55,7 +54,6 @@ try {
|
|||||||
$ab->type = 'scifi';
|
$ab->type = 'scifi';
|
||||||
|
|
||||||
var_dump($sc->addBook($ab));
|
var_dump($sc->addBook($ab));
|
||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
var_dump($e);
|
var_dump($e);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ class WsSecurityUserPassServerInteropTest extends TestCase
|
|||||||
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
'addBookResponse' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\addBookResponse',
|
||||||
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
'BookInformation' => 'BeSimple\SoapClient\Tests\ServerInterop\Fixtures\BookInformation',
|
||||||
),
|
),
|
||||||
'cli_webserver_workaround' => true, // Work around missing header access in PHP cli webserver by setting headers additionally as GET parameters.
|
'proxy_host' => false,
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testUserPassText()
|
public function testUserPassText()
|
||||||
|
@ -96,6 +96,20 @@ class SoapClientBuilderTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
$builder->withProxy('127.0.0.1', 8585, 'foo', 'bar');
|
$builder->withProxy('127.0.0.1', 8585, 'foo', 'bar');
|
||||||
$this->assertEquals($this->mergeOptions(array('proxy_host' => '127.0.0.1', 'proxy_port' => 8585, 'proxy_login' => 'foo', 'proxy_password' => 'bar')), $builder->getSoapOptions());
|
$this->assertEquals($this->mergeOptions(array('proxy_host' => '127.0.0.1', 'proxy_port' => 8585, 'proxy_login' => 'foo', 'proxy_password' => 'bar')), $builder->getSoapOptions());
|
||||||
|
|
||||||
|
$builder->withProxy('127.0.0.1', 8585, 'foo', 'bar', \CURLAUTH_BASIC);
|
||||||
|
$this->assertEquals($this->mergeOptions(array('proxy_host' => '127.0.0.1', 'proxy_port' => 8585, 'proxy_login' => 'foo', 'proxy_password' => 'bar', 'proxy_auth' => \CURLAUTH_BASIC)), $builder->getSoapOptions());
|
||||||
|
|
||||||
|
$builder->withProxy('127.0.0.1', 8585, 'foo', 'bar', \CURLAUTH_NTLM);
|
||||||
|
$this->assertEquals($this->mergeOptions(array('proxy_host' => '127.0.0.1', 'proxy_port' => 8585, 'proxy_login' => 'foo', 'proxy_password' => 'bar', 'proxy_auth' => \CURLAUTH_NTLM)), $builder->getSoapOptions());
|
||||||
|
|
||||||
|
try {
|
||||||
|
$builder->withProxy('127.0.0.1', 8585, 'foo', 'bar', -100);
|
||||||
|
|
||||||
|
$this->fail('An expected exception has not been raised.');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
$this->assertInstanceOf('InvalidArgumentException', $e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreateWithDefaults()
|
public function testCreateWithDefaults()
|
||||||
|
@ -25,9 +25,9 @@ use org\bovigo\vfs\vfsStreamWrapper;
|
|||||||
*/
|
*/
|
||||||
class WsdlDownloaderTest extends AbstractWebserverTest
|
class WsdlDownloaderTest extends AbstractWebserverTest
|
||||||
{
|
{
|
||||||
static protected $filesystem;
|
protected static $filesystem;
|
||||||
|
|
||||||
static protected $fixturesPath;
|
protected static $fixturesPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideDownload
|
* @dataProvider provideDownload
|
||||||
@ -41,7 +41,9 @@ class WsdlDownloaderTest extends AbstractWebserverTest
|
|||||||
Cache::setDirectory($wsdlCacheUrl);
|
Cache::setDirectory($wsdlCacheUrl);
|
||||||
$cacheDirForRegExp = preg_quote($wsdlCacheUrl, '#');
|
$cacheDirForRegExp = preg_quote($wsdlCacheUrl, '#');
|
||||||
|
|
||||||
$wsdlDownloader = new WsdlDownloader(new Curl());
|
$wsdlDownloader = new WsdlDownloader(new Curl(array(
|
||||||
|
'proxy_host' => false,
|
||||||
|
)));
|
||||||
$this->assertCount(0, $wsdlCacheDir->getChildren());
|
$this->assertCount(0, $wsdlCacheDir->getChildren());
|
||||||
|
|
||||||
$cacheFileName = $wsdlDownloader->download($source);
|
$cacheFileName = $wsdlDownloader->download($source);
|
||||||
@ -113,7 +115,9 @@ class WsdlDownloaderTest extends AbstractWebserverTest
|
|||||||
Cache::setDirectory($wsdlCacheUrl);
|
Cache::setDirectory($wsdlCacheUrl);
|
||||||
$cacheDirForRegExp = preg_quote($wsdlCacheUrl, '#');
|
$cacheDirForRegExp = preg_quote($wsdlCacheUrl, '#');
|
||||||
|
|
||||||
$wsdlDownloader = new WsdlDownloader(new Curl());
|
$wsdlDownloader = new WsdlDownloader(new Curl(array(
|
||||||
|
'proxy_host' => false,
|
||||||
|
)));
|
||||||
$r = new \ReflectionClass($wsdlDownloader);
|
$r = new \ReflectionClass($wsdlDownloader);
|
||||||
$m = $r->getMethod('resolveRemoteIncludes');
|
$m = $r->getMethod('resolveRemoteIncludes');
|
||||||
$m->setAccessible(true);
|
$m->setAccessible(true);
|
||||||
@ -176,7 +180,9 @@ class WsdlDownloaderTest extends AbstractWebserverTest
|
|||||||
Cache::setDirectory($wsdlCacheUrl);
|
Cache::setDirectory($wsdlCacheUrl);
|
||||||
$cacheDirForRegExp = preg_quote($wsdlCacheUrl, '#');
|
$cacheDirForRegExp = preg_quote($wsdlCacheUrl, '#');
|
||||||
|
|
||||||
$wsdlDownloader = new WsdlDownloader(new Curl());
|
$wsdlDownloader = new WsdlDownloader(new Curl(array(
|
||||||
|
'proxy_host' => false,
|
||||||
|
)));
|
||||||
$r = new \ReflectionClass($wsdlDownloader);
|
$r = new \ReflectionClass($wsdlDownloader);
|
||||||
$m = $r->getMethod('resolveRemoteIncludes');
|
$m = $r->getMethod('resolveRemoteIncludes');
|
||||||
$m->setAccessible(true);
|
$m->setAccessible(true);
|
||||||
@ -272,7 +278,7 @@ class WsdlDownloaderTest extends AbstractWebserverTest
|
|||||||
$content = file_get_contents(self::$fixturesPath.$file);
|
$content = file_get_contents(self::$fixturesPath.$file);
|
||||||
$content = preg_replace('#'.preg_quote('%location%').'#', sprintf('localhost:%d', WEBSERVER_PORT), $content);
|
$content = preg_replace('#'.preg_quote('%location%').'#', sprintf('localhost:%d', WEBSERVER_PORT), $content);
|
||||||
|
|
||||||
self::$filesystem->dumpFile(self::$fixturesPath.'build_include'.DIRECTORY_SEPARATOR.pathinfo($file, PATHINFO_BASENAME), $content);
|
file_put_contents(self::$fixturesPath.'build_include'.DIRECTORY_SEPARATOR.pathinfo($file, PATHINFO_BASENAME), $content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +23,12 @@ if [ ! -f "$DIR/$ZIP_RAMPART" ]; then
|
|||||||
curl -O -s $PATH_RAMPART
|
curl -O -s $PATH_RAMPART
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unzip -qq "$DIR/$ZIP_AXIS"
|
unzip -o -qq "$DIR/$ZIP_AXIS"
|
||||||
|
|
||||||
AXIS_DIR=$DIR/axis2-$VERSION_AXIS
|
AXIS_DIR=$DIR/axis2-$VERSION_AXIS
|
||||||
|
|
||||||
unzip -qq -j "$DIR/$ZIP_RAMPART" '*/lib/*.jar' -d $AXIS_DIR/lib
|
unzip -o -qq -j "$DIR/$ZIP_RAMPART" '*/lib/*.jar' -d $AXIS_DIR/lib
|
||||||
unzip -qq -j "$DIR/$ZIP_RAMPART" '*/modules/*.mar' -d $AXIS_DIR/repository/modules
|
unzip -o -qq -j "$DIR/$ZIP_RAMPART" '*/modules/*.mar' -d $AXIS_DIR/repository/modules
|
||||||
|
|
||||||
cp -r $DIR/../AxisInterop/axis_services/* $AXIS_DIR/repository/services
|
cp -r $DIR/../AxisInterop/axis_services/* $AXIS_DIR/repository/services
|
||||||
|
|
||||||
|
@ -157,7 +157,6 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
|
|||||||
public function getReferenceParameter($ns, $parameter)
|
public function getReferenceParameter($ns, $parameter)
|
||||||
{
|
{
|
||||||
if (isset($this->referenceParametersRecieved[$ns][$parameter])) {
|
if (isset($this->referenceParametersRecieved[$ns][$parameter])) {
|
||||||
|
|
||||||
return $this->referenceParametersRecieved[$ns][$parameter];
|
return $this->referenceParametersRecieved[$ns][$parameter];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,7 +151,6 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
|
|||||||
if (null !== $this->password
|
if (null !== $this->password
|
||||||
&& (null === $this->userSecurityKey
|
&& (null === $this->userSecurityKey
|
||||||
|| (null !== $this->userSecurityKey && !$this->userSecurityKey->hasPrivateKey()))) {
|
|| (null !== $this->userSecurityKey && !$this->userSecurityKey->hasPrivateKey()))) {
|
||||||
|
|
||||||
if (self::PASSWORD_TYPE_DIGEST === $this->passwordType) {
|
if (self::PASSWORD_TYPE_DIGEST === $this->passwordType) {
|
||||||
$nonce = mt_rand();
|
$nonce = mt_rand();
|
||||||
$password = base64_encode(sha1($nonce . $createdTimestamp . $this->password, true));
|
$password = base64_encode(sha1($nonce . $createdTimestamp . $this->password, true));
|
||||||
|
@ -56,7 +56,7 @@ class WsdlDownloader
|
|||||||
/**
|
/**
|
||||||
* Resolve WSDl/XSD includes.
|
* Resolve WSDl/XSD includes.
|
||||||
*
|
*
|
||||||
* @var boolean
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $resolveRemoteIncludes = true;
|
protected $resolveRemoteIncludes = true;
|
||||||
|
|
||||||
@ -64,13 +64,13 @@ class WsdlDownloader
|
|||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param \BeSimple\SoapClient\Curl $curl Curl instance
|
* @param \BeSimple\SoapClient\Curl $curl Curl instance
|
||||||
* @param boolean $resolveRemoteIncludes WSDL/XSD include enabled?
|
* @param bool $resolveRemoteIncludes WSDL/XSD include enabled?
|
||||||
* @param boolean $cacheWsdl Cache constant
|
* @param bool $cacheWsdl Cache constant
|
||||||
*/
|
*/
|
||||||
public function __construct(Curl $curl, $resolveRemoteIncludes = true, $cacheWsdl = Cache::TYPE_DISK)
|
public function __construct(Curl $curl, $resolveRemoteIncludes = true, $cacheWsdl = Cache::TYPE_DISK)
|
||||||
{
|
{
|
||||||
$this->curl = $curl;
|
$this->curl = $curl;
|
||||||
$this->resolveRemoteIncludes = (Boolean) $resolveRemoteIncludes;
|
$this->resolveRemoteIncludes = (bool) $resolveRemoteIncludes;
|
||||||
|
|
||||||
// get current WSDL caching config
|
// get current WSDL caching config
|
||||||
$this->cacheEnabled = $cacheWsdl === Cache::TYPE_NONE ? Cache::DISABLED : Cache::ENABLED == Cache::isEnabled();
|
$this->cacheEnabled = $cacheWsdl === Cache::TYPE_NONE ? Cache::DISABLED : Cache::ENABLED == Cache::isEnabled();
|
||||||
@ -101,6 +101,20 @@ class WsdlDownloader
|
|||||||
if ($responseSuccessfull) {
|
if ($responseSuccessfull) {
|
||||||
$response = $this->curl->getResponseBody();
|
$response = $this->curl->getResponseBody();
|
||||||
|
|
||||||
|
libxml_use_internal_errors(true);
|
||||||
|
|
||||||
|
$doc = simplexml_load_string($response);
|
||||||
|
|
||||||
|
if (!$doc) {
|
||||||
|
$errors = libxml_get_errors();
|
||||||
|
|
||||||
|
if (count($errors)) {
|
||||||
|
throw new \Exception('There is something wrong with the WSDL file formatting. The file can\'t be downloaded to be cached.');
|
||||||
|
}
|
||||||
|
|
||||||
|
libxml_clear_errors();
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->resolveRemoteIncludes) {
|
if ($this->resolveRemoteIncludes) {
|
||||||
$this->resolveRemoteIncludes($response, $cacheFilePath, $wsdl);
|
$this->resolveRemoteIncludes($response, $cacheFilePath, $wsdl);
|
||||||
} else {
|
} else {
|
||||||
@ -130,7 +144,7 @@ class WsdlDownloader
|
|||||||
*
|
*
|
||||||
* @param string $file File URL/path
|
* @param string $file File URL/path
|
||||||
*
|
*
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function isRemoteFile($file)
|
private function isRemoteFile($file)
|
||||||
{
|
{
|
||||||
@ -149,9 +163,7 @@ class WsdlDownloader
|
|||||||
*
|
*
|
||||||
* @param string $xml XML file
|
* @param string $xml XML file
|
||||||
* @param string $cacheFilePath Cache file name
|
* @param string $cacheFilePath Cache file name
|
||||||
* @param boolean $parentFilePath Parent file name
|
* @param bool $parentFilePath Parent file name
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
private function resolveRemoteIncludes($xml, $cacheFilePath, $parentFilePath = null)
|
private function resolveRemoteIncludes($xml, $cacheFilePath, $parentFilePath = null)
|
||||||
{
|
{
|
||||||
@ -214,7 +226,7 @@ class WsdlDownloader
|
|||||||
$urlParts = parse_url($base);
|
$urlParts = parse_url($base);
|
||||||
|
|
||||||
// combine base path with relative path
|
// combine base path with relative path
|
||||||
if (isset($urlParts['path']) && '/' === $relative{0}) {
|
if (isset($urlParts['path']) && '/' === $relative[0]) {
|
||||||
// $relative is absolute path from domain (starts with /)
|
// $relative is absolute path from domain (starts with /)
|
||||||
$path = $relative;
|
$path = $relative;
|
||||||
} elseif (isset($urlParts['path']) && strrpos($urlParts['path'], '/') === (strlen($urlParts['path']))) {
|
} elseif (isset($urlParts['path']) && strrpos($urlParts['path'], '/') === (strlen($urlParts['path']))) {
|
||||||
@ -247,7 +259,7 @@ class WsdlDownloader
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$keyToDelete--;
|
--$keyToDelete;
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($parts[$key]);
|
unset($parts[$key]);
|
||||||
|
@ -65,6 +65,5 @@ class XmlMimeFilter implements SoapRequestFilter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,15 +27,14 @@
|
|||||||
"ass/xmlsecurity": "~1.0"
|
"ass/xmlsecurity": "~1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"mikey179/vfsStream": "dev-master",
|
"mikey179/vfsStream": "~1.0",
|
||||||
"symfony/filesystem": "~2.3",
|
"symfony/filesystem": "~2.0",
|
||||||
"symfony/process": "~2.3"
|
"symfony/process": "~2.3"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": { "BeSimple\\SoapClient": "" }
|
"psr-0": { "BeSimple\\SoapClient": "" }
|
||||||
},
|
},
|
||||||
"target-dir": "BeSimple/SoapClient",
|
"target-dir": "BeSimple/SoapClient",
|
||||||
"minimum-stability": "dev",
|
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "0.2-dev"
|
"dev-master": "0.2-dev"
|
||||||
|
@ -27,7 +27,7 @@ abstract class AbstractSoapBuilder
|
|||||||
/**
|
/**
|
||||||
* @return AbstractSoapBuilder
|
* @return AbstractSoapBuilder
|
||||||
*/
|
*/
|
||||||
static public function createWithDefaults()
|
public static function createWithDefaults()
|
||||||
{
|
{
|
||||||
$builder = new static();
|
$builder = new static();
|
||||||
|
|
||||||
|
@ -25,24 +25,24 @@ class Cache
|
|||||||
const TYPE_MEMORY = WSDL_CACHE_MEMORY;
|
const TYPE_MEMORY = WSDL_CACHE_MEMORY;
|
||||||
const TYPE_DISK_MEMORY = WSDL_CACHE_BOTH;
|
const TYPE_DISK_MEMORY = WSDL_CACHE_BOTH;
|
||||||
|
|
||||||
static protected $types = array(
|
protected static $types = array(
|
||||||
self::TYPE_NONE,
|
self::TYPE_NONE,
|
||||||
self::TYPE_DISK,
|
self::TYPE_DISK,
|
||||||
self::TYPE_MEMORY,
|
self::TYPE_MEMORY,
|
||||||
self::TYPE_DISK_MEMORY,
|
self::TYPE_DISK_MEMORY,
|
||||||
);
|
);
|
||||||
|
|
||||||
static public function getTypes()
|
public static function getTypes()
|
||||||
{
|
{
|
||||||
return self::$types;
|
return self::$types;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function isEnabled()
|
public static function isEnabled()
|
||||||
{
|
{
|
||||||
return self::iniGet('soap.wsdl_cache_enabled');
|
return self::iniGet('soap.wsdl_cache_enabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function setEnabled($enabled)
|
public static function setEnabled($enabled)
|
||||||
{
|
{
|
||||||
if (!in_array($enabled, array(self::ENABLED, self::DISABLED), true)) {
|
if (!in_array($enabled, array(self::ENABLED, self::DISABLED), true)) {
|
||||||
throw new \InvalidArgumentException();
|
throw new \InvalidArgumentException();
|
||||||
@ -51,12 +51,12 @@ class Cache
|
|||||||
self::iniSet('soap.wsdl_cache_enabled', $enabled);
|
self::iniSet('soap.wsdl_cache_enabled', $enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getType()
|
public static function getType()
|
||||||
{
|
{
|
||||||
return self::iniGet('soap.wsdl_cache');
|
return self::iniGet('soap.wsdl_cache');
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function setType($type)
|
public static function setType($type)
|
||||||
{
|
{
|
||||||
if (!in_array($type, self::getTypes(), true)) {
|
if (!in_array($type, self::getTypes(), true)) {
|
||||||
throw new \InvalidArgumentException('The cache type has to be either Cache::TYPE_NONE, Cache::TYPE_DISK, Cache::TYPE_MEMORY or Cache::TYPE_DISK_MEMORY');
|
throw new \InvalidArgumentException('The cache type has to be either Cache::TYPE_NONE, Cache::TYPE_DISK, Cache::TYPE_MEMORY or Cache::TYPE_DISK_MEMORY');
|
||||||
@ -65,12 +65,12 @@ class Cache
|
|||||||
self::iniSet('soap.wsdl_cache', $type);
|
self::iniSet('soap.wsdl_cache', $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getDirectory()
|
public static function getDirectory()
|
||||||
{
|
{
|
||||||
return self::iniGet('soap.wsdl_cache_dir');
|
return self::iniGet('soap.wsdl_cache_dir');
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function setDirectory($directory)
|
public static function setDirectory($directory)
|
||||||
{
|
{
|
||||||
if (!is_dir($directory)) {
|
if (!is_dir($directory)) {
|
||||||
mkdir($directory, 0777, true);
|
mkdir($directory, 0777, true);
|
||||||
@ -79,32 +79,32 @@ class Cache
|
|||||||
self::iniSet('soap.wsdl_cache_dir', $directory);
|
self::iniSet('soap.wsdl_cache_dir', $directory);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getLifetime()
|
public static function getLifetime()
|
||||||
{
|
{
|
||||||
return self::iniGet('soap.wsdl_cache_ttl');
|
return self::iniGet('soap.wsdl_cache_ttl');
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function setLifetime($lifetime)
|
public static function setLifetime($lifetime)
|
||||||
{
|
{
|
||||||
self::iniSet('soap.wsdl_cache_ttl', $lifetime);
|
self::iniSet('soap.wsdl_cache_ttl', $lifetime);
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function getLimit()
|
public static function getLimit()
|
||||||
{
|
{
|
||||||
return self::iniGet('soap.wsdl_cache_limit');
|
return self::iniGet('soap.wsdl_cache_limit');
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function setLimit($limit)
|
public static function setLimit($limit)
|
||||||
{
|
{
|
||||||
self::iniSet('soap.wsdl_cache_limit', $limit);
|
self::iniSet('soap.wsdl_cache_limit', $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected function iniGet($key)
|
protected static function iniGet($key)
|
||||||
{
|
{
|
||||||
return ini_get($key);
|
return ini_get($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
static protected function iniSet($key, $value)
|
protected static function iniSet($key, $value)
|
||||||
{
|
{
|
||||||
ini_set($key, $value);
|
ini_set($key, $value);
|
||||||
}
|
}
|
||||||
|
@ -44,4 +44,3 @@ class DateTimeTypeConverter implements TypeConverterInterface
|
|||||||
return sprintf('<%1$s>%2$s</%1$s>', $this->getTypeName(), $data->format('Y-m-d\TH:i:sP'));
|
return sprintf('<%1$s>%2$s</%1$s>', $this->getTypeName(), $data->format('Y-m-d\TH:i:sP'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,4 +44,3 @@ class DateTypeConverter implements TypeConverterInterface
|
|||||||
return sprintf('<%1$s>%2$s</%1$s>', $this->getTypeName(), $data->format('Y-m-d'));
|
return sprintf('<%1$s>%2$s</%1$s>', $this->getTypeName(), $data->format('Y-m-d'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,10 +65,8 @@ class MtomTypeConverter implements TypeConverterInterface, SoapKernelAwareInterf
|
|||||||
$contentId = urldecode(substr($ref, 4));
|
$contentId = urldecode(substr($ref, 4));
|
||||||
|
|
||||||
if (null !== ($part = $this->soapKernel->getAttachment($contentId))) {
|
if (null !== ($part = $this->soapKernel->getAttachment($contentId))) {
|
||||||
|
|
||||||
return $part->getContent();
|
return $part->getContent();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,5 +28,5 @@ interface SoapKernelAwareInterface
|
|||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function setKernel(SoapKernel $soapKernel);
|
public function setKernel(SoapKernel $soapKernel);
|
||||||
}
|
}
|
@ -61,10 +61,8 @@ class SwaTypeConverter implements TypeConverterInterface, SoapKernelAwareInterfa
|
|||||||
$contentId = urldecode(substr($ref, 4));
|
$contentId = urldecode(substr($ref, 4));
|
||||||
|
|
||||||
if (null !== ($part = $this->soapKernel->getAttachment($contentId))) {
|
if (null !== ($part = $this->soapKernel->getAttachment($contentId))) {
|
||||||
|
|
||||||
return $part->getContent();
|
return $part->getContent();
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,14 @@ interface TypeConverterInterface
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getTypeNamespace();
|
public function getTypeNamespace();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get type name.
|
* Get type name.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getTypeName();
|
public function getTypeName();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert given XML string to PHP type.
|
* Convert given XML string to PHP type.
|
||||||
@ -40,7 +40,7 @@ interface TypeConverterInterface
|
|||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function convertXmlToPhp($data);
|
public function convertXmlToPhp($data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert PHP type to XML string.
|
* Convert PHP type to XML string.
|
||||||
@ -49,5 +49,5 @@ interface TypeConverterInterface
|
|||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function convertPhpToXml($data);
|
public function convertPhpToXml($data);
|
||||||
}
|
}
|
@ -25,7 +25,7 @@ class Message
|
|||||||
public function __construct($name)
|
public function __construct($name)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->parts = array();
|
$this->parts = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getName()
|
public function getName()
|
||||||
@ -48,13 +48,13 @@ class Message
|
|||||||
return 0 === count($this->parts) ? true : false;
|
return 0 === count($this->parts) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add($name, $phpType, $nillable = false)
|
public function add($name, $phpType, $nillable = false, $minOccurs = 1)
|
||||||
{
|
{
|
||||||
if ($phpType instanceof TypeInterface) {
|
if ($phpType instanceof TypeInterface) {
|
||||||
$phpType = $phpType->getPhpType();
|
$phpType = $phpType->getPhpType();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->parts[$name] = new Part($name, $phpType, $nillable);
|
$this->parts[$name] = new Part($name, $phpType, $nillable, $minOccurs);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,6 @@
|
|||||||
|
|
||||||
namespace BeSimple\SoapCommon\Definition;
|
namespace BeSimple\SoapCommon\Definition;
|
||||||
|
|
||||||
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Francis Besset <francis.besset@gmail.com>
|
* @author Francis Besset <francis.besset@gmail.com>
|
||||||
*/
|
*/
|
||||||
@ -66,7 +64,7 @@ class Method
|
|||||||
$this->input->add($name, $type);
|
$this->input->add($name, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setOutput($type)
|
public function setOutput($type, $name = 'return')
|
||||||
{
|
{
|
||||||
$this->output->add('return', $type);
|
$this->output->add('return', $type);
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,13 @@ class Part
|
|||||||
protected $name;
|
protected $name;
|
||||||
protected $type;
|
protected $type;
|
||||||
protected $nillable;
|
protected $nillable;
|
||||||
|
protected $minOccurs;
|
||||||
|
|
||||||
public function __construct($name, $type, $nillable = false)
|
public function __construct($name, $type, $nillable = false, $minOccurs = 1)
|
||||||
{
|
{
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
|
$this->minOccurs = $minOccurs;
|
||||||
$this->setNillable($nillable);
|
$this->setNillable($nillable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +52,16 @@ class Part
|
|||||||
|
|
||||||
public function setNillable($nillable)
|
public function setNillable($nillable)
|
||||||
{
|
{
|
||||||
$this->nillable = (boolean) $nillable;
|
$this->nillable = (bool) $nillable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setMinOccurs($minOccurs)
|
||||||
|
{
|
||||||
|
$this->minOccurs = $minOccurs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMinOccurs()
|
||||||
|
{
|
||||||
|
return $this->minOccurs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,8 @@ class Helper
|
|||||||
return sprintf(
|
return sprintf(
|
||||||
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
|
||||||
// 32 bits for "time_low"
|
// 32 bits for "time_low"
|
||||||
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
|
mt_rand(0, 0xffff),
|
||||||
|
mt_rand(0, 0xffff),
|
||||||
// 16 bits for "time_mid"
|
// 16 bits for "time_mid"
|
||||||
mt_rand(0, 0xffff),
|
mt_rand(0, 0xffff),
|
||||||
// 16 bits for "time_hi_and_version",
|
// 16 bits for "time_hi_and_version",
|
||||||
@ -183,7 +184,9 @@ class Helper
|
|||||||
// two most significant bits holds zero and one for variant DCE1.1
|
// two most significant bits holds zero and one for variant DCE1.1
|
||||||
mt_rand(0, 0x3fff) | 0x8000,
|
mt_rand(0, 0x3fff) | 0x8000,
|
||||||
// 48 bits for "node"
|
// 48 bits for "node"
|
||||||
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
|
mt_rand(0, 0xffff),
|
||||||
|
mt_rand(0, 0xffff),
|
||||||
|
mt_rand(0, 0xffff)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,13 @@ abstract class SoapMessage
|
|||||||
*/
|
*/
|
||||||
const CONTENT_TYPE_HEADER = 'CONTENT_TYPE';
|
const CONTENT_TYPE_HEADER = 'CONTENT_TYPE';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* $_SERVER key for 'Content-Type' header (with PHP cli-webserver)
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const HTTP_CONTENT_TYPE_HEADER = 'HTTP_CONTENT_TYPE';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* $_SERVER key for 'SOAPAction' header.
|
* $_SERVER key for 'SOAPAction' header.
|
||||||
*
|
*
|
||||||
@ -40,7 +47,7 @@ abstract class SoapMessage
|
|||||||
*
|
*
|
||||||
* @var array(string=>string)
|
* @var array(string=>string)
|
||||||
*/
|
*/
|
||||||
static protected $versionToContentTypeMap = array(
|
protected static $versionToContentTypeMap = array(
|
||||||
SOAP_1_1 => 'text/xml; charset=utf-8',
|
SOAP_1_1 => 'text/xml; charset=utf-8',
|
||||||
SOAP_1_2 => 'application/soap+xml; charset=utf-8'
|
SOAP_1_2 => 'application/soap+xml; charset=utf-8'
|
||||||
);
|
);
|
||||||
|
@ -22,5 +22,4 @@ use BeSimple\SoapCommon\SoapMessage;
|
|||||||
*/
|
*/
|
||||||
class SoapRequest extends SoapMessage
|
class SoapRequest extends SoapMessage
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
@ -22,5 +22,4 @@ use BeSimple\SoapCommon\SoapMessage;
|
|||||||
*/
|
*/
|
||||||
class SoapResponse extends SoapMessage
|
class SoapResponse extends SoapMessage
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
@ -51,4 +51,3 @@ class DateTimeTypeConverterTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNull($date);
|
$this->assertNull($date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,4 +49,3 @@ class DateTypeConverterTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNull($date);
|
$this->assertNull($date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ namespace BeSimple\SoapCommon\Type\KeyValue;
|
|||||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||||
use BeSimple\SoapCommon\Type\AbstractKeyValue;
|
use BeSimple\SoapCommon\Type\AbstractKeyValue;
|
||||||
|
|
||||||
class Boolean extends AbstractKeyValue
|
class BsBoolean extends AbstractKeyValue
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Soap\ComplexType("boolean")
|
* @Soap\ComplexType("boolean")
|
@ -5,7 +5,7 @@ namespace BeSimple\SoapCommon\Type\KeyValue;
|
|||||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||||
use BeSimple\SoapCommon\Type\AbstractKeyValue;
|
use BeSimple\SoapCommon\Type\AbstractKeyValue;
|
||||||
|
|
||||||
class Float extends AbstractKeyValue
|
class BsFloat extends AbstractKeyValue
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Soap\ComplexType("float")
|
* @Soap\ComplexType("float")
|
@ -5,7 +5,7 @@ namespace BeSimple\SoapCommon\Type\KeyValue;
|
|||||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||||
use BeSimple\SoapCommon\Type\AbstractKeyValue;
|
use BeSimple\SoapCommon\Type\AbstractKeyValue;
|
||||||
|
|
||||||
class Int extends AbstractKeyValue
|
class BsInt extends AbstractKeyValue
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Soap\ComplexType("int")
|
* @Soap\ComplexType("int")
|
@ -5,7 +5,7 @@ namespace BeSimple\SoapCommon\Type\KeyValue;
|
|||||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||||
use BeSimple\SoapCommon\Type\AbstractKeyValue;
|
use BeSimple\SoapCommon\Type\AbstractKeyValue;
|
||||||
|
|
||||||
class String extends AbstractKeyValue
|
class BsString extends AbstractKeyValue
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @Soap\ComplexType("string")
|
* @Soap\ComplexType("string")
|
@ -30,7 +30,7 @@ abstract class WsSecurityFilterClientServer
|
|||||||
/**
|
/**
|
||||||
* The date format to be used with {@link \DateTime}
|
* The date format to be used with {@link \DateTime}
|
||||||
*/
|
*/
|
||||||
const DATETIME_FORMAT = 'Y-m-d\TH:i:s.000\Z';
|
const DATETIME_FORMAT = 'Y-m-d\TH:i:s.u\Z';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (X509 3.2.1) Reference to a Subject Key Identifier
|
* (X509 3.2.1) Reference to a Subject Key Identifier
|
||||||
@ -338,7 +338,6 @@ abstract class WsSecurityFilterClientServer
|
|||||||
return XmlSecurityKey::factory($algorithm, $key, false, XmlSecurityKey::TYPE_PRIVATE);
|
return XmlSecurityKey::factory($algorithm, $key, false, XmlSecurityKey::TYPE_PRIVATE);
|
||||||
} elseif (Helper::NS_WSS === $referencedNode->namespaceURI
|
} elseif (Helper::NS_WSS === $referencedNode->namespaceURI
|
||||||
&& 'BinarySecurityToken' == $referencedNode->localName) {
|
&& 'BinarySecurityToken' == $referencedNode->localName) {
|
||||||
|
|
||||||
$key = XmlSecurityPem::formatKeyInPemFormat($referencedNode->textContent);
|
$key = XmlSecurityPem::formatKeyInPemFormat($referencedNode->textContent);
|
||||||
|
|
||||||
return XmlSecurityKey::factory(XmlSecurityKey::RSA_SHA1, $key, false, XmlSecurityKey::TYPE_PUBLIC);
|
return XmlSecurityKey::factory(XmlSecurityKey::RSA_SHA1, $key, false, XmlSecurityKey::TYPE_PUBLIC);
|
||||||
|
@ -25,14 +25,12 @@
|
|||||||
"ass/xmlsecurity": "~1.0"
|
"ass/xmlsecurity": "~1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"ext-mcrypt": "*",
|
"mikey179/vfsstream": "~1.0"
|
||||||
"mikey179/vfsStream": "dev-master"
|
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": { "BeSimple\\SoapCommon": "" }
|
"psr-0": { "BeSimple\\SoapCommon": "" }
|
||||||
},
|
},
|
||||||
"target-dir": "BeSimple/SoapCommon",
|
"target-dir": "BeSimple/SoapCommon",
|
||||||
"minimum-stability": "dev",
|
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "0.2-dev"
|
"dev-master": "0.2-dev"
|
||||||
|
@ -32,29 +32,19 @@ class SoapRequest extends CommonSoapRequest
|
|||||||
*/
|
*/
|
||||||
public static function create($content, $version)
|
public static function create($content, $version)
|
||||||
{
|
{
|
||||||
$location = self::getCurrentUrl();
|
|
||||||
/*
|
|
||||||
* Work around missing header/php://input access in PHP cli webserver by
|
|
||||||
* setting headers additionally as GET parameters and SOAP request body
|
|
||||||
* explicitly as POST variable
|
|
||||||
*/
|
|
||||||
if (php_sapi_name() == "cli-server") {
|
|
||||||
$content = is_null($content) ? $_POST['request'] : $content;
|
|
||||||
$action = $_GET[SoapMessage::SOAP_ACTION_HEADER];
|
|
||||||
$contentType = $_GET[SoapMessage::CONTENT_TYPE_HEADER];
|
|
||||||
} else {
|
|
||||||
$content = is_null($content) ? file_get_contents("php://input") : $content;
|
|
||||||
$action = isset($_SERVER[SoapMessage::SOAP_ACTION_HEADER]) ? $_SERVER[SoapMessage::SOAP_ACTION_HEADER] : null;
|
|
||||||
$contentType = $_SERVER[SoapMessage::CONTENT_TYPE_HEADER];
|
|
||||||
}
|
|
||||||
|
|
||||||
$request = new SoapRequest();
|
$request = new SoapRequest();
|
||||||
|
|
||||||
// $content is if unmodified from SoapClient not a php string type!
|
// $content is if unmodified from SoapClient not a php string type!
|
||||||
$request->setContent((string) $content);
|
$request->setContent((string) (null === $content ? file_get_contents("php://input") : $content));
|
||||||
$request->setLocation($location);
|
$request->setLocation(self::getCurrentUrl());
|
||||||
$request->setAction($action);
|
$request->setAction(isset($_SERVER[SoapMessage::SOAP_ACTION_HEADER]) ? $_SERVER[SoapMessage::SOAP_ACTION_HEADER] : null);
|
||||||
$request->setVersion($version);
|
$request->setVersion($version);
|
||||||
$request->setContentType($contentType);
|
|
||||||
|
if (isset($_SERVER[SoapMessage::CONTENT_TYPE_HEADER])) {
|
||||||
|
$request->setContentType($_SERVER[SoapMessage::CONTENT_TYPE_HEADER]);
|
||||||
|
} elseif (isset($_SERVER[SoapMessage::HTTP_CONTENT_TYPE_HEADER])) {
|
||||||
|
$request->setContentType($_SERVER[SoapMessage::HTTP_CONTENT_TYPE_HEADER]);
|
||||||
|
}
|
||||||
|
|
||||||
return $request;
|
return $request;
|
||||||
}
|
}
|
||||||
|
@ -131,9 +131,7 @@ class SoapServer extends \SoapServer
|
|||||||
/**
|
/**
|
||||||
* Configure filter and type converter for SwA/MTOM.
|
* Configure filter and type converter for SwA/MTOM.
|
||||||
*
|
*
|
||||||
* @param array &$options SOAP constructor options array.
|
* @param array &$options SOAP constructor options array
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
private function configureMime(array &$options)
|
private function configureMime(array &$options)
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ class SoapServerBuilder extends AbstractSoapBuilder
|
|||||||
*
|
*
|
||||||
* @return \BeSimple\SoapServer\SoapServerBuilder
|
* @return \BeSimple\SoapServer\SoapServerBuilder
|
||||||
*/
|
*/
|
||||||
static public function createWithDefaults()
|
public static function createWithDefaults()
|
||||||
{
|
{
|
||||||
return parent::createWithDefaults()
|
return parent::createWithDefaults()
|
||||||
->withErrorReporting(false);
|
->withErrorReporting(false);
|
||||||
|
@ -86,7 +86,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
|
|||||||
$expires = $xpath->query($query, $security)->item(0);
|
$expires = $xpath->query($query, $security)->item(0);
|
||||||
|
|
||||||
if (null !== $expires) {
|
if (null !== $expires) {
|
||||||
$expiresDatetime = \DateTime::createFromFormat(self::DATETIME_FORMAT, $expires->textContent, new \DateTimeZone('UTC'));
|
$expiresDatetime = \DateTime::createFromFormat(static::DATETIME_FORMAT, $expires->textContent, new \DateTimeZone('UTC'));
|
||||||
$currentDatetime = new \DateTime('now', new \DateTimeZone('UTC'));
|
$currentDatetime = new \DateTime('now', new \DateTimeZone('UTC'));
|
||||||
|
|
||||||
if ($currentDatetime > $expiresDatetime) {
|
if ($currentDatetime > $expiresDatetime) {
|
||||||
@ -170,7 +170,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
|
|||||||
|
|
||||||
// init timestamp
|
// init timestamp
|
||||||
$dt = new \DateTime('now', new \DateTimeZone('UTC'));
|
$dt = new \DateTime('now', new \DateTimeZone('UTC'));
|
||||||
$createdTimestamp = $dt->format(self::DATETIME_FORMAT);
|
$createdTimestamp = $dt->format(static::DATETIME_FORMAT);
|
||||||
|
|
||||||
// create security header
|
// create security header
|
||||||
$security = $filterHelper->createElement(Helper::NS_WSS, 'Security');
|
$security = $filterHelper->createElement(Helper::NS_WSS, 'Security');
|
||||||
@ -182,7 +182,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
|
|||||||
$timestamp->appendChild($created);
|
$timestamp->appendChild($created);
|
||||||
if (null !== $this->expires) {
|
if (null !== $this->expires) {
|
||||||
$dt->modify('+' . $this->expires . ' seconds');
|
$dt->modify('+' . $this->expires . ' seconds');
|
||||||
$expiresTimestamp = $dt->format(self::DATETIME_FORMAT);
|
$expiresTimestamp = $dt->format(static::DATETIME_FORMAT);
|
||||||
$expires = $filterHelper->createElement(Helper::NS_WSU, 'Expires', $expiresTimestamp);
|
$expires = $filterHelper->createElement(Helper::NS_WSU, 'Expires', $expiresTimestamp);
|
||||||
$timestamp->appendChild($expires);
|
$timestamp->appendChild($expires);
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,5 @@ class XmlMimeFilter implements SoapResponseFilter
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,6 @@
|
|||||||
"psr-0": { "BeSimple\\SoapServer": "" }
|
"psr-0": { "BeSimple\\SoapServer": "" }
|
||||||
},
|
},
|
||||||
"target-dir": "BeSimple/SoapServer",
|
"target-dir": "BeSimple/SoapServer",
|
||||||
"minimum-stability": "dev",
|
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "0.2-dev"
|
"dev-master": "0.2-dev"
|
||||||
|
@ -54,7 +54,7 @@ class Dumper
|
|||||||
protected $domService;
|
protected $domService;
|
||||||
protected $domPortType;
|
protected $domPortType;
|
||||||
|
|
||||||
public function __construct(Definition $definition, array $options = array())
|
public function __construct(Definition $definition, array $options = [])
|
||||||
{
|
{
|
||||||
$this->definition = $definition;
|
$this->definition = $definition;
|
||||||
$this->document = new \DOMDocument('1.0', 'utf-8');
|
$this->document = new \DOMDocument('1.0', 'utf-8');
|
||||||
@ -64,15 +64,15 @@ class Dumper
|
|||||||
|
|
||||||
public function setOptions(array $options)
|
public function setOptions(array $options)
|
||||||
{
|
{
|
||||||
$this->options = array(
|
$this->options = [
|
||||||
'version11_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version11',
|
'version11_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version11',
|
||||||
'version12_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version12',
|
'version12_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version12',
|
||||||
'version11_name' => $this->definition->getName(),
|
'version11_name' => $this->definition->getName(),
|
||||||
'version12_name' => $this->definition->getName() . '12',
|
'version12_name' => $this->definition->getName() . '12',
|
||||||
'stylesheet' => null,
|
'stylesheet' => null,
|
||||||
);
|
];
|
||||||
|
|
||||||
$invalid = array();
|
$invalid = [];
|
||||||
foreach ($options as $key => $value) {
|
foreach ($options as $key => $value) {
|
||||||
if (array_key_exists($key, $this->options)) {
|
if (array_key_exists($key, $this->options)) {
|
||||||
$this->options[$key] = $value;
|
$this->options[$key] = $value;
|
||||||
@ -114,7 +114,7 @@ class Dumper
|
|||||||
$this->addMethods();
|
$this->addMethods();
|
||||||
$this->addService();
|
$this->addService();
|
||||||
|
|
||||||
foreach (array($this->version11, $this->version12) as $version) {
|
foreach ([$this->version11, $this->version12] as $version) {
|
||||||
if (!$version) {
|
if (!$version) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -265,6 +265,11 @@ class Dumper
|
|||||||
$element->setAttribute('maxOccurs', 'unbounded');
|
$element->setAttribute('maxOccurs', 'unbounded');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 1 is the default value of minOccurs.
|
||||||
|
if (1 != $child->getMinOccurs()) {
|
||||||
|
$element->setAttribute('minOccurs', $child->getMinOccurs());
|
||||||
|
}
|
||||||
|
|
||||||
$all->appendChild($element);
|
$all->appendChild($element);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -284,7 +289,7 @@ class Dumper
|
|||||||
$operation = $this->document->createElement('operation');
|
$operation = $this->document->createElement('operation');
|
||||||
$operation->setAttribute('name', $method->getName());
|
$operation->setAttribute('name', $method->getName());
|
||||||
|
|
||||||
foreach (array('input' => $method->getInput(), 'output' => $method->getOutput(), 'fault' => $method->getFault()) as $type => $message) {
|
foreach (['input' => $method->getInput(), 'output' => $method->getOutput(), 'fault' => $method->getFault()] as $type => $message) {
|
||||||
if ('fault' === $type && $message->isEmpty()) {
|
if ('fault' === $type && $message->isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
"psr-0": { "BeSimple\\SoapWsdl": "" }
|
"psr-0": { "BeSimple\\SoapWsdl": "" }
|
||||||
},
|
},
|
||||||
"target-dir": "BeSimple/SoapWsdl",
|
"target-dir": "BeSimple/SoapWsdl",
|
||||||
"minimum-stability": "dev",
|
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "0.2-dev"
|
"dev-master": "0.2-dev"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user