Test With Legacy bundle
This commit is contained in:
parent
9312e4af6a
commit
ae746087e6
|
@ -13,45 +13,27 @@
|
|||
namespace BeSimple\SoapBundle;
|
||||
|
||||
use BeSimple\SoapCommon\Cache as BaseCache;
|
||||
use BeSimple\SoapCommon\SoapOptions\SoapOptions;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
*/
|
||||
class Cache
|
||||
{
|
||||
public function __construct(SoapOptions $soapOptions)
|
||||
public function __construct($cacheDisabled, $type, $directory, $lifetime = null, $limit = null)
|
||||
{
|
||||
if ($soapOptions->isWsdlCached()) {
|
||||
$isEnabled = (bool)$soapOptions->isWsdlCached() ? BaseCache::ENABLED : BaseCache::DISABLED;
|
||||
$isEnabled = (Boolean) $cacheDisabled ? BaseCache::DISABLED : BaseCache::ENABLED;
|
||||
|
||||
BaseCache::setEnabled($isEnabled);
|
||||
BaseCache::setType($soapOptions->getWsdlCacheType());
|
||||
BaseCache::setDirectory($soapOptions->getWsdlCacheDir());
|
||||
} else {
|
||||
BaseCache::setEnabled(BaseCache::DISABLED);
|
||||
BaseCache::setType(SoapOptions::SOAP_CACHE_TYPE_NONE);
|
||||
BaseCache::setDirectory(null);
|
||||
BaseCache::setEnabled($isEnabled);
|
||||
|
||||
BaseCache::setType($type);
|
||||
BaseCache::setDirectory($directory);
|
||||
|
||||
if (null !== $lifetime) {
|
||||
BaseCache::setLifetime($lifetime);
|
||||
}
|
||||
}
|
||||
|
||||
public function validateSettings(SoapOptions $soapOptions)
|
||||
{
|
||||
if ($soapOptions->isWsdlCached()) {
|
||||
if (BaseCache::isEnabled() !== true) {
|
||||
throw new Exception('WSDL cache could not be set');
|
||||
}
|
||||
if ($soapOptions->getWsdlCacheType() !== (int)BaseCache::getType()) {
|
||||
throw new Exception('WSDL cache type could not be set, ini settings is: '.BaseCache::getType());
|
||||
}
|
||||
if ($soapOptions->getWsdlCacheDir() !== BaseCache::getDirectory()) {
|
||||
throw new Exception('WSDL cache dir could not be set, real dir is: '.BaseCache::getDirectory());
|
||||
}
|
||||
} else {
|
||||
if (BaseCache::isEnabled() !== false) {
|
||||
throw new Exception('WSDL cache could not be turned off');
|
||||
}
|
||||
if (null !== $limit) {
|
||||
BaseCache::setLimit($limit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,10 @@ use BeSimple\SoapBundle\Handler\ExceptionHandler;
|
|||
use BeSimple\SoapBundle\Soap\SoapRequest;
|
||||
use BeSimple\SoapBundle\Soap\SoapResponse;
|
||||
use BeSimple\SoapServer\SoapServerBuilder;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\FlattenException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Symfony\Component\HttpKernel\HttpKernelInterface;
|
||||
use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
||||
|
@ -29,10 +28,8 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface;
|
|||
* @author Christian Kerl <christian-kerl@web.de>
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
*/
|
||||
class SoapWebServiceController implements ContainerAwareInterface
|
||||
class SoapWebServiceController extends ContainerAware
|
||||
{
|
||||
use ContainerAwareTrait;
|
||||
|
||||
/**
|
||||
* @var \SoapServer
|
||||
*/
|
||||
|
@ -67,7 +64,7 @@ class SoapWebServiceController implements ContainerAwareInterface
|
|||
|
||||
$this->serviceBinder = $webServiceContext->getServiceBinder();
|
||||
|
||||
$this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request_stack')->getCurrentRequest());
|
||||
$this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request'));
|
||||
$this->soapServer = $webServiceContext
|
||||
->getServerBuilder()
|
||||
->withSoapVersion11()
|
||||
|
@ -141,8 +138,8 @@ class SoapWebServiceController implements ContainerAwareInterface
|
|||
$request->query->remove('_besimple_soap_fault');
|
||||
}
|
||||
|
||||
$server = SoapServerBuilder::createWithDefaults(__DIR__.'/../Handler/wsdl/exception.wsdl')
|
||||
->withWsdl()
|
||||
$server = SoapServerBuilder::createWithDefaults()
|
||||
->withWsdl(__DIR__.'/../Handler/wsdl/exception.wsdl')
|
||||
->withWsdlCacheNone()
|
||||
->withHandler($handler)
|
||||
->build()
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace BeSimple\SoapBundle\Converter;
|
|||
|
||||
use BeSimple\SoapBundle\Soap\SoapRequest;
|
||||
use BeSimple\SoapBundle\Soap\SoapResponse;
|
||||
use BeSimple\SoapBundle\Util\StringUtility;
|
||||
use BeSimple\SoapBundle\Util\String;
|
||||
use BeSimple\SoapCommon\Converter\TypeConverterInterface;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +40,7 @@ class XopIncludeTypeConverter implements TypeConverterInterface
|
|||
|
||||
$ref = $include->getAttribute('href');
|
||||
|
||||
if (StringUtility::startsWith($ref, 'cid:')) {
|
||||
if (String::startsWith($ref, 'cid:')) {
|
||||
$cid = urldecode(substr($ref, 4));
|
||||
|
||||
return $request->getSoapAttachments()->get($cid)->getContent();
|
||||
|
|
|
@ -14,8 +14,6 @@ namespace BeSimple\SoapBundle\DependencyInjection;
|
|||
|
||||
use BeSimple\SoapCommon\Cache;
|
||||
|
||||
use BeSimple\SoapCommon\SoapOptions\SoapOptions;
|
||||
use Carpages\Core\Entity\ContactPhone;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
@ -43,7 +41,6 @@ class BeSimpleSoapExtension extends Extension
|
|||
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
|
||||
|
||||
$loader->load('request.xml');
|
||||
$loader->load('soap.xml');
|
||||
|
||||
$loader->load('loaders.xml');
|
||||
$loader->load('converters.xml');
|
||||
|
@ -56,8 +53,8 @@ class BeSimpleSoapExtension extends Extension
|
|||
|
||||
$this->registerCacheConfiguration($config['cache'], $container, $loader);
|
||||
|
||||
if ( ! empty($config['clients'])) {
|
||||
$this->registerClientConfiguration($config, $container, $loader);
|
||||
if (!empty($config['clients'])) {
|
||||
$this->registerClientConfiguration($config['clients'], $container, $loader);
|
||||
}
|
||||
|
||||
$container->setParameter('besimple.soap.definition.dumper.options.stylesheet', $config['wsdl_dumper']['stylesheet']);
|
||||
|
@ -72,9 +69,11 @@ class BeSimpleSoapExtension extends Extension
|
|||
|
||||
private function registerCacheConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
||||
{
|
||||
$loader->load('soap.xml');
|
||||
|
||||
$config['type'] = $this->getCacheType($config['type']);
|
||||
|
||||
foreach (array('type', 'file') as $key) {
|
||||
foreach (array('type', 'lifetime', 'limit') as $key) {
|
||||
$container->setParameter('besimple.soap.cache.'.$key, $config[$key]);
|
||||
}
|
||||
}
|
||||
|
@ -83,33 +82,22 @@ class BeSimpleSoapExtension extends Extension
|
|||
{
|
||||
$loader->load('client.xml');
|
||||
|
||||
foreach ($config['clients'] as $client => $options) {
|
||||
$soapClientOpts = new DefinitionDecorator('besimple.soap.client_options');
|
||||
$soapOpts = new DefinitionDecorator('besimple.soap.options');
|
||||
foreach ($config as $client => $options) {
|
||||
$definition = new DefinitionDecorator('besimple.soap.client.builder');
|
||||
$container->setDefinition(sprintf('besimple.soap.client.builder.%s', $client), $definition);
|
||||
|
||||
$soapClientOptsService = sprintf('besimple.soap.client_options.%s', $client);
|
||||
$soapOptsService = sprintf('besimple.soap.options.%s', $client);
|
||||
$definition->replaceArgument(0, $options['wsdl']);
|
||||
|
||||
// configure SoapClient
|
||||
$definition = new DefinitionDecorator('besimple.soap.client');
|
||||
$defOptions = $container
|
||||
->getDefinition('besimple.soap.client.builder')
|
||||
->getArgument(1);
|
||||
|
||||
$container->setDefinition(
|
||||
sprintf('besimple.soap.client.%s', $client),
|
||||
$definition
|
||||
);
|
||||
$container->setDefinition(
|
||||
$soapClientOptsService,
|
||||
$soapClientOpts
|
||||
);
|
||||
$container->setDefinition(
|
||||
$soapOptsService,
|
||||
$soapOpts
|
||||
);
|
||||
foreach (array('cache_type', 'user_agent') as $key) {
|
||||
if (isset($options[$key])) {
|
||||
$defOptions[$key] = $options[$key];
|
||||
}
|
||||
}
|
||||
|
||||
$definition->replaceArgument(0, new Reference($soapClientOptsService));
|
||||
$definition->replaceArgument(1, new Reference($soapOptsService));
|
||||
|
||||
// configure proxy
|
||||
$proxy = $options['proxy'];
|
||||
if (false !== $proxy['host']) {
|
||||
if (null !== $proxy['auth']) {
|
||||
|
@ -120,58 +108,49 @@ class BeSimpleSoapExtension extends Extension
|
|||
}
|
||||
}
|
||||
|
||||
$proxy = $this->createClientProxy($client, $proxy, $container);
|
||||
$soapClientOpts->setFactory([
|
||||
'%besimple.soap.client_options_builder.class%',
|
||||
'createWithProxy'
|
||||
]);
|
||||
$soapClientOpts->setArgument(0, new Reference($proxy));
|
||||
$definition->addMethodCall('withProxy', array(
|
||||
$proxy['host'], $proxy['port'],
|
||||
$proxy['login'], $proxy['password'],
|
||||
$proxy['auth']
|
||||
));
|
||||
}
|
||||
|
||||
// configure SoapOptions for client
|
||||
$classMap = $this->createClientClassMap($client, $options['classmap'], $container);
|
||||
|
||||
$soapOpts->replaceArgument(0, $config['cache']['file']);
|
||||
$soapOpts->replaceArgument(1, new Reference($classMap));
|
||||
$soapOpts->replaceArgument(2, $this->getCacheType($config['cache']['type']));
|
||||
|
||||
if ($config['cache']['version'] == SoapOptions::SOAP_VERSION_1_1) {
|
||||
$soapOpts->setFactory([
|
||||
'%besimple.soap.options_builder.class%',
|
||||
'createWithClassMapV11'
|
||||
]);
|
||||
if (isset($defOptions['cache_type'])) {
|
||||
$defOptions['cache_type'] = $this->getCacheType($defOptions['cache_type']);
|
||||
}
|
||||
|
||||
$definition->replaceArgument(1, $defOptions);
|
||||
|
||||
$classmap = $this->createClientClassmap($client, $options['classmap'], $container);
|
||||
$definition->replaceArgument(2, new Reference($classmap));
|
||||
|
||||
$this->createClient($client, $container);
|
||||
}
|
||||
}
|
||||
|
||||
private function createClientClassMap($client, array $classmap, ContainerBuilder $container)
|
||||
private function createClientClassmap($client, array $classmap, ContainerBuilder $container)
|
||||
{
|
||||
$definition = new DefinitionDecorator('besimple.soap.classmap');
|
||||
$container->setDefinition(sprintf('besimple.soap.classmap.%s', $client), $definition);
|
||||
|
||||
if ( ! empty($classmap)) {
|
||||
if (!empty($classmap)) {
|
||||
$definition->setMethodCalls(array(
|
||||
array('__construct', array($classmap)),
|
||||
array('set', array($classmap)),
|
||||
));
|
||||
}
|
||||
|
||||
return sprintf('besimple.soap.classmap.%s', $client);
|
||||
}
|
||||
|
||||
private function createClientProxy($client, array $proxy, ContainerBuilder $container)
|
||||
private function createClient($client, ContainerBuilder $container)
|
||||
{
|
||||
$definition = new DefinitionDecorator('besimple.soap.client.proxy');
|
||||
$container->setDefinition(sprintf('besimple.soap.client.proxy.%s', $client), $definition);
|
||||
$definition = new DefinitionDecorator('besimple.soap.client');
|
||||
$container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition);
|
||||
|
||||
if ( ! empty($proxy)) {
|
||||
$definition->replaceArgument(0, $proxy['host']);
|
||||
$definition->replaceArgument(1, $proxy['port']);
|
||||
$definition->replaceArgument(2, $proxy['login']);
|
||||
$definition->replaceArgument(3, $proxy['password']);
|
||||
$definition->replaceArgument(4, $proxy['auth']);
|
||||
}
|
||||
|
||||
return sprintf('besimple.soap.client.proxy.%s', $client);
|
||||
$definition->setFactory(array(
|
||||
new Reference(sprintf('besimple.soap.client.builder.%s', $client)),
|
||||
'build'
|
||||
));
|
||||
}
|
||||
|
||||
private function createWebServiceContext(array $config, ContainerBuilder $container)
|
||||
|
|
|
@ -64,10 +64,6 @@ class Configuration
|
|||
->thenInvalid(sprintf('The cache type has to be either %s', implode(', ', $this->cacheTypes)))
|
||||
->end()
|
||||
->end()
|
||||
->scalarNode('version')->defaultNull()->end()
|
||||
->scalarNode('encoding')->defaultNull()->end()
|
||||
->scalarNode('keepalive')->defaultNull()->end()
|
||||
->scalarNode('file')->defaultNull()->end()
|
||||
->scalarNode('lifetime')->defaultNull()->end()
|
||||
->scalarNode('limit')->defaultNull()->end()
|
||||
->end()
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
namespace BeSimple\SoapBundle\Handler;
|
||||
|
||||
use SoapFault;
|
||||
use Symfony\Component\Debug\Exception\FlattenException;
|
||||
use BeSimple\SoapServer\Exception\ReceiverSoapFault;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\FlattenException;
|
||||
|
||||
/**
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
|
@ -44,8 +44,7 @@ class ExceptionHandler
|
|||
|
||||
$code = $this->exception->getStatusCode();
|
||||
|
||||
throw new SoapFault(
|
||||
'receiver',
|
||||
throw new ReceiverSoapFault(
|
||||
isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
|
||||
null,
|
||||
$this->details
|
||||
|
|
|
@ -4,26 +4,26 @@
|
|||
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\SoapClient\SoapClientBuilder</parameter>
|
||||
<parameter key="besimple.soap.client.class">BeSimple\SoapClient\SoapClient</parameter>
|
||||
<parameter key="besimple.soap.client.proxy.class">BeSimple\SoapClient\SoapServerProxy\SoapServerProxy</parameter>
|
||||
<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" class="%besimple.soap.client.class%" abstract="true">
|
||||
<factory class="%besimple.soap.client.builder.class%" method="build" />
|
||||
<argument type="service" id="besimple.soap.client_options" />
|
||||
<argument type="service" id="besimple.soap.options" /> <!-- hack to load besimple cache configuration -->
|
||||
<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.proxy" class="%besimple.soap.client.proxy.class%" abstract="true">
|
||||
<argument id="$host" />
|
||||
<argument id="$port" />
|
||||
<argument id="$login" />
|
||||
<argument id="$password" />
|
||||
<argument id="$authenticationType" />
|
||||
<service id="besimple.soap.client" class="%besimple.soap.client.builder.class%" abstract="true">
|
||||
<factory class="besimple.soap.client.builder" method="build" />
|
||||
</service>
|
||||
|
||||
<service id="besimple.soap.classmap" class="%besimple.soap.classmap.class%" abstract="true" />
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
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" path="/{webservice}">
|
||||
<route id="_webservice_call" pattern="/{webservice}">
|
||||
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Call</default>
|
||||
<default key="_format">xml</default>
|
||||
<requirement key="_method">POST</requirement>
|
||||
</route>
|
||||
|
||||
<route id="_webservice_definition" path="/{webservice}">
|
||||
<route id="_webservice_definition" pattern="/{webservice}">
|
||||
<default key="_controller">BeSimpleSoapBundle:SoapWebService:Definition</default>
|
||||
<default key="_format">xml</default>
|
||||
<requirement key="_method">GET</requirement>
|
||||
|
|
|
@ -1,31 +1,20 @@
|
|||
<?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">
|
||||
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.classmap.class">BeSimple\SoapCommon\ClassMap</parameter>
|
||||
<parameter key="besimple.soap.client_options.class">BeSimple\SoapClient\SoapOptions\SoapClientOptions</parameter>
|
||||
<parameter key="besimple.soap.client_options_builder.class">BeSimple\SoapClient\SoapClientOptionsBuilder</parameter>
|
||||
<parameter key="besimple.soap.options.class">BeSimple\SoapCommon\SoapOptions\SoapOptions</parameter>
|
||||
<parameter key="besimple.soap.options_builder.class">BeSimple\SoapCommon\SoapOptionsBuilder</parameter>
|
||||
<parameter key="besimple.soap.cache.dir">%kernel.cache_dir%</parameter>
|
||||
<parameter key="besimple.soap.cache.class">BeSimple\SoapBundle\Cache</parameter>
|
||||
<parameter key="besimple.soap.cache.dir">%kernel.cache_dir%/besimple/soap</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="besimple.soap.client_options" class="%besimple.soap.client_options.class%" abstract="true">
|
||||
<!-- call the static method -->
|
||||
<factory class="%besimple.soap.client_options_builder.class%" method="createWithDefaults" />
|
||||
</service>
|
||||
|
||||
<service id="besimple.soap.classmap" class="%besimple.soap.classmap.class%" abstract="true" />
|
||||
|
||||
<service id="besimple.soap.options" class="%besimple.soap.options.class%" abstract="true">
|
||||
<factory class="%besimple.soap.options_builder.class%" method="createWithClassMap" />
|
||||
<argument>%besimple.soap.cache.file%</argument>
|
||||
<argument type="service" id="besimple.soap.classmap" />
|
||||
<service id="besimple.soap.cache" class="%besimple.soap.cache.class%">
|
||||
<argument>%kernel.debug%</argument>
|
||||
<argument>%besimple.soap.cache.type%</argument>
|
||||
<argument>%besimple.soap.cache.dir%</argument>
|
||||
<argument>%besimple.soap.cache.dir%/cache</argument>
|
||||
<argument>%besimple.soap.cache.lifetime%</argument>
|
||||
<argument>%besimple.soap.cache.limit%</argument>
|
||||
</service>
|
||||
</services>
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<parameter key="besimple.soap.binder.request_header.documentwrapped.class">BeSimple\SoapBundle\ServiceBinding\DocumentLiteralWrappedRequestHeaderMessageBinder</parameter>
|
||||
<parameter key="besimple.soap.binder.response.documentwrapped.class">BeSimple\SoapBundle\ServiceBinding\DocumentLiteralWrappedResponseMessageBinder</parameter>
|
||||
<parameter key="besimple.soap.type.repository.class">BeSimple\SoapCommon\Definition\Type\TypeRepository</parameter>
|
||||
<parameter key="besimple.soap.server.classmap.class">BeSimple\SoapCommon\ClassMap</parameter>
|
||||
<parameter key="besimple.soap.server.classmap.class">BeSimple\SoapServer\Classmap</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
|
|
|
@ -7,7 +7,7 @@ Pre-existent Type
|
|||
+------------------------------------------------+-----------------+
|
||||
| Php Type | Value Type |
|
||||
+================================================+=================+
|
||||
| BeSimple\\SoapCommon\\Type\\KeyValue\\StringUtility | StringUtility |
|
||||
| BeSimple\\SoapCommon\\Type\\KeyValue\\String | String |
|
||||
+------------------------------------------------+-----------------+
|
||||
| BeSimple\\SoapCommon\\Type\\KeyValue\\Boolean | Boolean |
|
||||
+------------------------------------------------+-----------------+
|
||||
|
@ -34,7 +34,7 @@ Controller
|
|||
{
|
||||
/**
|
||||
* @Soap\Method("returnAssocArray")
|
||||
* @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\StringUtility[]")
|
||||
* @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
|
||||
*/
|
||||
public function assocArrayOfStringAction()
|
||||
{
|
||||
|
@ -46,8 +46,8 @@ Controller
|
|||
|
||||
/**
|
||||
* @Soap\Method("sendAssocArray")
|
||||
* @Soap\Param("assocArray", phpType = "BeSimple\SoapCommon\Type\KeyValue\StringUtility[]")
|
||||
* @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\StringUtility[]")
|
||||
* @Soap\Param("assocArray", phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
|
||||
* @Soap\Result(phpType = "BeSimple\SoapCommon\Type\KeyValue\String[]")
|
||||
*/
|
||||
public function sendAssocArrayOfStringAction(array $assocArray)
|
||||
{
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace BeSimple\SoapBundle\Soap;
|
||||
|
||||
class SoapAttachmentList
|
||||
{
|
||||
private $soapAttachments;
|
||||
|
||||
/**
|
||||
* @param SoapAttachment[] $soapAttachments
|
||||
*/
|
||||
public function __construct(array $soapAttachments = [])
|
||||
{
|
||||
$this->soapAttachments = $soapAttachments;
|
||||
}
|
||||
|
||||
public function hasSoapAttachments()
|
||||
{
|
||||
return $this->soapAttachments !== null && count($this->soapAttachments) > 0;
|
||||
}
|
||||
|
||||
public function getSoapAttachments()
|
||||
{
|
||||
return $this->soapAttachments;
|
||||
}
|
||||
|
||||
public function getSoapAttachmentIds()
|
||||
{
|
||||
$ids = [];
|
||||
foreach ($this->getSoapAttachments() as $soapAttachment) {
|
||||
$ids[] = $soapAttachment->getId();
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
namespace BeSimple\SoapBundle\Soap;
|
||||
|
||||
use BeSimple\SoapCommon\Classmap;
|
||||
use BeSimple\SoapCommon\Converter\TypeConverterCollection;
|
||||
use BeSimple\SoapClient\SoapClientBuilder as BaseSoapClientBuilder;
|
||||
|
||||
class SoapClientBuilder extends BaseSoapClientBuilder
|
||||
{
|
||||
protected $soapClient;
|
||||
|
||||
public function __construct($wsdl, array $options, Classmap $classmap = null, TypeConverterCollection $converters = null)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->checkOptions($options);
|
||||
|
||||
$this
|
||||
->withWsdl($wsdl)
|
||||
->withTrace($options['debug'])
|
||||
;
|
||||
|
||||
if (isset($options['user_agent'])) {
|
||||
$this->withUserAgent($options['user_agent']);
|
||||
}
|
||||
|
||||
if (isset($options['cache_type'])) {
|
||||
$this->withWsdlCache($options['cache_type']);
|
||||
}
|
||||
|
||||
if ($classmap) {
|
||||
$this->withClassmap($classmap);
|
||||
}
|
||||
|
||||
if ($converters) {
|
||||
$this->withTypeConverters($converters);
|
||||
}
|
||||
}
|
||||
|
||||
public function build()
|
||||
{
|
||||
if (!$this->soapClient) {
|
||||
$this->soapClient = parent::build();
|
||||
}
|
||||
|
||||
return $this->soapClient;
|
||||
}
|
||||
|
||||
protected function checkOptions(array $options)
|
||||
{
|
||||
$checkOptions = array(
|
||||
'debug' => false,
|
||||
'cache_type' => null,
|
||||
'exceptions' => true,
|
||||
'user_agent' => 'BeSimpleSoap',
|
||||
);
|
||||
|
||||
// check option names and live merge, if errors are encountered Exception will be thrown
|
||||
$invalid = array();
|
||||
$isInvalid = false;
|
||||
foreach ($options as $key => $value) {
|
||||
if (!array_key_exists($key, $checkOptions)) {
|
||||
$isInvalid = true;
|
||||
$invalid[] = $key;
|
||||
}
|
||||
}
|
||||
|
||||
if ($isInvalid) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
'The "%s" class does not support the following options: "%s".',
|
||||
get_class($this),
|
||||
implode('\', \'', $invalid)
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,11 +11,11 @@
|
|||
namespace BeSimple\SoapBundle\Util;
|
||||
|
||||
/**
|
||||
* StringUtility provides utility methods for strings.
|
||||
* String provides utility methods for strings.
|
||||
*
|
||||
* @author Christian Kerl <christian-kerl@web.de>
|
||||
*/
|
||||
class StringUtility
|
||||
class String
|
||||
{
|
||||
/**
|
||||
* Checks if a string starts with a given string.
|
|
@ -13,8 +13,6 @@ namespace BeSimple\SoapBundle;
|
|||
|
||||
use BeSimple\SoapBundle\ServiceBinding\ServiceBinder;
|
||||
use BeSimple\SoapCommon\Converter\TypeConverterCollection;
|
||||
use BeSimple\SoapCommon\SoapOptionsBuilder;
|
||||
use BeSimple\SoapServer\SoapServerOptionsBuilder;
|
||||
use BeSimple\SoapWsdl\Dumper\Dumper;
|
||||
use BeSimple\SoapServer\SoapServerBuilder;
|
||||
use Symfony\Component\Config\ConfigCache;
|
||||
|
@ -46,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 $cache->getPath();
|
||||
$this->serviceDefinition = include (string) $cache;
|
||||
} 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']));
|
||||
|
@ -84,7 +82,7 @@ class WebServiceContext
|
|||
$cache->write($dumper->dump());
|
||||
}
|
||||
|
||||
return $cache->getPath();
|
||||
return (string) $cache;
|
||||
}
|
||||
|
||||
public function getServiceBinder()
|
||||
|
@ -104,14 +102,15 @@ class WebServiceContext
|
|||
public function getServerBuilder()
|
||||
{
|
||||
if (null === $this->serverBuilder) {
|
||||
$soapServerBuilder = new SoapServerBuilder();
|
||||
$this->serverBuilder = $soapServerBuilder->build(
|
||||
SoapServerOptionsBuilder::createWithDefaults(),
|
||||
SoapOptionsBuilder::createWithClassMap(
|
||||
$this->getWsdlFile(),
|
||||
$this->getServiceDefinition()->getTypeRepository()->getClassmap()
|
||||
)
|
||||
);
|
||||
$this->serverBuilder = SoapServerBuilder::createWithDefaults()
|
||||
->withWsdl($this->getWsdlFile())
|
||||
->withClassmap($this->getServiceDefinition()->getTypeRepository()->getClassmap())
|
||||
->withTypeConverters($this->converters)
|
||||
;
|
||||
|
||||
if (null !== $this->options['cache_type']) {
|
||||
$this->serverBuilder->withWsdlCache($this->options['cache_type']);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->serverBuilder;
|
||||
|
|
Loading…
Reference in New Issue