28 Commits

Author SHA1 Message Date
1fa5c8a15e Mark client generated services as public 2022-02-23 15:13:04 +01:00
813dd52d70 Update dependency injection for Symfony 4.* 2022-02-09 09:47:50 +01:00
8a40d23a94 Use laminas/laminas-mime instead of zendframework/zend-mime 2022-02-08 16:03:13 +01:00
5d335f2ca9 Correction de l'écriture du xml 2020-07-15 12:35:40 -04:00
9d6468d0a6 Update composer.json 2020-07-15 11:25:49 -04:00
9786f291b0 Update composer.json 2020-07-15 11:25:04 -04:00
750db6692b Update composer.json 2020-07-15 11:24:05 -04:00
9f7b7f40b8 Merge pull request #4 from Cadoles/develop
Add minOccurs annotation support on complexType
2020-07-15 16:29:05 +02:00
87947a1e7b Merge branch 'mse' into develop 2020-07-15 16:26:24 +02:00
e024833d48 Add minOccurs annotation support on complexType 2020-07-15 16:16:25 +02:00
fc44014790 Définition timeout curl a 10 secondes 2019-10-24 16:34:14 -04:00
7ba9c4048c Nouvelle méthode de validation des WSDL 2019-10-10 15:20:59 -04:00
f0733bd671 Nouvelle méthode de validation des WSDL 2019-10-10 15:17:16 -04:00
f5e1be09de Merge branch 'mse' of github.com:Cadoles/BeSimpleSoap into mse 2019-10-10 15:16:24 -04:00
df3d75047f Nouvelle méthode de validation des WSDL 2019-10-10 15:16:10 -04:00
87350704d3 Merge pull request #2 from Cadoles/issue#1
vérification fichier de cache vide ou xml erronné
2019-09-24 09:19:38 -04:00
85f86469ab Merge OK 2019-09-24 09:17:28 -04:00
e1a35d1e1e Vérification fichier de cache vide ou xml erronné 2019-09-24 08:54:47 -04:00
30850d7a01 Merge pull request #3 from Cadoles/php-cs-fixer
Passe générale php-cs-fixer
2019-09-24 08:50:42 -04:00
77403fcfbb Suppression fichier de cache cs-fixer 2019-09-24 08:45:47 -04:00
dc63ba20e4 ajouter fichier de cache cs-fixer au gitignore 2019-09-24 08:43:49 -04:00
dad2b76165 Passe générale php-cs-fixer 2019-09-24 08:23:19 -04:00
a1695680ae Signature de Response iso PROD 2019-09-20 12:10:09 -04:00
95706abbd7 Retour à une signature iso PROD 2019-09-19 15:29:04 -04:00
6d5f9ff9e5 Show null attributes in response
Partially revert changes from d1f5c1f674 and fea1093bed
2019-09-16 16:41:21 +02:00
914acccf1d Ignore .php_cs.cache files 2019-09-12 11:45:48 +02:00
0c94185907 Revert "Fix Dumper. Each complext type is now wrapped inside container element tag"
This reverts commit 7802a0d19f.
2019-09-12 11:44:47 +02:00
aa0b750f47 Revert "Array support change"
This reverts commit 3f2a99adf6.
2019-09-12 11:43:53 +02:00
84 changed files with 247 additions and 341 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@ composer.lock
composer.phar composer.phar
phpunit.xml phpunit.xml
.idea .idea
.php_cs.cache

View File

@ -26,7 +26,7 @@
"ass/xmlsecurity": "~1.0", "ass/xmlsecurity": "~1.0",
"symfony/framework-bundle": "~3.4|~4.0", "symfony/framework-bundle": "~3.4|~4.0",
"symfony/twig-bundle": "~3.4|~4.0", "symfony/twig-bundle": "~3.4|~4.0",
"zendframework/zend-mime": "2.1.*" "laminas/laminas-mime": "~2.1"
}, },
"replace": { "replace": {
"besimple/soap-bundle": "self.version", "besimple/soap-bundle": "self.version",
@ -47,7 +47,7 @@
}, },
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "master-dev" "dev-master": "5.2.0-dev"
} }
} }
} }

View File

@ -19,7 +19,6 @@ use BeSimple\SoapBundle\WebServiceContext;
use BeSimple\SoapServer\SoapServerBuilder; use BeSimple\SoapServer\SoapServerBuilder;
use Symfony\Component\DependencyInjection\ContainerAwareInterface; use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait; use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Debug\Exception\FlattenException; use Symfony\Component\Debug\Exception\FlattenException;
@ -59,7 +58,7 @@ class SoapWebServiceController implements ContainerAwareInterface
/** /**
* @var array * @var array
*/ */
private $headers = array(); private $headers = [];
/** /**
* @return \BeSimple\SoapBundle\Soap\SoapResponse * @return \BeSimple\SoapBundle\Soap\SoapResponse
@ -96,14 +95,14 @@ class SoapWebServiceController implements ContainerAwareInterface
{ {
$routeName = $webservice.'_webservice_call'; $routeName = $webservice.'_webservice_call';
$result = $this->container->get('router')->getRouteCollection()->get($routeName); $result = $this->container->get('router')->getRouteCollection()->get($routeName);
if ($result === null) { if (null === $result) {
$routeName = '_webservice_call'; $routeName = '_webservice_call';
} }
$response = new Response($this->getWebServiceContext($webservice)->getWsdlFileContent( $response = new Response($this->getWebServiceContext($webservice)->getWsdlFileContent(
$this->container->get('router')->generate( $this->container->get('router')->generate(
$routeName, $routeName,
array('webservice' => $webservice), ['webservice' => $webservice],
UrlGeneratorInterface::ABSOLUTE_URL UrlGeneratorInterface::ABSOLUTE_URL
) )
)); ));
@ -137,12 +136,12 @@ class SoapWebServiceController implements ContainerAwareInterface
$view = '@Twig/Exception/'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error').'.txt.twig'; $view = '@Twig/Exception/'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error').'.txt.twig';
$code = $exception->getStatusCode(); $code = $exception->getStatusCode();
$details = $this->container->get('twig')->render($view, array( $details = $this->container->get('twig')->render($view, [
'status_code' => $code, 'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '', 'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
'exception' => $exception, 'exception' => $exception,
'logger' => $logger, 'logger' => $logger,
)); ]);
$handler = new ExceptionHandler($exception, $details); $handler = new ExceptionHandler($exception, $details);
if ($soapFault = $request->query->get('_besimple_soap_fault')) { if ($soapFault = $request->query->get('_besimple_soap_fault')) {
@ -234,7 +233,7 @@ class SoapWebServiceController implements ContainerAwareInterface
} }
/** /**
* Set the SoapResponse * Set the SoapResponse.
* *
* @param Response $response A response to check and set * @param Response $response A response to check and set
* *

View File

@ -152,11 +152,12 @@ class BeSimpleSoapExtension extends Extension
$definition = new ChildDefinition('besimple.soap.client'); $definition = new ChildDefinition('besimple.soap.client');
$container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition); $container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition);
if (3 === Kernel::MAJOR_VERSION) { if (Kernel::MAJOR_VERSION >= 3) {
$definition->setFactory(array( $definition->setFactory(array(
new Reference(sprintf('besimple.soap.client.builder.%s', $client)), new Reference(sprintf('besimple.soap.client.builder.%s', $client)),
'build' 'build'
)); ));
$definition->setPublic(true);
} else { } else {
$definition->setFactoryService(sprintf('besimple.soap.client.builder.%s', $client)); $definition->setFactoryService(sprintf('besimple.soap.client.builder.%s', $client));
} }

View File

@ -96,8 +96,12 @@ class Configuration
->info('proxy configuration') ->info('proxy configuration')
->addDefaultsIfNotSet() ->addDefaultsIfNotSet()
->beforeNormalization() ->beforeNormalization()
->ifTrue(function ($v) { return !is_array($v); }) ->ifTrue(function ($v) {
->then(function ($v) { return array('host' => null === $v ? false : $v); }) return !is_array($v);
})
->then(function ($v) {
return array('host' => null === $v ? false : $v);
})
->end() ->end()
->children() ->children()
->scalarNode('host')->defaultFalse()->end() ->scalarNode('host')->defaultFalse()->end()

View File

@ -19,7 +19,9 @@
<argument type="service" id="besimple.soap.cache" /> <!-- hack to load besimple cache configuration --> <argument type="service" id="besimple.soap.cache" /> <!-- hack to load besimple cache configuration -->
</service> </service>
<service id="besimple.soap.client" factory-service="besimple.soap.client.builder" factory-method="build" class="%besimple.soap.client.builder.class%" abstract="true" /> <service id="besimple.soap.client" class="%besimple.soap.client.builder.class%" abstract="true">
<factory service="besimple.soap.client.builder" method="build" />
</service>
<service id="besimple.soap.classmap" class="%besimple.soap.classmap.class%" abstract="true" /> <service id="besimple.soap.classmap" class="%besimple.soap.classmap.class%" abstract="true" />
</services> </services>

View File

@ -24,5 +24,5 @@ interface MessageBinderInterface
* *
* @return mixed * @return mixed
*/ */
function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository); public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository);
} }

View File

@ -55,8 +55,7 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
$isArray = true; $isArray = true;
$array = array(); $array = array();
$phpType = substr($type->getPhpType(), 0, strlen($type->getPhpType()) - 2); $type = $this->typeRepository->getType($type->get('item')->getType());
$type = $this->typeRepository->getType($phpType);
} }
// @TODO Fix array reference // @TODO Fix array reference
@ -79,21 +78,6 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
$array = $assocArray; $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; $message = $array;
} else { } else {

View File

@ -44,7 +44,8 @@ class ServiceBinder
* @param MessageBinderInterface $requestMessageBinder * @param MessageBinderInterface $requestMessageBinder
* @param MessageBinderInterface $responseMessageBinder * @param MessageBinderInterface $responseMessageBinder
*/ */
public function __construct(Definition $definition, MessageBinderInterface $requestHeaderMessageBinder, MessageBinderInterface $requestMessageBinder, MessageBinderInterface $responseMessageBinder) { public function __construct(Definition $definition, MessageBinderInterface $requestHeaderMessageBinder, MessageBinderInterface $requestMessageBinder, MessageBinderInterface $responseMessageBinder)
{
$this->definition = $definition; $this->definition = $definition;
$this->requestHeaderMessageBinder = $requestHeaderMessageBinder; $this->requestHeaderMessageBinder = $requestHeaderMessageBinder;

View File

@ -18,7 +18,7 @@ class ComplexType extends Configuration
private $name; private $name;
private $value; private $value;
private $isNillable = false; private $isNillable = false;
private $isAttribute = false; private $minOccurs = 1;
public function getName() public function getName()
{ {
@ -60,24 +60,14 @@ class ComplexType extends Configuration
$this->isNillable = (bool) $isNillable; $this->isNillable = (bool) $isNillable;
} }
/** public function setMinOccurs($minOccurs)
* @return bool
*/
public function isAttribute()
{ {
return $this->isAttribute; $this->minOccurs = $minOccurs;
} }
/** public function getMinOccurs()
* @param bool $isAttribute
*
* @return $this
*/
public function setIsAttribute($isAttribute)
{ {
$this->isAttribute = $isAttribute; return $this->minOccurs;
return $this;
} }
public function getAliasName() public function getAliasName()

View File

@ -22,5 +22,5 @@ interface ConfigurationInterface
* *
* @return string * @return string
*/ */
function getAliasName(); public function getAliasName();
} }

View File

@ -12,8 +12,8 @@ namespace BeSimple\SoapBundle\ServiceDefinition\Annotation;
interface TypedElementInterface interface TypedElementInterface
{ {
function getPhpType(); public function getPhpType();
function getXmlType(); public function getXmlType();
function setPhpType($phpType); public function setPhpType($phpType);
function setXmlType($xmlType); public function setXmlType($xmlType);
} }

View File

@ -20,7 +20,7 @@ class ComplexType
private $name; private $name;
private $value; private $value;
private $isNillable = false; private $isNillable = false;
private $isAttribute = false; private $minOccurs = 1;
public function getName() public function getName()
{ {
@ -47,28 +47,18 @@ class ComplexType
$this->value = $value; $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) public function setNillable($isNillable)
{ {
$this->isNillable = (bool) $isNillable; $this->isNillable = (bool) $isNillable;
} }
public function setMinOccurs($minOccurs)
{
$this->minOccurs = $minOccurs;
}
public function getMinOccurs()
{
return $this->minOccurs;
}
} }

View File

@ -160,7 +160,7 @@ class AnnotationClassLoader extends Loader
$loaded = $complexTypeResolver->load($phpType); $loaded = $complexTypeResolver->load($phpType);
$complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType); $complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType);
foreach ($loaded['properties'] as $name => $property) { foreach ($loaded['properties'] as $name => $property) {
$complexType->add($name, $this->loadType($property->getValue()), $property->isNillable(), $property->isAttribute()); $complexType->add($name, $this->loadType($property->getValue()), $property->isNillable(), $property->getMinOccurs());
} }
$this->typeRepository->addComplexType($complexType); $this->typeRepository->addComplexType($complexType);

View File

@ -43,7 +43,7 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class)); throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
} }
$annotations = array(); $annotations = [];
$class = new \ReflectionClass($class); $class = new \ReflectionClass($class);
if ($alias = $this->reader->getClassAnnotation($class, $this->aliasClass)) { if ($alias = $this->reader->getClassAnnotation($class, $this->aliasClass)) {
@ -58,8 +58,8 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
$propertyComplexType = new ComplexType(); $propertyComplexType = new ComplexType();
$propertyComplexType->setValue($complexType->getValue()); $propertyComplexType->setValue($complexType->getValue());
$propertyComplexType->setNillable($complexType->isNillable()); $propertyComplexType->setNillable($complexType->isNillable());
$propertyComplexType->setIsAttribute($complexType->isAttribute());
$propertyComplexType->setName($property->getName()); $propertyComplexType->setName($property->getName());
$propertyComplexType->setMinOccurs($complexType->getMinOccurs());
$annotations['properties']->add($propertyComplexType); $annotations['properties']->add($propertyComplexType);
} }
} }
@ -73,7 +73,7 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
* @param mixed $resource A resource * @param mixed $resource A resource
* @param string $type The resource type * @param string $type The resource type
* *
* @return Boolean True if this class supports the given resource, false otherwise * @return bool True if this class supports the given resource, false otherwise
*/ */
public function supports($resource, $type = null) public function supports($resource, $type = null)
{ {

View File

@ -12,7 +12,7 @@ namespace BeSimple\SoapBundle\Soap;
use BeSimple\SoapBundle\Util\Collection; use BeSimple\SoapBundle\Util\Collection;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Zend\Mime\Message; use Laminas\Mime\Message;
/** /**
* SoapRequest. * SoapRequest.

View File

@ -79,10 +79,7 @@ class WebServiceContext
} }
$dumper = new Dumper($definition, array('stylesheet' => $this->options['wsdl_stylesheet'])); $dumper = new Dumper($definition, array('stylesheet' => $this->options['wsdl_stylesheet']));
$cache->write($dumper->dump());
$wsdl = $dumper->dump();
$cache->write($wsdl);
} }
return $cache->getPath(); return $cache->getPath();

View File

@ -77,9 +77,8 @@ class Curl
if (isset($options['compression']) && !($options['compression'] & SOAP_COMPRESSION_ACCEPT)) { if (isset($options['compression']) && !($options['compression'] & SOAP_COMPRESSION_ACCEPT)) {
curl_setopt($this->ch, CURLOPT_ENCODING, 'identity'); curl_setopt($this->ch, CURLOPT_ENCODING, 'identity');
} }
if (isset($options['connection_timeout'])) {
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, $options['connection_timeout']); curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 10);
}
if (isset($options['proxy_host'])) { if (isset($options['proxy_host'])) {
if (false !== $options['proxy_host']) { if (false !== $options['proxy_host']) {
@ -167,7 +166,6 @@ class Curl
private function execManualRedirect($redirects = 0) private function execManualRedirect($redirects = 0)
{ {
if ($redirects > $this->followLocationMaxRedirects) { if ($redirects > $this->followLocationMaxRedirects) {
// TODO Redirection limit reached, aborting // TODO Redirection limit reached, aborting
return false; return false;
} }
@ -205,7 +203,7 @@ class Curl
/** /**
* Error code mapping from cURL error codes to PHP ext/soap error messages * Error code mapping from cURL error codes to PHP ext/soap error messages
* (where applicable) * (where applicable).
* *
* http://curl.haxx.se/libcurl/c/libcurl-errors.html * http://curl.haxx.se/libcurl/c/libcurl-errors.html
* *
@ -251,7 +249,6 @@ class Curl
$errorCodeMapping = $this->getErrorCodeMapping(); $errorCodeMapping = $this->getErrorCodeMapping();
$errorNumber = curl_errno($this->ch); $errorNumber = curl_errno($this->ch);
if (isset($errorCodeMapping[$errorNumber])) { if (isset($errorCodeMapping[$errorNumber])) {
return $errorCodeMapping[$errorNumber]; return $errorCodeMapping[$errorNumber];
} }

View File

@ -23,7 +23,7 @@ abstract class AbstractWebServerTest extends \PHPUnit_Framework_TestCase
/** /**
* @var ProcessBuilder * @var ProcessBuilder
*/ */
static protected $webserver; protected static $webserver;
public static function setUpBeforeClass() public static function setUpBeforeClass()
{ {

View File

@ -36,7 +36,6 @@ try {
$attachment->binaryData = $b64; $attachment->binaryData = $b64;
var_dump($sc->attachment($attachment)); var_dump($sc->attachment($attachment));
} catch (Exception $e) { } catch (Exception $e) {
var_dump($e); var_dump($e);
} }

View File

@ -29,7 +29,6 @@ $options = array(
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $options); $sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/SwA.wsdl', $options);
try { try {
$upload = new uploadFile(); $upload = new uploadFile();
$upload->name = 'upload.txt'; $upload->name = 'upload.txt';
$upload->data = 'This is a test. :)'; $upload->data = 'This is a test. :)';

View File

@ -69,7 +69,6 @@ try {
$ab->type = 'scifi'; $ab->type = 'scifi';
var_dump($sc->addBook($ab)); var_dump($sc->addBook($ab));
} catch (Exception $e) { } catch (Exception $e) {
var_dump($e); var_dump($e);
} }

View File

@ -54,7 +54,6 @@ try {
$ab->type = 'scifi'; $ab->type = 'scifi';
var_dump($sc->addBook($ab)); var_dump($sc->addBook($ab));
} catch (Exception $e) { } catch (Exception $e) {
var_dump($e); var_dump($e);
} }

View File

@ -25,9 +25,9 @@ use org\bovigo\vfs\vfsStreamWrapper;
*/ */
class WsdlDownloaderTest extends AbstractWebserverTest class WsdlDownloaderTest extends AbstractWebserverTest
{ {
static protected $filesystem; protected static $filesystem;
static protected $fixturesPath; protected static $fixturesPath;
/** /**
* @dataProvider provideDownload * @dataProvider provideDownload

View File

@ -157,7 +157,6 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
public function getReferenceParameter($ns, $parameter) public function getReferenceParameter($ns, $parameter)
{ {
if (isset($this->referenceParametersRecieved[$ns][$parameter])) { if (isset($this->referenceParametersRecieved[$ns][$parameter])) {
return $this->referenceParametersRecieved[$ns][$parameter]; return $this->referenceParametersRecieved[$ns][$parameter];
} }

View File

@ -151,7 +151,6 @@ class WsSecurityFilter extends WsSecurityFilterClientServer implements SoapReque
if (null !== $this->password if (null !== $this->password
&& (null === $this->userSecurityKey && (null === $this->userSecurityKey
|| (null !== $this->userSecurityKey && !$this->userSecurityKey->hasPrivateKey()))) { || (null !== $this->userSecurityKey && !$this->userSecurityKey->hasPrivateKey()))) {
if (self::PASSWORD_TYPE_DIGEST === $this->passwordType) { if (self::PASSWORD_TYPE_DIGEST === $this->passwordType) {
$nonce = mt_rand(); $nonce = mt_rand();
$password = base64_encode(sha1($nonce . $createdTimestamp . $this->password, true)); $password = base64_encode(sha1($nonce . $createdTimestamp . $this->password, true));

View File

@ -56,7 +56,7 @@ class WsdlDownloader
/** /**
* Resolve WSDl/XSD includes. * Resolve WSDl/XSD includes.
* *
* @var boolean * @var bool
*/ */
protected $resolveRemoteIncludes = true; protected $resolveRemoteIncludes = true;
@ -64,13 +64,13 @@ class WsdlDownloader
* Constructor. * Constructor.
* *
* @param \BeSimple\SoapClient\Curl $curl Curl instance * @param \BeSimple\SoapClient\Curl $curl Curl instance
* @param boolean $resolveRemoteIncludes WSDL/XSD include enabled? * @param bool $resolveRemoteIncludes WSDL/XSD include enabled?
* @param boolean $cacheWsdl Cache constant * @param bool $cacheWsdl Cache constant
*/ */
public function __construct(Curl $curl, $resolveRemoteIncludes = true, $cacheWsdl = Cache::TYPE_DISK) public function __construct(Curl $curl, $resolveRemoteIncludes = true, $cacheWsdl = Cache::TYPE_DISK)
{ {
$this->curl = $curl; $this->curl = $curl;
$this->resolveRemoteIncludes = (Boolean) $resolveRemoteIncludes; $this->resolveRemoteIncludes = (bool) $resolveRemoteIncludes;
// get current WSDL caching config // get current WSDL caching config
$this->cacheEnabled = $cacheWsdl === Cache::TYPE_NONE ? Cache::DISABLED : Cache::ENABLED == Cache::isEnabled(); $this->cacheEnabled = $cacheWsdl === Cache::TYPE_NONE ? Cache::DISABLED : Cache::ENABLED == Cache::isEnabled();
@ -101,6 +101,20 @@ class WsdlDownloader
if ($responseSuccessfull) { if ($responseSuccessfull) {
$response = $this->curl->getResponseBody(); $response = $this->curl->getResponseBody();
libxml_use_internal_errors(true);
$doc = simplexml_load_string($response);
if (!$doc) {
$errors = libxml_get_errors();
if (count($errors)) {
throw new \Exception('There is something wrong with the WSDL file formatting. The file can\'t be downloaded to be cached.');
}
libxml_clear_errors();
}
if ($this->resolveRemoteIncludes) { if ($this->resolveRemoteIncludes) {
$this->resolveRemoteIncludes($response, $cacheFilePath, $wsdl); $this->resolveRemoteIncludes($response, $cacheFilePath, $wsdl);
} else { } else {
@ -130,7 +144,7 @@ class WsdlDownloader
* *
* @param string $file File URL/path * @param string $file File URL/path
* *
* @return boolean * @return bool
*/ */
private function isRemoteFile($file) private function isRemoteFile($file)
{ {
@ -149,9 +163,7 @@ class WsdlDownloader
* *
* @param string $xml XML file * @param string $xml XML file
* @param string $cacheFilePath Cache file name * @param string $cacheFilePath Cache file name
* @param boolean $parentFilePath Parent file name * @param bool $parentFilePath Parent file name
*
* @return void
*/ */
private function resolveRemoteIncludes($xml, $cacheFilePath, $parentFilePath = null) private function resolveRemoteIncludes($xml, $cacheFilePath, $parentFilePath = null)
{ {
@ -214,7 +226,7 @@ class WsdlDownloader
$urlParts = parse_url($base); $urlParts = parse_url($base);
// combine base path with relative path // combine base path with relative path
if (isset($urlParts['path']) && '/' === $relative{0}) { if (isset($urlParts['path']) && '/' === $relative[0]) {
// $relative is absolute path from domain (starts with /) // $relative is absolute path from domain (starts with /)
$path = $relative; $path = $relative;
} elseif (isset($urlParts['path']) && strrpos($urlParts['path'], '/') === (strlen($urlParts['path']))) { } elseif (isset($urlParts['path']) && strrpos($urlParts['path'], '/') === (strlen($urlParts['path']))) {
@ -247,7 +259,7 @@ class WsdlDownloader
break; break;
} }
$keyToDelete--; --$keyToDelete;
} }
unset($parts[$key]); unset($parts[$key]);

View File

@ -65,6 +65,5 @@ class XmlMimeFilter implements SoapRequestFilter
} }
} }
} }
} }
} }

View File

@ -27,7 +27,7 @@ abstract class AbstractSoapBuilder
/** /**
* @return AbstractSoapBuilder * @return AbstractSoapBuilder
*/ */
static public function createWithDefaults() public static function createWithDefaults()
{ {
$builder = new static(); $builder = new static();

View File

@ -25,24 +25,24 @@ class Cache
const TYPE_MEMORY = WSDL_CACHE_MEMORY; const TYPE_MEMORY = WSDL_CACHE_MEMORY;
const TYPE_DISK_MEMORY = WSDL_CACHE_BOTH; const TYPE_DISK_MEMORY = WSDL_CACHE_BOTH;
static protected $types = array( protected static $types = array(
self::TYPE_NONE, self::TYPE_NONE,
self::TYPE_DISK, self::TYPE_DISK,
self::TYPE_MEMORY, self::TYPE_MEMORY,
self::TYPE_DISK_MEMORY, self::TYPE_DISK_MEMORY,
); );
static public function getTypes() public static function getTypes()
{ {
return self::$types; return self::$types;
} }
static public function isEnabled() public static function isEnabled()
{ {
return self::iniGet('soap.wsdl_cache_enabled'); return self::iniGet('soap.wsdl_cache_enabled');
} }
static public function setEnabled($enabled) public static function setEnabled($enabled)
{ {
if (!in_array($enabled, array(self::ENABLED, self::DISABLED), true)) { if (!in_array($enabled, array(self::ENABLED, self::DISABLED), true)) {
throw new \InvalidArgumentException(); throw new \InvalidArgumentException();
@ -51,12 +51,12 @@ class Cache
self::iniSet('soap.wsdl_cache_enabled', $enabled); self::iniSet('soap.wsdl_cache_enabled', $enabled);
} }
static public function getType() public static function getType()
{ {
return self::iniGet('soap.wsdl_cache'); return self::iniGet('soap.wsdl_cache');
} }
static public function setType($type) public static function setType($type)
{ {
if (!in_array($type, self::getTypes(), true)) { if (!in_array($type, self::getTypes(), true)) {
throw new \InvalidArgumentException('The cache type has to be either Cache::TYPE_NONE, Cache::TYPE_DISK, Cache::TYPE_MEMORY or Cache::TYPE_DISK_MEMORY'); throw new \InvalidArgumentException('The cache type has to be either Cache::TYPE_NONE, Cache::TYPE_DISK, Cache::TYPE_MEMORY or Cache::TYPE_DISK_MEMORY');
@ -65,12 +65,12 @@ class Cache
self::iniSet('soap.wsdl_cache', $type); self::iniSet('soap.wsdl_cache', $type);
} }
static public function getDirectory() public static function getDirectory()
{ {
return self::iniGet('soap.wsdl_cache_dir'); return self::iniGet('soap.wsdl_cache_dir');
} }
static public function setDirectory($directory) public static function setDirectory($directory)
{ {
if (!is_dir($directory)) { if (!is_dir($directory)) {
mkdir($directory, 0777, true); mkdir($directory, 0777, true);
@ -79,32 +79,32 @@ class Cache
self::iniSet('soap.wsdl_cache_dir', $directory); self::iniSet('soap.wsdl_cache_dir', $directory);
} }
static public function getLifetime() public static function getLifetime()
{ {
return self::iniGet('soap.wsdl_cache_ttl'); return self::iniGet('soap.wsdl_cache_ttl');
} }
static public function setLifetime($lifetime) public static function setLifetime($lifetime)
{ {
self::iniSet('soap.wsdl_cache_ttl', $lifetime); self::iniSet('soap.wsdl_cache_ttl', $lifetime);
} }
static public function getLimit() public static function getLimit()
{ {
return self::iniGet('soap.wsdl_cache_limit'); return self::iniGet('soap.wsdl_cache_limit');
} }
static public function setLimit($limit) public static function setLimit($limit)
{ {
self::iniSet('soap.wsdl_cache_limit', $limit); self::iniSet('soap.wsdl_cache_limit', $limit);
} }
static protected function iniGet($key) protected static function iniGet($key)
{ {
return ini_get($key); return ini_get($key);
} }
static protected function iniSet($key, $value) protected static function iniSet($key, $value)
{ {
ini_set($key, $value); ini_set($key, $value);
} }

View File

@ -44,4 +44,3 @@ class DateTimeTypeConverter implements TypeConverterInterface
return sprintf('<%1$s>%2$s</%1$s>', $this->getTypeName(), $data->format('Y-m-d\TH:i:sP')); return sprintf('<%1$s>%2$s</%1$s>', $this->getTypeName(), $data->format('Y-m-d\TH:i:sP'));
} }
} }

View File

@ -44,4 +44,3 @@ class DateTypeConverter implements TypeConverterInterface
return sprintf('<%1$s>%2$s</%1$s>', $this->getTypeName(), $data->format('Y-m-d')); return sprintf('<%1$s>%2$s</%1$s>', $this->getTypeName(), $data->format('Y-m-d'));
} }
} }

View File

@ -65,10 +65,8 @@ class MtomTypeConverter implements TypeConverterInterface, SoapKernelAwareInterf
$contentId = urldecode(substr($ref, 4)); $contentId = urldecode(substr($ref, 4));
if (null !== ($part = $this->soapKernel->getAttachment($contentId))) { if (null !== ($part = $this->soapKernel->getAttachment($contentId))) {
return $part->getContent(); return $part->getContent();
} else { } else {
return null; return null;
} }
} }

View File

@ -28,5 +28,5 @@ interface SoapKernelAwareInterface
* *
* @return void * @return void
*/ */
function setKernel(SoapKernel $soapKernel); public function setKernel(SoapKernel $soapKernel);
} }

View File

@ -61,10 +61,8 @@ class SwaTypeConverter implements TypeConverterInterface, SoapKernelAwareInterfa
$contentId = urldecode(substr($ref, 4)); $contentId = urldecode(substr($ref, 4));
if (null !== ($part = $this->soapKernel->getAttachment($contentId))) { if (null !== ($part = $this->soapKernel->getAttachment($contentId))) {
return $part->getContent(); return $part->getContent();
} else { } else {
return null; return null;
} }
} }

View File

@ -24,14 +24,14 @@ interface TypeConverterInterface
* *
* @return string * @return string
*/ */
function getTypeNamespace(); public function getTypeNamespace();
/** /**
* Get type name. * Get type name.
* *
* @return string * @return string
*/ */
function getTypeName(); public function getTypeName();
/** /**
* Convert given XML string to PHP type. * Convert given XML string to PHP type.
@ -40,7 +40,7 @@ interface TypeConverterInterface
* *
* @return mixed * @return mixed
*/ */
function convertXmlToPhp($data); public function convertXmlToPhp($data);
/** /**
* Convert PHP type to XML string. * Convert PHP type to XML string.
@ -49,5 +49,5 @@ interface TypeConverterInterface
* *
* @return string * @return string
*/ */
function convertPhpToXml($data); public function convertPhpToXml($data);
} }

View File

@ -25,7 +25,7 @@ class Message
public function __construct($name) public function __construct($name)
{ {
$this->name = $name; $this->name = $name;
$this->parts = array(); $this->parts = [];
} }
public function getName() public function getName()
@ -48,13 +48,13 @@ class Message
return 0 === count($this->parts) ? true : false; return 0 === count($this->parts) ? true : false;
} }
public function add($name, $phpType, $nillable = false, $attribute = false) public function add($name, $phpType, $nillable = false, $minOccurs = 1)
{ {
if ($phpType instanceof TypeInterface) { if ($phpType instanceof TypeInterface) {
$phpType = $phpType->getPhpType(); $phpType = $phpType->getPhpType();
} }
$this->parts[$name] = new Part($name, $phpType, $nillable, $attribute); $this->parts[$name] = new Part($name, $phpType, $nillable, $minOccurs);
return $this; return $this;
} }

View File

@ -12,8 +12,6 @@
namespace BeSimple\SoapCommon\Definition; namespace BeSimple\SoapCommon\Definition;
use BeSimple\SoapCommon\Definition\Type\TypeRepository;
/** /**
* @author Francis Besset <francis.besset@gmail.com> * @author Francis Besset <francis.besset@gmail.com>
*/ */
@ -53,7 +51,7 @@ class Method
public function getUse() public function getUse()
{ {
return \SOAP_ENCODED; return \SOAP_LITERAL;
} }
public function addHeader($name, $type) public function addHeader($name, $type)
@ -68,11 +66,7 @@ class Method
public function setOutput($type, $name = 'return') public function setOutput($type, $name = 'return')
{ {
if ('return' !== $name) { $this->output->add('return', $type);
$this->output = new Message($name);
}
$this->output->add($name, $type);
} }
public function getHeaders() public function getHeaders()

View File

@ -20,14 +20,14 @@ class Part
protected $name; protected $name;
protected $type; protected $type;
protected $nillable; protected $nillable;
protected $attribute; protected $minOccurs;
public function __construct($name, $type, $nillable = false, $attribute = false) public function __construct($name, $type, $nillable = false, $minOccurs = 1)
{ {
$this->name = $name; $this->name = $name;
$this->type = $type; $this->type = $type;
$this->minOccurs = $minOccurs;
$this->setNillable($nillable); $this->setNillable($nillable);
$this->setAttribute($attribute);
} }
public function getName() public function getName()
@ -35,26 +35,6 @@ class Part
return $this->name; 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() public function getType()
{ {
return $this->type; return $this->type;
@ -72,6 +52,16 @@ class Part
public function setNillable($nillable) public function setNillable($nillable)
{ {
$this->nillable = (boolean) $nillable; $this->nillable = (bool) $nillable;
}
public function setMinOccurs($minOccurs)
{
$this->minOccurs = $minOccurs;
}
public function getMinOccurs()
{
return $this->minOccurs;
} }
} }

View File

@ -172,7 +172,8 @@ class Helper
return sprintf( return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x', '%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 32 bits for "time_low" // 32 bits for "time_low"
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
// 16 bits for "time_mid" // 16 bits for "time_mid"
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
// 16 bits for "time_hi_and_version", // 16 bits for "time_hi_and_version",
@ -183,7 +184,9 @@ class Helper
// two most significant bits holds zero and one for variant DCE1.1 // two most significant bits holds zero and one for variant DCE1.1
mt_rand(0, 0x3fff) | 0x8000, mt_rand(0, 0x3fff) | 0x8000,
// 48 bits for "node" // 48 bits for "node"
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff) mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff)
); );
} }

View File

@ -47,7 +47,7 @@ abstract class SoapMessage
* *
* @var array(string=>string) * @var array(string=>string)
*/ */
static protected $versionToContentTypeMap = array( protected static $versionToContentTypeMap = array(
SOAP_1_1 => 'text/xml; charset=utf-8', SOAP_1_1 => 'text/xml; charset=utf-8',
SOAP_1_2 => 'application/soap+xml; charset=utf-8' SOAP_1_2 => 'application/soap+xml; charset=utf-8'
); );

View File

@ -22,5 +22,4 @@ use BeSimple\SoapCommon\SoapMessage;
*/ */
class SoapRequest extends SoapMessage class SoapRequest extends SoapMessage
{ {
} }

View File

@ -22,5 +22,4 @@ use BeSimple\SoapCommon\SoapMessage;
*/ */
class SoapResponse extends SoapMessage class SoapResponse extends SoapMessage
{ {
} }

View File

@ -51,4 +51,3 @@ class DateTimeTypeConverterTest extends \PHPUnit_Framework_TestCase
$this->assertNull($date); $this->assertNull($date);
} }
} }

View File

@ -49,4 +49,3 @@ class DateTypeConverterTest extends \PHPUnit_Framework_TestCase
$this->assertNull($date); $this->assertNull($date);
} }
} }

View File

@ -338,7 +338,6 @@ abstract class WsSecurityFilterClientServer
return XmlSecurityKey::factory($algorithm, $key, false, XmlSecurityKey::TYPE_PRIVATE); return XmlSecurityKey::factory($algorithm, $key, false, XmlSecurityKey::TYPE_PRIVATE);
} elseif (Helper::NS_WSS === $referencedNode->namespaceURI } elseif (Helper::NS_WSS === $referencedNode->namespaceURI
&& 'BinarySecurityToken' == $referencedNode->localName) { && 'BinarySecurityToken' == $referencedNode->localName) {
$key = XmlSecurityPem::formatKeyInPemFormat($referencedNode->textContent); $key = XmlSecurityPem::formatKeyInPemFormat($referencedNode->textContent);
return XmlSecurityKey::factory(XmlSecurityKey::RSA_SHA1, $key, false, XmlSecurityKey::TYPE_PUBLIC); return XmlSecurityKey::factory(XmlSecurityKey::RSA_SHA1, $key, false, XmlSecurityKey::TYPE_PUBLIC);

View File

@ -100,34 +100,6 @@ class SoapServer extends \SoapServer
parent::handle($soapRequest->getContent()); parent::handle($soapRequest->getContent());
$response = ob_get_clean(); $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 // Remove headers added by SoapServer::handle() method
header_remove('Content-Length'); header_remove('Content-Length');
header_remove('Content-Type'); header_remove('Content-Type');
@ -159,9 +131,7 @@ class SoapServer extends \SoapServer
/** /**
* Configure filter and type converter for SwA/MTOM. * Configure filter and type converter for SwA/MTOM.
* *
* @param array &$options SOAP constructor options array. * @param array &$options SOAP constructor options array
*
* @return void
*/ */
private function configureMime(array &$options) private function configureMime(array &$options)
{ {

View File

@ -33,7 +33,7 @@ class SoapServerBuilder extends AbstractSoapBuilder
* *
* @return \BeSimple\SoapServer\SoapServerBuilder * @return \BeSimple\SoapServer\SoapServerBuilder
*/ */
static public function createWithDefaults() public static function createWithDefaults()
{ {
return parent::createWithDefaults() return parent::createWithDefaults()
->withErrorReporting(false); ->withErrorReporting(false);

View File

@ -65,6 +65,5 @@ class XmlMimeFilter implements SoapResponseFilter
} }
} }
} }
} }
} }

View File

@ -61,7 +61,7 @@ abstract class AbstractVersion implements VersionInterface
{ {
if (!$this->bindingNode) { if (!$this->bindingNode) {
$this->bindingNode = $this->document->createElement('binding'); $this->bindingNode = $this->document->createElement('binding');
$this->bindingNode->setAttribute('name', $this->name.'_SOAP'); $this->bindingNode->setAttribute('name', $this->name.'Binding');
$this->bindingNode->setAttribute('type', $this->portTypeName); $this->bindingNode->setAttribute('type', $this->portTypeName);
$this->addSoapBinding(); $this->addSoapBinding();
@ -75,7 +75,7 @@ abstract class AbstractVersion implements VersionInterface
if (!$this->servicePortNode) { if (!$this->servicePortNode) {
$this->servicePortNode = $this->document->createElement('port'); $this->servicePortNode = $this->document->createElement('port');
$this->servicePortNode->setAttribute('name', $this->name.'Port'); $this->servicePortNode->setAttribute('name', $this->name.'Port');
$this->servicePortNode->setAttribute('binding', $this->typeNs.':'.$this->name.'_SOAP'); $this->servicePortNode->setAttribute('binding', $this->typeNs.':'.$this->name.'Binding');
$this->addSoapAddress(); $this->addSoapAddress();
} }

View File

@ -54,7 +54,7 @@ class Dumper
protected $domService; protected $domService;
protected $domPortType; protected $domPortType;
public function __construct(Definition $definition, array $options = array()) public function __construct(Definition $definition, array $options = [])
{ {
$this->definition = $definition; $this->definition = $definition;
$this->document = new \DOMDocument('1.0', 'utf-8'); $this->document = new \DOMDocument('1.0', 'utf-8');
@ -64,15 +64,15 @@ class Dumper
public function setOptions(array $options) public function setOptions(array $options)
{ {
$this->options = array( $this->options = [
'version11_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version11', 'version11_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version11',
'version12_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version12', 'version12_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version12',
'version11_name' => $this->definition->getName(), 'version11_name' => $this->definition->getName(),
'version12_name' => $this->definition->getName() . '12', 'version12_name' => $this->definition->getName() . '12',
'stylesheet' => null, 'stylesheet' => null,
); ];
$invalid = array(); $invalid = [];
foreach ($options as $key => $value) { foreach ($options as $key => $value) {
if (array_key_exists($key, $this->options)) { if (array_key_exists($key, $this->options)) {
$this->options[$key] = $value; $this->options[$key] = $value;
@ -114,7 +114,7 @@ class Dumper
$this->addMethods(); $this->addMethods();
$this->addService(); $this->addService();
foreach (array($this->version11, $this->version12) as $version) { foreach ([$this->version11, $this->version12] as $version) {
if (!$version) { if (!$version) {
continue; continue;
} }
@ -203,9 +203,9 @@ class Dumper
$partElement->setAttribute('name', $part->getName()); $partElement->setAttribute('name', $part->getName());
if ($type instanceof ComplexType) { if ($type instanceof ComplexType) {
$partElement->setAttribute('element', static::TYPES_NS.':'.$type->getXmlType()); $partElement->setAttribute('type', static::TYPES_NS . ':' . $type->getXmlType());
} else { } else {
$partElement->setAttribute('element', $type); $partElement->setAttribute('type', $type);
} }
$messageElement->appendChild($partElement); $messageElement->appendChild($partElement);
@ -217,13 +217,11 @@ class Dumper
protected function addComplexTypes() protected function addComplexTypes()
{ {
$types = $this->document->createElement(static::WSDL_NS . ':types'); $types = $this->document->createElement('types');
$this->domDefinitions->appendChild($types); $this->domDefinitions->appendChild($types);
$this->domSchema = $this->document->createElement(static::XSD_NS . ':schema'); $this->domSchema = $this->document->createElement(static::XSD_NS . ':schema');
$this->domSchema->setAttribute('targetNamespace', $this->definition->getNamespace()); $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); $types->appendChild($this->domSchema);
foreach ($this->definition->getTypeRepository()->getComplexTypes() as $type) { foreach ($this->definition->getTypeRepository()->getComplexTypes() as $type) {
@ -238,18 +236,13 @@ class Dumper
$complexType = $this->document->createElement(static::XSD_NS . ':complexType'); $complexType = $this->document->createElement(static::XSD_NS . ':complexType');
$complexType->setAttribute('name', $type->getXmlType()); $complexType->setAttribute('name', $type->getXmlType());
$all = $this->document->createElement(static::XSD_NS.':'.'sequence'); $all = $this->document->createElement(static::XSD_NS . ':' . ($type instanceof ArrayOfType ? 'sequence' : 'all'));
$complexType->appendChild($all); $complexType->appendChild($all);
foreach ($type->all() as $child) { foreach ($type->all() as $child) {
$isArray = false;
$childType = $this->definition->getTypeRepository()->getType($child->getType()); $childType = $this->definition->getTypeRepository()->getType($child->getType());
if ($child->isAttribute()) {
$element = $this->document->createElement(static::XSD_NS.':attribute');
} else {
$element = $this->document->createElement(static::XSD_NS . ':element'); $element = $this->document->createElement(static::XSD_NS . ':element');
}
$element->setAttribute('name', $child->getName()); $element->setAttribute('name', $child->getName());
if ($childType instanceof ComplexType) { if ($childType instanceof ComplexType) {
@ -264,23 +257,20 @@ class Dumper
} }
if ($child->isNillable()) { if ($child->isNillable()) {
$element->setAttribute('minOccurs', 0); $element->setAttribute('nillable', 'true');
} else {
$element->setAttribute('minOccurs', 1);
} }
if ($type instanceof ArrayOfType || $isArray) { if ($type instanceof ArrayOfType) {
$element->setAttribute('minOccurs', 0); $element->setAttribute('minOccurs', 0);
$element->setAttribute('maxOccurs', 'unbounded'); $element->setAttribute('maxOccurs', 'unbounded');
} else {
$element->setAttribute('maxOccurs', 1);
} }
if ($child->isAttribute()) { // 1 is the default value of minOccurs.
$complexType->appendChild($element); if (1 != $child->getMinOccurs()) {
} else { $element->setAttribute('minOccurs', $child->getMinOccurs());
$all->appendChild($element);
} }
$all->appendChild($element);
} }
$this->domSchema->appendChild($complexType); $this->domSchema->appendChild($complexType);
@ -299,7 +289,7 @@ class Dumper
$operation = $this->document->createElement('operation'); $operation = $this->document->createElement('operation');
$operation->setAttribute('name', $method->getName()); $operation->setAttribute('name', $method->getName());
foreach (array('input' => $method->getInput(), 'output' => $method->getOutput(), 'fault' => $method->getFault()) as $type => $message) { foreach (['input' => $method->getInput(), 'output' => $method->getOutput(), 'fault' => $method->getFault()] as $type => $message) {
if ('fault' === $type && $message->isEmpty()) { if ('fault' === $type && $message->isEmpty()) {
continue; continue;
} }