Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
e6beef5a80 | |||
69a7005c35 | |||
073028f160 | |||
a9f11beb83 | |||
7ab8771989 | |||
d68c25daad | |||
6e117940a3 | |||
0c47f5a8d4 |
@ -14,6 +14,8 @@ 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;
|
||||
@ -41,6 +43,7 @@ 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');
|
||||
@ -53,8 +56,8 @@ class BeSimpleSoapExtension extends Extension
|
||||
|
||||
$this->registerCacheConfiguration($config['cache'], $container, $loader);
|
||||
|
||||
if (!empty($config['clients'])) {
|
||||
$this->registerClientConfiguration($config['clients'], $container, $loader);
|
||||
if ( ! empty($config['clients'])) {
|
||||
$this->registerClientConfiguration($config, $container, $loader);
|
||||
}
|
||||
|
||||
$container->setParameter('besimple.soap.definition.dumper.options.stylesheet', $config['wsdl_dumper']['stylesheet']);
|
||||
@ -69,11 +72,9 @@ 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', 'lifetime', 'limit') as $key) {
|
||||
foreach (array('type', 'file') as $key) {
|
||||
$container->setParameter('besimple.soap.cache.'.$key, $config[$key]);
|
||||
}
|
||||
}
|
||||
@ -82,22 +83,33 @@ class BeSimpleSoapExtension extends Extension
|
||||
{
|
||||
$loader->load('client.xml');
|
||||
|
||||
foreach ($config as $client => $options) {
|
||||
$definition = new DefinitionDecorator('besimple.soap.client.builder');
|
||||
$container->setDefinition(sprintf('besimple.soap.client.builder.%s', $client), $definition);
|
||||
foreach ($config['clients'] as $client => $options) {
|
||||
$soapClientOpts = new DefinitionDecorator('besimple.soap.client_options');
|
||||
$soapOpts = new DefinitionDecorator('besimple.soap.options');
|
||||
|
||||
$definition->replaceArgument(0, $options['wsdl']);
|
||||
$soapClientOptsService = sprintf('besimple.soap.client_options.%s', $client);
|
||||
$soapOptsService = sprintf('besimple.soap.options.%s', $client);
|
||||
|
||||
$defOptions = $container
|
||||
->getDefinition('besimple.soap.client.builder')
|
||||
->getArgument(1);
|
||||
// configure SoapClient
|
||||
$definition = new DefinitionDecorator('besimple.soap.client');
|
||||
|
||||
foreach (array('cache_type', 'user_agent') as $key) {
|
||||
if (isset($options[$key])) {
|
||||
$defOptions[$key] = $options[$key];
|
||||
}
|
||||
}
|
||||
$container->setDefinition(
|
||||
sprintf('besimple.soap.client.%s', $client),
|
||||
$definition
|
||||
);
|
||||
$container->setDefinition(
|
||||
$soapClientOptsService,
|
||||
$soapClientOpts
|
||||
);
|
||||
$container->setDefinition(
|
||||
$soapOptsService,
|
||||
$soapOpts
|
||||
);
|
||||
|
||||
$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']) {
|
||||
@ -108,49 +120,58 @@ class BeSimpleSoapExtension extends Extension
|
||||
}
|
||||
}
|
||||
|
||||
$definition->addMethodCall('withProxy', array(
|
||||
$proxy['host'], $proxy['port'],
|
||||
$proxy['login'], $proxy['password'],
|
||||
$proxy['auth']
|
||||
));
|
||||
$proxy = $this->createClientProxy($client, $proxy, $container);
|
||||
$soapClientOpts->setFactory([
|
||||
'%besimple.soap.client_options_builder.class%',
|
||||
'createWithProxy'
|
||||
]);
|
||||
$soapClientOpts->setArgument(0, new Reference($proxy));
|
||||
}
|
||||
|
||||
if (isset($defOptions['cache_type'])) {
|
||||
$defOptions['cache_type'] = $this->getCacheType($defOptions['cache_type']);
|
||||
// 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'
|
||||
]);
|
||||
}
|
||||
|
||||
$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('set', array($classmap)),
|
||||
array('__construct', array($classmap)),
|
||||
));
|
||||
}
|
||||
|
||||
return sprintf('besimple.soap.classmap.%s', $client);
|
||||
}
|
||||
|
||||
private function createClient($client, ContainerBuilder $container)
|
||||
private function createClientProxy($client, array $proxy, ContainerBuilder $container)
|
||||
{
|
||||
$definition = new DefinitionDecorator('besimple.soap.client');
|
||||
$container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition);
|
||||
$definition = new DefinitionDecorator('besimple.soap.client.proxy');
|
||||
$container->setDefinition(sprintf('besimple.soap.client.proxy.%s', $client), $definition);
|
||||
|
||||
$definition->setFactory(array(
|
||||
new Reference(sprintf('besimple.soap.client.builder.%s', $client)),
|
||||
'build'
|
||||
));
|
||||
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);
|
||||
}
|
||||
|
||||
private function createWebServiceContext(array $config, ContainerBuilder $container)
|
||||
|
@ -64,6 +64,10 @@ 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()
|
||||
|
@ -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\SoapBundle\Soap\SoapClientBuilder</parameter>
|
||||
<parameter key="besimple.soap.classmap.class">BeSimple\SoapCommon\Classmap</parameter>
|
||||
<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>
|
||||
</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 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>
|
||||
|
||||
<service id="besimple.soap.client" class="%besimple.soap.client.builder.class%" abstract="true">
|
||||
<factory class="besimple.soap.client.builder" method="build" />
|
||||
<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>
|
||||
|
||||
<service id="besimple.soap.classmap" class="%besimple.soap.classmap.class%" abstract="true" />
|
||||
</services>
|
||||
|
||||
</container>
|
||||
|
@ -1,20 +1,31 @@
|
||||
<?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.cache.class">BeSimple\SoapBundle\Cache</parameter>
|
||||
<parameter key="besimple.soap.cache.dir">%kernel.cache_dir%/besimple/soap</parameter>
|
||||
<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>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
<service id="besimple.soap.cache" class="%besimple.soap.cache.class%">
|
||||
<argument>%kernel.debug%</argument>
|
||||
<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" />
|
||||
<argument>%besimple.soap.cache.type%</argument>
|
||||
<argument>%besimple.soap.cache.dir%/cache</argument>
|
||||
<argument>%besimple.soap.cache.lifetime%</argument>
|
||||
<argument>%besimple.soap.cache.limit%</argument>
|
||||
<argument>%besimple.soap.cache.dir%</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\SoapServer\Classmap</parameter>
|
||||
<parameter key="besimple.soap.server.classmap.class">BeSimple\SoapCommon\ClassMap</parameter>
|
||||
</parameters>
|
||||
|
||||
<services>
|
||||
|
@ -4,7 +4,6 @@ namespace BeSimple\SoapClient\Curl;
|
||||
|
||||
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationBasicOptions;
|
||||
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationDigestOptions;
|
||||
use BeSimple\SoapClient\Curl\Http\SslCertificateOptions;
|
||||
use Exception;
|
||||
|
||||
class Curl
|
||||
@ -141,6 +140,11 @@ class Curl
|
||||
curl_setopt($curlSession, CURLOPT_CAPATH, $sslCertificateOptions->hasCertificateAuthorityPath());
|
||||
}
|
||||
}
|
||||
|
||||
if ($options->hasSslVersion()) {
|
||||
curl_setopt($curlSession, CURLOPT_SSLVERSION, $options->getSslVersion());
|
||||
}
|
||||
|
||||
$executeSoapCallResponse = $this->executeHttpCall($curlSession, $options);
|
||||
|
||||
$httpRequestHeadersAsString = curl_getinfo($curlSession, CURLINFO_HEADER_OUT);
|
||||
@ -159,7 +163,7 @@ class Curl
|
||||
$httpResponseCode
|
||||
);
|
||||
|
||||
if (!is_integer($httpResponseCode) || $httpResponseCode >= 400 || $httpResponseCode === 0) {
|
||||
if (!is_int($httpResponseCode) || $httpResponseCode >= 400 || $httpResponseCode === 0) {
|
||||
|
||||
return new CurlResponse(
|
||||
$this->normalizeStringOrFalse($httpRequestHeadersAsString),
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace BeSimple\SoapClient\Curl;
|
||||
|
||||
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationBasicOptions;
|
||||
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationDigestOptions;
|
||||
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationInterface;
|
||||
use BeSimple\SoapClient\Curl\Http\HttpAuthenticationBasicOptions;
|
||||
use BeSimple\SoapClient\Curl\Http\SslCertificateOptions;
|
||||
use BeSimple\SoapClient\SoapServerProxy\SoapServerProxy;
|
||||
|
||||
@ -22,6 +22,7 @@ class CurlOptions
|
||||
private $proxy;
|
||||
private $httpAuthentication;
|
||||
private $sslCertificateOptions;
|
||||
private $sslVersion;
|
||||
|
||||
/**
|
||||
* @param string $userAgent
|
||||
@ -31,6 +32,7 @@ class CurlOptions
|
||||
* @param SoapServerProxy|null $proxy
|
||||
* @param HttpAuthenticationInterface|null $httpAuthentication
|
||||
* @param SslCertificateOptions|null $sslCertificateOptions
|
||||
* @param int $sslVersion
|
||||
*/
|
||||
public function __construct(
|
||||
$userAgent,
|
||||
@ -39,7 +41,8 @@ class CurlOptions
|
||||
$connectionTimeout,
|
||||
SoapServerProxy $proxy = null,
|
||||
HttpAuthenticationInterface $httpAuthentication = null,
|
||||
SslCertificateOptions $sslCertificateOptions = null
|
||||
SslCertificateOptions $sslCertificateOptions = null,
|
||||
$sslVersion = null
|
||||
) {
|
||||
$this->userAgent = $userAgent;
|
||||
$this->followLocationMaxRedirects = $followLocationMaxRedirects;
|
||||
@ -48,6 +51,7 @@ class CurlOptions
|
||||
$this->proxy = $proxy;
|
||||
$this->httpAuthentication = $httpAuthentication;
|
||||
$this->sslCertificateOptions = $sslCertificateOptions;
|
||||
$this->sslVersion = $sslVersion;
|
||||
}
|
||||
|
||||
public function getUserAgent()
|
||||
@ -123,4 +127,14 @@ class CurlOptions
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function hasSslVersion()
|
||||
{
|
||||
return $this->sslVersion !== null;
|
||||
}
|
||||
|
||||
public function getSslVersion()
|
||||
{
|
||||
return $this->sslVersion;
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ class CurlOptionsBuilder
|
||||
self::DEFAULT_CONNECTION_TIMEOUT,
|
||||
$soapClientOptions->getProxy(),
|
||||
self::getHttpAuthOptions($soapClientOptions),
|
||||
self::getSslCertificateOptions($soapClientOptions)
|
||||
self::getSslCertificateOptions($soapClientOptions),
|
||||
$soapClientOptions->getSslVersion()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -45,6 +45,18 @@ class SoapClientOptionsBuilder
|
||||
);
|
||||
}
|
||||
|
||||
public static function createWithProxy($proxy)
|
||||
{
|
||||
return new SoapClientOptions(
|
||||
SoapClientOptions::SOAP_CLIENT_TRACE_ON,
|
||||
SoapClientOptions::SOAP_CLIENT_EXCEPTIONS_ON,
|
||||
CurlOptions::DEFAULT_USER_AGENT,
|
||||
SoapClientOptions::SOAP_CLIENT_COMPRESSION_NONE,
|
||||
SoapClientOptions::SOAP_CLIENT_AUTHENTICATION_NONE,
|
||||
$proxy
|
||||
);
|
||||
}
|
||||
|
||||
public static function createWithEndpointLocation($endpointLocation)
|
||||
{
|
||||
return new SoapClientOptions(
|
||||
@ -82,6 +94,28 @@ class SoapClientOptionsBuilder
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $endpointLocation
|
||||
* @param SoapServerAuthenticationInterface $authentication
|
||||
* @return SoapClientOptions
|
||||
*/
|
||||
public static function createWithAuthenticationAndEndpointLocationAndSslVersionV3(
|
||||
$endpointLocation,
|
||||
SoapServerAuthenticationInterface $authentication
|
||||
) {
|
||||
return new SoapClientOptions(
|
||||
SoapClientOptions::SOAP_CLIENT_TRACE_ON,
|
||||
SoapClientOptions::SOAP_CLIENT_EXCEPTIONS_ON,
|
||||
CurlOptions::DEFAULT_USER_AGENT,
|
||||
SoapClientOptions::SOAP_CLIENT_COMPRESSION_NONE,
|
||||
$authentication,
|
||||
SoapClientOptions::SOAP_CLIENT_PROXY_NONE,
|
||||
$endpointLocation,
|
||||
false,
|
||||
CURL_SSLVERSION_SSLv3
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SoapServerAuthenticationInterface $authentication
|
||||
* @param bool $resolveRemoteIncludes
|
||||
|
@ -31,6 +31,7 @@ class SoapClientOptions
|
||||
private $proxy;
|
||||
private $location;
|
||||
private $resolveRemoteIncludes;
|
||||
private $sslVersion;
|
||||
|
||||
/**
|
||||
* @param bool $trace = self::SOAP_CLIENT_TRACE_ON|self::SOAP_CLIENT_TRACE_OFF
|
||||
@ -41,6 +42,7 @@ class SoapClientOptions
|
||||
* @param SoapServerProxy|null $proxy
|
||||
* @param string|null $location
|
||||
* @param bool $resolveRemoteIncludes = self::SOAP_CLIENT_RESOLVE_REMOTE_INCLUDES_ON|self::SOAP_CLIENT_RESOLVE_REMOTE_INCLUDES_OFF
|
||||
* @param int $sslVersion
|
||||
*/
|
||||
public function __construct(
|
||||
$trace,
|
||||
@ -50,7 +52,8 @@ class SoapClientOptions
|
||||
SoapServerAuthenticationInterface $authentication = null,
|
||||
SoapServerProxy $proxy = null,
|
||||
$location = null,
|
||||
$resolveRemoteIncludes = false
|
||||
$resolveRemoteIncludes = false,
|
||||
$sslVersion = null
|
||||
) {
|
||||
$this->trace = $trace;
|
||||
$this->exceptions = $exceptions;
|
||||
@ -60,6 +63,7 @@ class SoapClientOptions
|
||||
$this->proxy = $proxy;
|
||||
$this->location = $location;
|
||||
$this->resolveRemoteIncludes = $resolveRemoteIncludes;
|
||||
$this->sslVersion = $sslVersion;
|
||||
}
|
||||
|
||||
public function getTrace()
|
||||
@ -154,4 +158,9 @@ class SoapClientOptions
|
||||
|
||||
return $optionsAsArray;
|
||||
}
|
||||
|
||||
public function getSslVersion()
|
||||
{
|
||||
return $this->sslVersion;
|
||||
}
|
||||
}
|
||||
|
@ -19,16 +19,16 @@ class RelativePathResolver
|
||||
public function resolveRelativePathInUrl($base, $relative)
|
||||
{
|
||||
$urlParts = parse_url($base);
|
||||
$isRelativePathAbsolute = 0 === strpos($relative, '/') || 0 === strpos($relative, '..');
|
||||
$pathIsSet = true === isset($urlParts['path']);
|
||||
|
||||
// combine base path with relative path
|
||||
if (isset($urlParts['path']) && mb_strlen($relative) > 0 && $isRelativePathAbsolute) {
|
||||
if (true === $pathIsSet && 0 < mb_strlen($relative) && 0 === strpos($relative, '/')) {
|
||||
// $relative is absolute path from domain (starts with /)
|
||||
$path = $relative;
|
||||
} elseif (isset($urlParts['path']) && strrpos($urlParts['path'], '/') === (strlen($urlParts['path']) )) {
|
||||
} elseif (true === $pathIsSet && strrpos($urlParts['path'], '/') === strlen($urlParts['path'])) {
|
||||
// base path is directory
|
||||
$path = $urlParts['path'].$relative;
|
||||
} elseif (isset($urlParts['path'])) {
|
||||
} elseif (true === $pathIsSet) {
|
||||
// strip filename from base path
|
||||
$path = substr($urlParts['path'], 0, strrpos($urlParts['path'], '/')).'/'.$relative;
|
||||
} else {
|
||||
|
@ -4,6 +4,7 @@ namespace BeSimple\SoapClient\Xml;
|
||||
|
||||
use BeSimple\SoapClient\Curl\Curl;
|
||||
use BeSimple\SoapClient\WsdlDownloader;
|
||||
use BeSimple\SoapClient\Xml\Path\RelativePathResolver;
|
||||
use DOMElement;
|
||||
use DOMXPath;
|
||||
|
||||
@ -45,7 +46,8 @@ class XmlDomDocumentImportReplacer
|
||||
$locationAttributeName,
|
||||
WsdlDownloader::instantiateDownloader()->getWsdlPath(
|
||||
$curl,
|
||||
self::resolveRelativePathInUrl($parentFilePath, $locationPath),
|
||||
RelativePathResolver::instantiateResolver()
|
||||
->resolveRelativePathInUrl($parentFilePath, $locationPath),
|
||||
$cacheType,
|
||||
true
|
||||
)
|
||||
@ -55,68 +57,4 @@ class XmlDomDocumentImportReplacer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the relative path to base into an absolute.
|
||||
*
|
||||
* @param string $base Base path
|
||||
* @param string $relative Relative path
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function resolveRelativePathInUrl($base, $relative)
|
||||
{
|
||||
$urlParts = parse_url($base);
|
||||
$isRelativePathAbsolute = 0 === strpos($relative, '/') || 0 === strpos($relative, '..');
|
||||
|
||||
// combine base path with relative path
|
||||
if (isset($urlParts['path']) && mb_strlen($relative) > 0 && $isRelativePathAbsolute) {
|
||||
// $relative is absolute path from domain (starts with /)
|
||||
$path = $relative;
|
||||
} elseif (isset($urlParts['path']) && strrpos($urlParts['path'], '/') === (strlen($urlParts['path']) )) {
|
||||
// base path is directory
|
||||
$path = $urlParts['path'].$relative;
|
||||
} elseif (isset($urlParts['path'])) {
|
||||
// strip filename from base path
|
||||
$path = substr($urlParts['path'], 0, strrpos($urlParts['path'], '/')).'/'.$relative;
|
||||
} else {
|
||||
// no base path
|
||||
$path = '/'.$relative;
|
||||
}
|
||||
|
||||
// foo/./bar ==> foo/bar
|
||||
// remove double slashes
|
||||
$path = preg_replace(array('#/\./#', '#/+#'), '/', $path);
|
||||
|
||||
// split path by '/'
|
||||
$parts = explode('/', $path);
|
||||
|
||||
// resolve /../
|
||||
foreach ($parts as $key => $part) {
|
||||
if ($part === '..') {
|
||||
$keyToDelete = $key - 1;
|
||||
while ($keyToDelete > 0) {
|
||||
if (isset($parts[$keyToDelete])) {
|
||||
unset($parts[$keyToDelete]);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$keyToDelete--;
|
||||
}
|
||||
|
||||
unset($parts[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$hostname = $urlParts['scheme'].'://'.$urlParts['host'];
|
||||
if (isset($urlParts['port'])) {
|
||||
$hostname .= ':'.$urlParts['port'];
|
||||
}
|
||||
if (substr($hostname, -1) !== '/') {
|
||||
$hostname .= '/';
|
||||
}
|
||||
|
||||
return $hostname.implode('/', $parts);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
namespace BeSimple\SoapCommon\Definition\Type;
|
||||
|
||||
use BeSimple\SoapCommon\Classmap;
|
||||
use BeSimple\SoapCommon\ClassMap;
|
||||
|
||||
/**
|
||||
* @author Christian Kerl <christian-kerl@web.de>
|
||||
@ -27,7 +27,7 @@ class TypeRepository
|
||||
|
||||
protected $classmap;
|
||||
|
||||
public function __construct(Classmap $classmap = null)
|
||||
public function __construct(ClassMap $classmap = null)
|
||||
{
|
||||
$this->classmap = $classmap;
|
||||
}
|
||||
@ -77,7 +77,7 @@ class TypeRepository
|
||||
$phpType = $type->getPhpType();
|
||||
|
||||
$this->types[$phpType] = $type;
|
||||
$this->addClassmap($type->getXmlType(), $phpType);
|
||||
$this->addClassMap($type->getXmlType(), $phpType);
|
||||
}
|
||||
|
||||
public function hasType($type)
|
||||
@ -119,12 +119,12 @@ class TypeRepository
|
||||
return $match[1];
|
||||
}
|
||||
|
||||
public function getClassmap()
|
||||
public function getClassMap()
|
||||
{
|
||||
return $this->classmap;
|
||||
}
|
||||
|
||||
protected function addClassmap($xmlType, $phpType)
|
||||
protected function addClassMap($xmlType, $phpType)
|
||||
{
|
||||
if (!$this->classmap) {
|
||||
return;
|
||||
|
@ -27,7 +27,7 @@ class MimeBoundaryAnalyser
|
||||
*/
|
||||
public static function isMessageLineBoundary($mimeMessageLine)
|
||||
{
|
||||
return strlen($mimeMessageLine) > 0 && $mimeMessageLine[0] === "-";
|
||||
return preg_match('/^--[0-9A-Za-z\s\'\/\+\_\,\-\.\:\=\?]+/', $mimeMessageLine) === 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,6 +4,7 @@ namespace BeSimple\SoapClient;
|
||||
|
||||
use BeSimple\SoapClient\Curl\CurlOptions;
|
||||
use BeSimple\SoapClient\SoapOptions\SoapClientOptions;
|
||||
use BeSimple\SoapClient\SoapServerAuthentication\SoapServerAuthenticationBasic;
|
||||
use BeSimple\SoapCommon\ClassMap;
|
||||
use BeSimple\SoapCommon\SoapOptions\SoapOptions;
|
||||
use BeSimple\SoapCommon\SoapOptionsBuilder;
|
||||
@ -87,6 +88,27 @@ class SoapClientBuilderTest extends PHPUnit_Framework_TestCase
|
||||
self::assertInstanceOf(SoapClient::class, $soapClient);
|
||||
}
|
||||
|
||||
public function testCreateOptionsWithAuthenticationAndEndpointLocationAndSslVersionV3()
|
||||
{
|
||||
$authentication = new SoapServerAuthenticationBasic('', '');
|
||||
$soapClientOptions = SoapClientOptionsBuilder::createWithAuthenticationAndEndpointLocationAndSslVersionV3('', $authentication);
|
||||
|
||||
self::assertSame(CURL_SSLVERSION_SSLv3, $soapClientOptions->getSslVersion());
|
||||
}
|
||||
|
||||
public function testConstructSoapClientWithAuthenticationAndEndpointLocationAndSslVersionV3()
|
||||
{
|
||||
$authentication = new SoapServerAuthenticationBasic('', '');
|
||||
$soapOptions = SoapOptionsBuilder::createWithDefaults(self::TEST_LOCAL_WSDL_UK);
|
||||
|
||||
$soapClient = $this->getSoapBuilder()->build(
|
||||
SoapClientOptionsBuilder::createWithAuthenticationAndEndpointLocationAndSslVersionV3('', $authentication),
|
||||
$soapOptions
|
||||
);
|
||||
|
||||
self::assertInstanceOf(SoapClient::class, $soapClient);
|
||||
}
|
||||
|
||||
private function getSoapBuilder()
|
||||
{
|
||||
return new SoapClientBuilder();
|
||||
|
@ -30,6 +30,11 @@ class RelativePathResolverTest extends PHPUnit_Framework_TestCase
|
||||
public function providePathInfo()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'http://anyendpoint.tld:9999/path/to/endpoint.wsdl',
|
||||
'../Schemas/Common/SoapHeader.xsd',
|
||||
'http://anyendpoint.tld:9999/path/Schemas/Common/SoapHeader.xsd',
|
||||
],
|
||||
[
|
||||
'http://endpoint-location.ltd/',
|
||||
'Document1.xsd',
|
||||
|
@ -97,9 +97,18 @@ class XmlDomDocumentImportReplacerTest extends PHPUnit_Framework_TestCase
|
||||
Helper::PFX_XML_SCHEMA,
|
||||
Helper::NS_XML_SCHEMA,
|
||||
'schemaLocation',
|
||||
'http://endpoint-location.ltd:8080/endpoint/',
|
||||
'http://endpoint-location.ltd:8080/endpoint/wsdl.wsdl',
|
||||
'<xs:include schemaLocation="http://endpoint-location.ltd:8080/Schemas/Common/Document1.xsd"></xs:include>'
|
||||
],
|
||||
'schemaWithParentPathAndSubDir' => [
|
||||
file_get_contents(__DIR__.'/testUpdateXmlDocument.wsdl'),
|
||||
new Curl(CurlOptionsBuilder::buildDefault()),
|
||||
Helper::PFX_XML_SCHEMA,
|
||||
Helper::NS_XML_SCHEMA,
|
||||
'schemaLocation',
|
||||
'http://endpoint-location.ltd:8080/endpoint/subdir/wsdl.wsdl',
|
||||
'<xs:include schemaLocation="http://endpoint-location.ltd:8080/endpoint/Schemas/Common/Document1.xsd"></xs:include>'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -67,6 +67,8 @@ class MimeBoundaryAnalyserTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
return [
|
||||
['-- this line is boundary', self::EXPECTED_IS_BOUNDARY],
|
||||
['--this line is boundary', self::EXPECTED_IS_BOUNDARY],
|
||||
['--@ this line is not boundary', self::EXPECTED_IS_NOT_BOUNDARY],
|
||||
['-- this line is also a boundary --', self::EXPECTED_IS_BOUNDARY],
|
||||
['mesage line -- is not boundary', self::EXPECTED_IS_NOT_BOUNDARY],
|
||||
[' -- mesage line -- is not boundary', self::EXPECTED_IS_NOT_BOUNDARY],
|
||||
|
Reference in New Issue
Block a user