Compare commits
146 Commits
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
f2a8a7ebb3 | |||
bbd4c26134 | |||
294a9fe90e | |||
313840d5a4 | |||
8e4d8b0300 | |||
621b2080e0 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
||||
/vendor/
|
||||
composer.lock
|
||||
composer.phar
|
||||
phpunit.xml
|
||||
.idea
|
||||
|
18
.travis.yml
18
.travis.yml
@ -1,20 +1,16 @@
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
- 7.0
|
||||
- 7.1
|
||||
|
||||
env:
|
||||
- SYMFONY_VERSION=2.0.*
|
||||
- SYMFONY_VERSION=2.1.*
|
||||
- SYMFONY_VERSION=2.2.*
|
||||
- SYMFONY_VERSION=2.3.*
|
||||
- SYMFONY_VERSION=2.4.*
|
||||
- SYMFONY_VERSION=2.5.*
|
||||
- SYMFONY_VERSION="dev-master symfony/debug:~2.6@dev symfony/http-kernel:~2.6@dev"
|
||||
- SYMFONY_VERSION=2.8.*
|
||||
- SYMFONY_VERSION="dev-master symfony/debug:~2.8@dev symfony/http-kernel:~2.8@dev"
|
||||
|
||||
before_script:
|
||||
- phpenv config-add myphp.ini
|
||||
- composer self-update
|
||||
- composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update
|
||||
- composer update --no-interaction --prefer-source
|
||||
@ -26,4 +22,4 @@ script:
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- env: SYMFONY_VERSION="dev-master symfony/debug:~2.6@dev symfony/http-kernel:~2.6@dev"
|
||||
- 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
|
||||
|
||||
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
|
||||
|
||||
The BeSimpleSoapClient is a component that extends the native PHP SoapClient with further features like SwA, MTOM 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).
|
||||
|
||||
**Refactored** BeSimpleSoapClient is a component that extends the native PHP SoapClient with further features like SwA and WS-Security.
|
||||
|
||||
## BeSimpleSoapServer
|
||||
|
||||
The BeSimpleSoapServer is a component that extends the native PHP SoapServer with further features like SwA, MTOM and WS-Security.
|
||||
For further information see the [README](https://github.com/BeSimple/BeSimpleSoap/blob/master/src/BeSimple/SoapServer/README.md).
|
||||
**Refactored** BeSimpleSoapServer is a component that extends the native PHP SoapServer with further features like SwA and WS-Security.
|
||||
|
||||
## BeSimpleSoapCommon
|
||||
|
||||
**Refactored** BeSimpleSoapCommon component contains functionality shared by both the server and client implementations.
|
||||
|
||||
## 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
|
||||
curl -s http://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin
|
||||
# How to use
|
||||
|
||||
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": {
|
||||
"besimple/soap": "0.2.*@dev"
|
||||
}
|
||||
$response = new DummyServiceResponse();
|
||||
$response->status = true;
|
||||
|
||||
return $response;
|
||||
}
|
||||
```
|
||||
|
||||
Now you are ready to install the library:
|
||||
|
||||
```sh
|
||||
php /usr/local/bin/composer.phar install
|
||||
```
|
||||
For further information and getting inspiration for your implementation, see the unit tests in ``tests`` dir.
|
@ -1,9 +1,9 @@
|
||||
{
|
||||
"name": "besimple/soap",
|
||||
"name": "cadoles/soap",
|
||||
"type": "library",
|
||||
"description": "Build and consume SOAP and WSDL based web services",
|
||||
"keywords": ["soap"],
|
||||
"homepage": "http://besim.pl",
|
||||
"homepage": "https://github.com/Cadoles/BeSimpleSoap",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
@ -20,12 +20,12 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0",
|
||||
"php": ">=7.0",
|
||||
"ext-soap": "*",
|
||||
"ext-curl": "*",
|
||||
"ass/xmlsecurity": "~1.0",
|
||||
"symfony/framework-bundle": "~2.0",
|
||||
"symfony/twig-bundle": "~2.0",
|
||||
"symfony/framework-bundle": "~3.4|~4.0",
|
||||
"symfony/twig-bundle": "~3.4|~4.0",
|
||||
"zendframework/zend-mime": "2.1.*"
|
||||
},
|
||||
"replace": {
|
||||
@ -33,20 +33,21 @@
|
||||
"besimple/soap-client": "self.version",
|
||||
"besimple/soap-common": "self.version",
|
||||
"besimple/soap-server": "self.version",
|
||||
"besimple/soap-wsdl": "self.version"
|
||||
"besimple/soap-wsdl": "self.version",
|
||||
"cocciagialla/soap": "self.version"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-mcrypt": "*",
|
||||
"mikey179/vfsStream": "~1.0",
|
||||
"symfony/filesystem": "~2.0",
|
||||
"symfony/process": "~2.3"
|
||||
"mikey179/vfsstream": "~1.6.5",
|
||||
"symfony/filesystem": "~2.3",
|
||||
"symfony/process": "~2.3",
|
||||
"phpunit/phpunit": "^5.7"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "BeSimple\\": "src/" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "0.2-dev"
|
||||
"dev-master": "master-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1
src/BeSimple/SoapBundle/.gitignore
vendored
1
src/BeSimple/SoapBundle/.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
vendor/
|
||||
composer.lock
|
||||
phpunit.xml
|
||||
.idea/
|
||||
|
@ -15,21 +15,27 @@ namespace BeSimple\SoapBundle\Controller;
|
||||
use BeSimple\SoapBundle\Handler\ExceptionHandler;
|
||||
use BeSimple\SoapBundle\Soap\SoapRequest;
|
||||
use BeSimple\SoapBundle\Soap\SoapResponse;
|
||||
use BeSimple\SoapBundle\WebServiceContext;
|
||||
use BeSimple\SoapServer\SoapServerBuilder;
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
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\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
/**
|
||||
* @author Christian Kerl <christian-kerl@web.de>
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
*/
|
||||
class SoapWebServiceController extends ContainerAware
|
||||
class SoapWebServiceController implements ContainerAwareInterface
|
||||
{
|
||||
use ContainerAwareTrait;
|
||||
|
||||
/**
|
||||
* @var \SoapServer
|
||||
*/
|
||||
@ -60,11 +66,12 @@ class SoapWebServiceController extends ContainerAware
|
||||
*/
|
||||
public function callAction($webservice)
|
||||
{
|
||||
/** @var WebServiceContext $webServiceContext */
|
||||
$webServiceContext = $this->getWebServiceContext($webservice);
|
||||
|
||||
$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
|
||||
->getServerBuilder()
|
||||
->withSoapVersion11()
|
||||
@ -83,19 +90,26 @@ class SoapWebServiceController extends ContainerAware
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Symfony\Component\HttpFoundation\Response
|
||||
* @return Response
|
||||
*/
|
||||
public function definitionAction($webservice)
|
||||
{
|
||||
$routeName = $webservice . '_webservice_call';
|
||||
$result = $this->container->get('router')->getRouteCollection()->get($routeName);
|
||||
if ($result === null) {
|
||||
$routeName = '_webservice_call';
|
||||
}
|
||||
|
||||
$response = new Response($this->getWebServiceContext($webservice)->getWsdlFileContent(
|
||||
$this->container->get('router')->generate(
|
||||
'_webservice_call',
|
||||
$routeName,
|
||||
array('webservice' => $webservice),
|
||||
true
|
||||
UrlGeneratorInterface::ABSOLUTE_URL
|
||||
)
|
||||
));
|
||||
|
||||
$request = $this->container->get('request');
|
||||
/** @var Request $request */
|
||||
$request = $this->container->get('request_stack')->getCurrentRequest();
|
||||
$query = $request->query;
|
||||
if ($query->has('wsdl') || $query->has('WSDL')) {
|
||||
$request->setRequestFormat('wsdl');
|
||||
@ -121,9 +135,9 @@ 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);
|
||||
}
|
||||
|
||||
$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();
|
||||
$details = $this->container->get('templating')->render($view, array(
|
||||
$details = $this->container->get('twig')->render($view, array(
|
||||
'status_code' => $code,
|
||||
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
|
||||
'exception' => $exception,
|
||||
@ -237,7 +251,7 @@ class SoapWebServiceController extends ContainerAware
|
||||
return $this->soapResponse = $response;
|
||||
}
|
||||
|
||||
private function getWebServiceContext($webservice)
|
||||
protected function getWebServiceContext($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\SoapResponse;
|
||||
use BeSimple\SoapBundle\Util\String;
|
||||
use BeSimple\SoapBundle\Util\BsString;
|
||||
use BeSimple\SoapCommon\Converter\TypeConverterInterface;
|
||||
|
||||
/**
|
||||
@ -40,7 +40,7 @@ class XopIncludeTypeConverter implements TypeConverterInterface
|
||||
|
||||
$ref = $include->getAttribute('href');
|
||||
|
||||
if (String::startsWith($ref, 'cid:')) {
|
||||
if (BsString::startsWith($ref, 'cid:')) {
|
||||
$cid = urldecode(substr($ref, 4));
|
||||
|
||||
return $request->getSoapAttachments()->get($cid)->getContent();
|
||||
|
@ -17,10 +17,11 @@ use BeSimple\SoapCommon\Cache;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\DefinitionDecorator;
|
||||
use Symfony\Component\DependencyInjection\ChildDefinition;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
|
||||
/**
|
||||
* BeSimpleSoapExtension.
|
||||
@ -80,17 +81,21 @@ class BeSimpleSoapExtension extends Extension
|
||||
|
||||
private function registerClientConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
||||
{
|
||||
$loader->load('client.xml');
|
||||
if (3 === Kernel::MAJOR_VERSION) {
|
||||
$loader->load('client3.xml');
|
||||
} else {
|
||||
$loader->load('client.xml');
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
$definition->replaceArgument(0, $options['wsdl']);
|
||||
|
||||
$defOptions = $container
|
||||
->getDefinition('besimple.soap.client.builder')
|
||||
->getArgument(1);
|
||||
->getDefinition('besimple.soap.client.builder')
|
||||
->getArgument(1);
|
||||
|
||||
foreach (array('cache_type', 'user_agent') as $key) {
|
||||
if (isset($options[$key])) {
|
||||
@ -130,7 +135,7 @@ class BeSimpleSoapExtension extends Extension
|
||||
|
||||
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);
|
||||
|
||||
if (!empty($classmap)) {
|
||||
@ -144,10 +149,17 @@ class BeSimpleSoapExtension extends Extension
|
||||
|
||||
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);
|
||||
|
||||
$definition->setFactoryService(sprintf('besimple.soap.client.builder.%s', $client));
|
||||
if (3 === Kernel::MAJOR_VERSION) {
|
||||
$definition->setFactory(array(
|
||||
new Reference(sprintf('besimple.soap.client.builder.%s', $client)),
|
||||
'build'
|
||||
));
|
||||
} else {
|
||||
$definition->setFactoryService(sprintf('besimple.soap.client.builder.%s', $client));
|
||||
}
|
||||
}
|
||||
|
||||
private function createWebServiceContext(array $config, ContainerBuilder $container)
|
||||
@ -156,7 +168,7 @@ class BeSimpleSoapExtension extends Extension
|
||||
unset($config['binding']);
|
||||
|
||||
$contextId = 'besimple.soap.context.'.$config['name'];
|
||||
$definition = new DefinitionDecorator('besimple.soap.context.'.$bindingSuffix);
|
||||
$definition = new ChildDefinition('besimple.soap.context.'.$bindingSuffix);
|
||||
$container->setDefinition($contextId, $definition);
|
||||
|
||||
if (isset($config['cache_type'])) {
|
||||
@ -165,6 +177,7 @@ class BeSimpleSoapExtension extends Extension
|
||||
|
||||
$options = $container
|
||||
->getDefinition('besimple.soap.context.'.$bindingSuffix)
|
||||
->setPublic(true)
|
||||
->getArgument(2);
|
||||
|
||||
$definition->replaceArgument(2, array_merge($options, $config));
|
||||
|
@ -13,8 +13,8 @@
|
||||
namespace BeSimple\SoapBundle\Handler;
|
||||
|
||||
use BeSimple\SoapServer\Exception\ReceiverSoapFault;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\FlattenException;
|
||||
|
||||
/**
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
|
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>
|
@ -1,18 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<routes xmlns="http://symfony.com/schema/routing"
|
||||
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">
|
||||
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">
|
||||
|
||||
<route id="_webservice_call" pattern="/{webservice}">
|
||||
<route id="_webservice_call" path="/{webservice}" methods="POST">
|
||||
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default>
|
||||
<default key="_format">xml</default>
|
||||
<requirement key="_method">POST</requirement>
|
||||
</route>
|
||||
|
||||
<route id="_webservice_definition" pattern="/{webservice}">
|
||||
<route id="_webservice_definition" path="/{webservice}" methods="GET">
|
||||
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default>
|
||||
<default key="_format">xml</default>
|
||||
<requirement key="_method">GET</requirement>
|
||||
</route>
|
||||
</routes>
|
||||
|
@ -19,7 +19,7 @@
|
||||
</parameters>
|
||||
|
||||
<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%">
|
||||
<tag name="kernel.event_listener" event="kernel.view" method="onKernelView" />
|
||||
@ -96,6 +96,14 @@
|
||||
<argument>dateTime</argument>
|
||||
<argument>xsd:dateTime</argument>
|
||||
</call>
|
||||
<call method="addType">
|
||||
<argument>base64Binary</argument>
|
||||
<argument>xsd:base64Binary</argument>
|
||||
</call>
|
||||
<call method="addType">
|
||||
<argument>hexBinary</argument>
|
||||
<argument>xsd:hexBinary</argument>
|
||||
</call>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
|
@ -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;
|
||||
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Method;
|
||||
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
|
||||
|
||||
/**
|
||||
* @author Christian Kerl <christian-kerl@web.de>
|
||||
*/
|
||||
class DocumentLiteralWrappedRequestMessageBinder implements MessageBinderInterface
|
||||
{
|
||||
public function processMessage(Method $messageDefinition, $message)
|
||||
public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository)
|
||||
{
|
||||
if(count($message) > 1) {
|
||||
throw new \InvalidArgumentException();
|
||||
@ -26,10 +27,10 @@ class DocumentLiteralWrappedRequestMessageBinder implements MessageBinderInterfa
|
||||
$result = array();
|
||||
$message = $message[0];
|
||||
|
||||
foreach($messageDefinition->getArguments() as $argument) {
|
||||
$result[$argument->getName()] = $message->{$argument->getName()};
|
||||
foreach($messageDefinition->getInput()->all() as $argument) {
|
||||
$result[$argument->getName()] = $message;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,17 +11,15 @@
|
||||
namespace BeSimple\SoapBundle\ServiceBinding;
|
||||
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Method;
|
||||
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
|
||||
|
||||
/**
|
||||
* @author Christian Kerl <christian-kerl@web.de>
|
||||
*/
|
||||
class DocumentLiteralWrappedResponseMessageBinder implements MessageBinderInterface
|
||||
{
|
||||
public function processMessage(Method $messageDefinition, $message)
|
||||
public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository)
|
||||
{
|
||||
$result = new \stdClass();
|
||||
$result->{$messageDefinition->getName().'Result'} = $message;
|
||||
|
||||
return $result;
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -55,7 +55,8 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
|
||||
$isArray = true;
|
||||
$array = array();
|
||||
|
||||
$type = $this->typeRepository->getType($type->get('item')->getType());
|
||||
$phpType = substr($type->getPhpType(), 0, strlen($type->getPhpType()) - 2);
|
||||
$type = $this->typeRepository->getType($phpType);
|
||||
}
|
||||
|
||||
// @TODO Fix array reference
|
||||
@ -78,6 +79,21 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
|
||||
$array = $assocArray;
|
||||
}
|
||||
}
|
||||
if (is_array($message)) {
|
||||
foreach ($message as $complexType) {
|
||||
$array[] = $this->checkComplexType($phpType, $complexType);
|
||||
}
|
||||
|
||||
// See https://github.com/BeSimple/BeSimpleSoapBundle/issues/29
|
||||
if (in_array('BeSimple\SoapCommon\Type\AbstractKeyValue', class_parents($phpType))) {
|
||||
$assocArray = array();
|
||||
foreach ($array as $keyValue) {
|
||||
$assocArray[$keyValue->getKey()] = $keyValue->getValue();
|
||||
}
|
||||
|
||||
$array = $assocArray;
|
||||
}
|
||||
}
|
||||
|
||||
$message = $array;
|
||||
} else {
|
||||
|
@ -32,7 +32,10 @@ class RpcLiteralResponseMessageBinder implements MessageBinderInterface
|
||||
{
|
||||
$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)
|
||||
|
@ -18,6 +18,7 @@ class ComplexType extends Configuration
|
||||
private $name;
|
||||
private $value;
|
||||
private $isNillable = false;
|
||||
private $isAttribute = false;
|
||||
|
||||
public function getName()
|
||||
{
|
||||
@ -34,6 +35,11 @@ class ComplexType extends Configuration
|
||||
return $this->isNillable;
|
||||
}
|
||||
|
||||
public function getIsNillable()
|
||||
{
|
||||
return $this->isNillable;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
@ -49,8 +55,33 @@ class ComplexType extends Configuration
|
||||
$this->isNillable = (bool) $isNillable;
|
||||
}
|
||||
|
||||
public function setIsNillable($isNillable)
|
||||
{
|
||||
$this->isNillable = (bool) $isNillable;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isAttribute()
|
||||
{
|
||||
return $this->isAttribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $isAttribute
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsAttribute($isAttribute)
|
||||
{
|
||||
$this->isAttribute = $isAttribute;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAliasName()
|
||||
{
|
||||
return 'complextype';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ class ComplexType
|
||||
private $name;
|
||||
private $value;
|
||||
private $isNillable = false;
|
||||
private $isAttribute = false;
|
||||
|
||||
public function getName()
|
||||
{
|
||||
@ -46,6 +47,26 @@ class ComplexType
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isAttribute()
|
||||
{
|
||||
return $this->isAttribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $isAttribute
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setIsAttribute($isAttribute)
|
||||
{
|
||||
$this->isAttribute = $isAttribute;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setNillable($isNillable)
|
||||
{
|
||||
$this->isNillable = (bool) $isNillable;
|
||||
|
@ -96,6 +96,7 @@ class AnnotationClassLoader extends Loader
|
||||
}
|
||||
|
||||
$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()));
|
||||
}
|
||||
|
||||
$serviceMethod->setOutput($this->loadType($serviceReturn));
|
||||
if (!isset($serviceXmlReturn) || !$serviceXmlReturn) {
|
||||
$serviceXmlReturn = 'return';
|
||||
}
|
||||
|
||||
$serviceMethod->setOutput($this->loadType($serviceReturn), $serviceXmlReturn);
|
||||
|
||||
$definition->addMethod($serviceMethod);
|
||||
}
|
||||
@ -155,7 +160,7 @@ class AnnotationClassLoader extends Loader
|
||||
$loaded = $complexTypeResolver->load($phpType);
|
||||
$complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType);
|
||||
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->isAttribute());
|
||||
}
|
||||
|
||||
$this->typeRepository->addComplexType($complexType);
|
||||
|
@ -58,6 +58,7 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
|
||||
$propertyComplexType = new ComplexType();
|
||||
$propertyComplexType->setValue($complexType->getValue());
|
||||
$propertyComplexType->setNillable($complexType->isNillable());
|
||||
$propertyComplexType->setIsAttribute($complexType->isAttribute());
|
||||
$propertyComplexType->setName($property->getName());
|
||||
$annotations['properties']->add($propertyComplexType);
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ namespace BeSimple\SoapBundle\Util;
|
||||
*
|
||||
* @author Christian Kerl <christian-kerl@web.de>
|
||||
*/
|
||||
class String
|
||||
class BsString
|
||||
{
|
||||
/**
|
||||
* Checks if a string starts with a given string.
|
@ -44,7 +44,7 @@ class WebServiceContext
|
||||
if (null === $this->serviceDefinition) {
|
||||
$cache = new ConfigCache(sprintf('%s/%s.definition.php', $this->options['cache_dir'], $this->options['name']), $this->options['debug']);
|
||||
if ($cache->isFresh()) {
|
||||
$this->serviceDefinition = include (string) $cache;
|
||||
$this->serviceDefinition = include $cache->getPath();
|
||||
} else {
|
||||
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']));
|
||||
@ -79,10 +79,13 @@ class WebServiceContext
|
||||
}
|
||||
|
||||
$dumper = new Dumper($definition, array('stylesheet' => $this->options['wsdl_stylesheet']));
|
||||
$cache->write($dumper->dump());
|
||||
|
||||
$wsdl = $dumper->dump();
|
||||
|
||||
$cache->write($wsdl);
|
||||
}
|
||||
|
||||
return (string) $cache;
|
||||
return $cache->getPath();
|
||||
}
|
||||
|
||||
public function getServiceBinder()
|
||||
|
@ -25,8 +25,8 @@
|
||||
"besimple/soap-common": "0.2.*",
|
||||
"besimple/soap-wsdl": "0.2.*",
|
||||
"ass/xmlsecurity": "~1.0",
|
||||
"symfony/framework-bundle": "~2.0",
|
||||
"symfony/twig-bundle": "~2.0",
|
||||
"symfony/framework-bundle": "~2.0|~3.0",
|
||||
"symfony/twig-bundle": "~2.0|~3.0",
|
||||
"zendframework/zend-mime": "2.1.*"
|
||||
},
|
||||
"suggest": {
|
||||
|
@ -24,7 +24,6 @@ abstract class AbstractWebServerTest extends \PHPUnit_Framework_TestCase
|
||||
* @var ProcessBuilder
|
||||
*/
|
||||
static protected $webserver;
|
||||
static protected $websererPortLength;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
@ -44,8 +43,6 @@ abstract class AbstractWebServerTest extends \PHPUnit_Framework_TestCase
|
||||
|
||||
self::$webserver->start();
|
||||
usleep(100000);
|
||||
|
||||
self::$websererPortLength = strlen(WEBSERVER_PORT);
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
|
@ -45,19 +45,6 @@ class CurlTest extends AbstractWebserverTest
|
||||
$this->assertEquals('Unable to parse URL', $curl->getErrorMessage());
|
||||
}
|
||||
|
||||
public function testGetRequestHeaders()
|
||||
{
|
||||
$curl = new Curl(array(
|
||||
'proxy_host' => false,
|
||||
));
|
||||
|
||||
$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()
|
||||
{
|
||||
$curl = new Curl(array(
|
||||
@ -66,7 +53,6 @@ class CurlTest extends AbstractWebserverTest
|
||||
|
||||
$curl->exec(sprintf('http://localhost:%d/curl.txt', WEBSERVER_PORT));
|
||||
$this->assertSame('OK', $curl->getResponseStatusMessage());
|
||||
$this->assertEquals(145 + self::$websererPortLength, strlen($curl->getResponse()));
|
||||
|
||||
$curl->exec(sprintf('http://localhost:%d/404.txt', WEBSERVER_PORT));
|
||||
$this->assertSame('Not Found', $curl->getResponseStatusMessage());
|
||||
@ -95,19 +81,6 @@ class CurlTest extends AbstractWebserverTest
|
||||
$this->assertEquals('text/html; charset=UTF-8', $curl->getResponseContentType());
|
||||
}
|
||||
|
||||
public function testGetResponseHeaders()
|
||||
{
|
||||
$curl = new Curl(array(
|
||||
'proxy_host' => false,
|
||||
));
|
||||
|
||||
$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()
|
||||
{
|
||||
$curl = new Curl(array(
|
||||
|
@ -48,13 +48,13 @@ class Message
|
||||
return 0 === count($this->parts) ? true : false;
|
||||
}
|
||||
|
||||
public function add($name, $phpType, $nillable = false)
|
||||
public function add($name, $phpType, $nillable = false, $attribute = false)
|
||||
{
|
||||
if ($phpType instanceof TypeInterface) {
|
||||
$phpType = $phpType->getPhpType();
|
||||
}
|
||||
|
||||
$this->parts[$name] = new Part($name, $phpType, $nillable);
|
||||
$this->parts[$name] = new Part($name, $phpType, $nillable, $attribute);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ class Method
|
||||
|
||||
public function getUse()
|
||||
{
|
||||
return \SOAP_LITERAL;
|
||||
return \SOAP_ENCODED;
|
||||
}
|
||||
|
||||
public function addHeader($name, $type)
|
||||
@ -66,9 +66,13 @@ class Method
|
||||
$this->input->add($name, $type);
|
||||
}
|
||||
|
||||
public function setOutput($type)
|
||||
public function setOutput($type, $name = 'return')
|
||||
{
|
||||
$this->output->add('return', $type);
|
||||
if ('return' !== $name) {
|
||||
$this->output = new Message($name);
|
||||
}
|
||||
|
||||
$this->output->add($name, $type);
|
||||
}
|
||||
|
||||
public function getHeaders()
|
||||
|
@ -20,12 +20,14 @@ class Part
|
||||
protected $name;
|
||||
protected $type;
|
||||
protected $nillable;
|
||||
protected $attribute;
|
||||
|
||||
public function __construct($name, $type, $nillable = false)
|
||||
public function __construct($name, $type, $nillable = false, $attribute = false)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->type = $type;
|
||||
$this->setNillable($nillable);
|
||||
$this->setAttribute($attribute);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
@ -33,6 +35,26 @@ class Part
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isAttribute()
|
||||
{
|
||||
return $this->attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $attribute
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setAttribute($attribute)
|
||||
{
|
||||
$this->attribute = $attribute;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
|
@ -5,7 +5,7 @@ namespace BeSimple\SoapCommon\Type\KeyValue;
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||
use BeSimple\SoapCommon\Type\AbstractKeyValue;
|
||||
|
||||
class Boolean extends AbstractKeyValue
|
||||
class BsBoolean extends AbstractKeyValue
|
||||
{
|
||||
/**
|
||||
* @Soap\ComplexType("boolean")
|
@ -5,7 +5,7 @@ namespace BeSimple\SoapCommon\Type\KeyValue;
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||
use BeSimple\SoapCommon\Type\AbstractKeyValue;
|
||||
|
||||
class Float extends AbstractKeyValue
|
||||
class BsFloat extends AbstractKeyValue
|
||||
{
|
||||
/**
|
||||
* @Soap\ComplexType("float")
|
@ -5,7 +5,7 @@ namespace BeSimple\SoapCommon\Type\KeyValue;
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||
use BeSimple\SoapCommon\Type\AbstractKeyValue;
|
||||
|
||||
class Int extends AbstractKeyValue
|
||||
class BsInt extends AbstractKeyValue
|
||||
{
|
||||
/**
|
||||
* @Soap\ComplexType("int")
|
@ -5,7 +5,7 @@ namespace BeSimple\SoapCommon\Type\KeyValue;
|
||||
use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;
|
||||
use BeSimple\SoapCommon\Type\AbstractKeyValue;
|
||||
|
||||
class String extends AbstractKeyValue
|
||||
class BsString extends AbstractKeyValue
|
||||
{
|
||||
/**
|
||||
* @Soap\ComplexType("string")
|
@ -30,7 +30,7 @@ abstract class WsSecurityFilterClientServer
|
||||
/**
|
||||
* 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
|
||||
|
@ -25,8 +25,7 @@
|
||||
"ass/xmlsecurity": "~1.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-mcrypt": "*",
|
||||
"mikey179/vfsStream": "~1.0"
|
||||
"mikey179/vfsstream": "~1.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "BeSimple\\SoapCommon": "" }
|
||||
|
@ -100,6 +100,34 @@ class SoapServer extends \SoapServer
|
||||
parent::handle($soapRequest->getContent());
|
||||
$response = ob_get_clean();
|
||||
|
||||
$dom = \DOMDocument::loadXML($response);
|
||||
|
||||
/** @var \DOMElement $envelop */
|
||||
$envelop = $dom->childNodes->item(0);
|
||||
$ns1 = $envelop->getAttribute('xmlns:ns1');
|
||||
$envelop->removeAttributeNS($ns1, 'ns1');
|
||||
$envelop->prefix = 'soap';
|
||||
|
||||
$envelop->setAttribute('soap:encodingStyle', 'http://schemas.xmlsoap.org/soap/encoding/');
|
||||
$envelop->setAttribute('xmlns:soapenc', 'http://schemas.xmlsoap.org/soap/encoding/');
|
||||
$envelop->setAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
|
||||
$envelop->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
||||
|
||||
/** @var \DOMElement $body */
|
||||
$body = $envelop->childNodes->item(0);
|
||||
$body->prefix = 'soap';
|
||||
|
||||
/** @var \DOMElement $responseRoot */
|
||||
$responseRoot = $body->childNodes->item(0);
|
||||
$responseRoot->setAttribute('xmlns', $ns1);
|
||||
|
||||
$envelop->removeAttributeNS('http://schemas.xmlsoap.org/soap/envelope/', 'SOAP-ENV');
|
||||
$envelop->removeAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'SOAP-ENC');
|
||||
|
||||
$response = $dom->saveXML();
|
||||
|
||||
$response = preg_replace('/xsi:type="ns1:\w*"/', '', $response);
|
||||
|
||||
// Remove headers added by SoapServer::handle() method
|
||||
header_remove('Content-Length');
|
||||
header_remove('Content-Type');
|
||||
|
@ -86,7 +86,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
|
||||
$expires = $xpath->query($query, $security)->item(0);
|
||||
|
||||
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'));
|
||||
|
||||
if ($currentDatetime > $expiresDatetime) {
|
||||
@ -170,7 +170,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
|
||||
|
||||
// init timestamp
|
||||
$dt = new \DateTime('now', new \DateTimeZone('UTC'));
|
||||
$createdTimestamp = $dt->format(self::DATETIME_FORMAT);
|
||||
$createdTimestamp = $dt->format(static::DATETIME_FORMAT);
|
||||
|
||||
// create security header
|
||||
$security = $filterHelper->createElement(Helper::NS_WSS, 'Security');
|
||||
@ -182,7 +182,7 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
|
||||
$timestamp->appendChild($created);
|
||||
if (null !== $this->expires) {
|
||||
$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);
|
||||
$timestamp->appendChild($expires);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ abstract class AbstractVersion implements VersionInterface
|
||||
{
|
||||
if (!$this->bindingNode) {
|
||||
$this->bindingNode = $this->document->createElement('binding');
|
||||
$this->bindingNode->setAttribute('name', $this->name.'Binding');
|
||||
$this->bindingNode->setAttribute('name', $this->name.'_SOAP');
|
||||
$this->bindingNode->setAttribute('type', $this->portTypeName);
|
||||
|
||||
$this->addSoapBinding();
|
||||
@ -75,7 +75,7 @@ abstract class AbstractVersion implements VersionInterface
|
||||
if (!$this->servicePortNode) {
|
||||
$this->servicePortNode = $this->document->createElement('port');
|
||||
$this->servicePortNode->setAttribute('name', $this->name.'Port');
|
||||
$this->servicePortNode->setAttribute('binding', $this->typeNs.':'.$this->name.'Binding');
|
||||
$this->servicePortNode->setAttribute('binding', $this->typeNs.':'.$this->name.'_SOAP');
|
||||
|
||||
$this->addSoapAddress();
|
||||
}
|
||||
|
@ -203,9 +203,9 @@ class Dumper
|
||||
$partElement->setAttribute('name', $part->getName());
|
||||
|
||||
if ($type instanceof ComplexType) {
|
||||
$partElement->setAttribute('type', static::TYPES_NS.':'.$type->getXmlType());
|
||||
$partElement->setAttribute('element', static::TYPES_NS.':'.$type->getXmlType());
|
||||
} else {
|
||||
$partElement->setAttribute('type', $type);
|
||||
$partElement->setAttribute('element', $type);
|
||||
}
|
||||
|
||||
$messageElement->appendChild($partElement);
|
||||
@ -217,11 +217,13 @@ class Dumper
|
||||
|
||||
protected function addComplexTypes()
|
||||
{
|
||||
$types = $this->document->createElement('types');
|
||||
$types = $this->document->createElement(static::WSDL_NS . ':types');
|
||||
$this->domDefinitions->appendChild($types);
|
||||
|
||||
$this->domSchema = $this->document->createElement(static::XSD_NS.':schema');
|
||||
$this->domSchema->setAttribute('targetNamespace', $this->definition->getNamespace());
|
||||
$this->domSchema->setAttribute('elementFormDefault', 'unqualified');
|
||||
$this->domSchema->setAttribute(static::XML_NS.':'.static::XSD_NS, static::XSD_NS_URI);
|
||||
$types->appendChild($this->domSchema);
|
||||
|
||||
foreach ($this->definition->getTypeRepository()->getComplexTypes() as $type) {
|
||||
@ -236,13 +238,18 @@ class Dumper
|
||||
$complexType = $this->document->createElement(static::XSD_NS.':complexType');
|
||||
$complexType->setAttribute('name', $type->getXmlType());
|
||||
|
||||
$all = $this->document->createElement(static::XSD_NS.':'.($type instanceof ArrayOfType ? 'sequence' : 'all'));
|
||||
$all = $this->document->createElement(static::XSD_NS.':'.'sequence');
|
||||
$complexType->appendChild($all);
|
||||
|
||||
foreach ($type->all() as $child) {
|
||||
$isArray = false;
|
||||
$childType = $this->definition->getTypeRepository()->getType($child->getType());
|
||||
|
||||
$element = $this->document->createElement(static::XSD_NS.':element');
|
||||
if ($child->isAttribute()) {
|
||||
$element = $this->document->createElement(static::XSD_NS.':attribute');
|
||||
} else {
|
||||
$element = $this->document->createElement(static::XSD_NS.':element');
|
||||
}
|
||||
$element->setAttribute('name', $child->getName());
|
||||
|
||||
if ($childType instanceof ComplexType) {
|
||||
@ -257,15 +264,23 @@ class Dumper
|
||||
}
|
||||
|
||||
if ($child->isNillable()) {
|
||||
$element->setAttribute('nillable', 'true');
|
||||
$element->setAttribute('minOccurs', 0);
|
||||
} else {
|
||||
$element->setAttribute('minOccurs', 1);
|
||||
}
|
||||
|
||||
if ($type instanceof ArrayOfType) {
|
||||
if ($type instanceof ArrayOfType || $isArray) {
|
||||
$element->setAttribute('minOccurs', 0);
|
||||
$element->setAttribute('maxOccurs', 'unbounded');
|
||||
} else {
|
||||
$element->setAttribute('maxOccurs', 1);
|
||||
}
|
||||
|
||||
$all->appendChild($element);
|
||||
if ($child->isAttribute()) {
|
||||
$complexType->appendChild($element);
|
||||
} else {
|
||||
$all->appendChild($element);
|
||||
}
|
||||
}
|
||||
|
||||
$this->domSchema->appendChild($complexType);
|
||||
|
Reference in New Issue
Block a user