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
phpunit.xml
.idea
.php_cs.cache

View File

@ -26,7 +26,7 @@
"ass/xmlsecurity": "~1.0",
"symfony/framework-bundle": "~3.4|~4.0",
"symfony/twig-bundle": "~3.4|~4.0",
"zendframework/zend-mime": "2.1.*"
"laminas/laminas-mime": "~2.1"
},
"replace": {
"besimple/soap-bundle": "self.version",
@ -47,7 +47,7 @@
},
"extra": {
"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 Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Debug\Exception\FlattenException;
@ -59,7 +58,7 @@ class SoapWebServiceController implements ContainerAwareInterface
/**
* @var array
*/
private $headers = array();
private $headers = [];
/**
* @return \BeSimple\SoapBundle\Soap\SoapResponse
@ -94,16 +93,16 @@ class SoapWebServiceController implements ContainerAwareInterface
*/
public function definitionAction($webservice)
{
$routeName = $webservice . '_webservice_call';
$routeName = $webservice.'_webservice_call';
$result = $this->container->get('router')->getRouteCollection()->get($routeName);
if ($result === null) {
if (null === $result) {
$routeName = '_webservice_call';
}
$response = new Response($this->getWebServiceContext($webservice)->getWsdlFileContent(
$this->container->get('router')->generate(
$routeName,
array('webservice' => $webservice),
['webservice' => $webservice],
UrlGeneratorInterface::ABSOLUTE_URL
)
));
@ -137,12 +136,12 @@ class SoapWebServiceController implements ContainerAwareInterface
$view = '@Twig/Exception/'.($this->container->get('kernel')->isDebug() ? 'exception' : 'error').'.txt.twig';
$code = $exception->getStatusCode();
$details = $this->container->get('twig')->render($view, array(
$details = $this->container->get('twig')->render($view, [
'status_code' => $code,
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',
'exception' => $exception,
'logger' => $logger,
));
]);
$handler = new ExceptionHandler($exception, $details);
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
*

View File

@ -48,7 +48,7 @@ class TypeRepository
public function fixTypeInformation(ServiceDefinition $definition)
{
foreach($definition->getAllTypes() as $type) {
foreach ($definition->getAllTypes() as $type) {
$phpType = $type->getPhpType();
$xmlType = $type->getXmlType();

View File

@ -60,7 +60,7 @@ class BeSimpleSoapExtension extends Extension
$container->setParameter('besimple.soap.definition.dumper.options.stylesheet', $config['wsdl_dumper']['stylesheet']);
foreach($config['services'] as $name => $serviceConfig) {
foreach ($config['services'] as $name => $serviceConfig) {
$serviceConfig['name'] = $name;
$this->createWebServiceContext($serviceConfig, $container);
}
@ -152,11 +152,12 @@ class BeSimpleSoapExtension extends Extension
$definition = new ChildDefinition('besimple.soap.client');
$container->setDefinition(sprintf('besimple.soap.client.%s', $client), $definition);
if (3 === Kernel::MAJOR_VERSION) {
if (Kernel::MAJOR_VERSION >= 3) {
$definition->setFactory(array(
new Reference(sprintf('besimple.soap.client.builder.%s', $client)),
'build'
));
$definition->setPublic(true);
} else {
$definition->setFactoryService(sprintf('besimple.soap.client.builder.%s', $client));
}

View File

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

View File

@ -19,7 +19,9 @@
<argument type="service" id="besimple.soap.cache" /> <!-- hack to load besimple cache configuration -->
</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" />
</services>

View File

@ -20,14 +20,14 @@ class DocumentLiteralWrappedRequestMessageBinder implements MessageBinderInterfa
{
public function processMessage(Method $messageDefinition, $message, TypeRepository $typeRepository)
{
if(count($message) > 1) {
if (count($message) > 1) {
throw new \InvalidArgumentException();
}
$result = array();
$message = $message[0];
foreach($messageDefinition->getInput()->all() as $argument) {
foreach ($messageDefinition->getInput()->all() as $argument) {
$result[$argument->getName()] = $message;
}

View File

@ -24,5 +24,5 @@ interface MessageBinderInterface
*
* @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;
$array = array();
$phpType = substr($type->getPhpType(), 0, strlen($type->getPhpType()) - 2);
$type = $this->typeRepository->getType($phpType);
$type = $this->typeRepository->getType($type->get('item')->getType());
}
// @TODO Fix array reference
@ -79,21 +78,6 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
$array = $assocArray;
}
}
if (is_array($message)) {
foreach ($message as $complexType) {
$array[] = $this->checkComplexType($phpType, $complexType);
}
// See https://github.com/BeSimple/BeSimpleSoapBundle/issues/29
if (in_array('BeSimple\SoapCommon\Type\AbstractKeyValue', class_parents($phpType))) {
$assocArray = array();
foreach ($array as $keyValue) {
$assocArray[$keyValue->getKey()] = $keyValue->getValue();
}
$array = $assocArray;
}
}
$message = $array;
} else {

View File

@ -44,7 +44,8 @@ class ServiceBinder
* @param MessageBinderInterface $requestMessageBinder
* @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->requestHeaderMessageBinder = $requestHeaderMessageBinder;

View File

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

View File

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

View File

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

View File

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

View File

@ -138,7 +138,7 @@ class AnnotationClassLoader extends Loader
*/
private function getController(\ReflectionClass $class, \ReflectionMethod $method, Annotation\Method $annotation)
{
if(null !== $annotation->getService()) {
if (null !== $annotation->getService()) {
return $annotation->getService() . ':' . $method->name;
} else {
return $class->name . '::' . $method->name;
@ -160,7 +160,7 @@ class AnnotationClassLoader extends Loader
$loaded = $complexTypeResolver->load($phpType);
$complexType = new ComplexType($phpType, isset($loaded['alias']) ? $loaded['alias'] : $phpType);
foreach ($loaded['properties'] as $name => $property) {
$complexType->add($name, $this->loadType($property->getValue()), $property->isNillable(), $property->isAttribute());
$complexType->add($name, $this->loadType($property->getValue()), $property->isNillable(), $property->getMinOccurs());
}
$this->typeRepository->addComplexType($complexType);

View File

@ -43,7 +43,7 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
throw new \InvalidArgumentException(sprintf('Class "%s" does not exist.', $class));
}
$annotations = array();
$annotations = [];
$class = new \ReflectionClass($class);
if ($alias = $this->reader->getClassAnnotation($class, $this->aliasClass)) {
@ -58,8 +58,8 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
$propertyComplexType = new ComplexType();
$propertyComplexType->setValue($complexType->getValue());
$propertyComplexType->setNillable($complexType->isNillable());
$propertyComplexType->setIsAttribute($complexType->isAttribute());
$propertyComplexType->setName($property->getName());
$propertyComplexType->setMinOccurs($complexType->getMinOccurs());
$annotations['properties']->add($propertyComplexType);
}
}
@ -73,7 +73,7 @@ class AnnotationComplexTypeLoader extends AnnotationClassLoader
* @param mixed $resource A resource
* @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)
{

View File

@ -12,7 +12,7 @@ namespace BeSimple\SoapBundle\Soap;
use BeSimple\SoapBundle\Util\Collection;
use Symfony\Component\HttpFoundation\Request;
use Zend\Mime\Message;
use Laminas\Mime\Message;
/**
* SoapRequest.
@ -69,7 +69,7 @@ class SoapRequest extends Request
*/
public function getSoapMessage()
{
if(null === $this->soapMessage) {
if (null === $this->soapMessage) {
$this->soapMessage = $this->initializeSoapMessage();
}
@ -88,12 +88,12 @@ class SoapRequest extends Request
protected function initializeSoapMessage()
{
if($this->server->has('CONTENT_TYPE')) {
if ($this->server->has('CONTENT_TYPE')) {
$type = $this->splitContentTypeHeader($this->server->get('CONTENT_TYPE'));
switch($type['_type']) {
switch ($type['_type']) {
case 'multipart/related':
if($type['type'] == 'application/xop+xml') {
if ($type['type'] == 'application/xop+xml') {
return $this->initializeMtomSoapMessage($type, $this->getContent());
} else {
//log error
@ -114,7 +114,7 @@ class SoapRequest extends Request
protected function initializeMtomSoapMessage(array $contentTypeHeader, $content)
{
if(!isset($contentTypeHeader['start']) || !isset($contentTypeHeader['start-info']) || !isset($contentTypeHeader['boundary'])) {
if (!isset($contentTypeHeader['start']) || !isset($contentTypeHeader['start-info']) || !isset($contentTypeHeader['boundary'])) {
throw new \InvalidArgumentException();
}
@ -129,11 +129,11 @@ class SoapRequest extends Request
// TODO: add more checks to achieve full compatibility to MTOM spec
// http://www.w3.org/TR/soap12-mtom/
if($rootPart->id != $soapMimePartId || $rootPartType['_type'] != 'application/xop+xml' || $rootPartType['type'] != $soapMimePartType) {
if ($rootPart->id != $soapMimePartId || $rootPartType['_type'] != 'application/xop+xml' || $rootPartType['type'] != $soapMimePartType) {
throw new \InvalidArgumentException();
}
foreach($mimeParts as $mimePart) {
foreach ($mimeParts as $mimePart) {
$this->soapAttachments->add(new SoapAttachment(
$mimePart->id,
$mimePart->type,
@ -153,7 +153,7 @@ class SoapRequest extends Request
$result['_type'] = array_shift($parts);
foreach($parts as $part) {
foreach ($parts as $part) {
list($key, $value) = explode('=', trim($part), 2);
$result[$key] = trim($value, '"');

View File

@ -21,7 +21,7 @@ class Assert
public static function thatArgument($name, $condition, $message = self::ARGUMENT_INVALID)
{
if(!$condition) {
if (!$condition) {
throw new \InvalidArgumentException(sprintf($message, $name));
}
}

View File

@ -27,7 +27,7 @@ class BsString
*/
public static function startsWith($str, $substr)
{
if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) {
if (is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) {
return $substr == substr($str, 0, strlen($substr));
}
}
@ -42,7 +42,7 @@ class BsString
*/
public static function endsWith($str, $substr)
{
if(is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) {
if (is_string($str) && is_string($substr) && strlen($str) >= strlen($substr)) {
return $substr == substr($str, strlen($str) - strlen($substr));
}
}

View File

@ -68,10 +68,10 @@ class WebServiceContext
public function getWsdlFile($endpoint = null)
{
$file = sprintf ('%s/%s.%s.wsdl', $this->options['cache_dir'], $this->options['name'], md5($endpoint));
$file = sprintf('%s/%s.%s.wsdl', $this->options['cache_dir'], $this->options['name'], md5($endpoint));
$cache = new ConfigCache($file, $this->options['debug']);
if(!$cache->isFresh()) {
if (!$cache->isFresh()) {
$definition = $this->getServiceDefinition();
if ($endpoint) {
@ -79,10 +79,7 @@ class WebServiceContext
}
$dumper = new Dumper($definition, array('stylesheet' => $this->options['wsdl_stylesheet']));
$wsdl = $dumper->dump();
$cache->write($wsdl);
$cache->write($dumper->dump());
}
return $cache->getPath();

View File

@ -77,9 +77,8 @@ class Curl
if (isset($options['compression']) && !($options['compression'] & SOAP_COMPRESSION_ACCEPT)) {
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 (false !== $options['proxy_host']) {
@ -167,7 +166,6 @@ class Curl
private function execManualRedirect($redirects = 0)
{
if ($redirects > $this->followLocationMaxRedirects) {
// TODO Redirection limit reached, aborting
return false;
}
@ -193,7 +191,7 @@ class Curl
if (!isset($url['path'])) {
$url['path'] = $lastUrl['path'];
}
$newUrl = $url['scheme'] . '://' . $url['host'] . $url['path'] . ($url['query'] ? '?' . $url['query'] : '');
$newUrl = $url['scheme'].'://'.$url['host'].$url['path'].($url['query'] ? '?'.$url['query'] : '');
curl_setopt($this->ch, CURLOPT_URL, $newUrl);
return $this->execManualRedirect($redirects++);
@ -205,7 +203,7 @@ class Curl
/**
* 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
*
@ -251,7 +249,6 @@ class Curl
$errorCodeMapping = $this->getErrorCodeMapping();
$errorNumber = curl_errno($this->ch);
if (isset($errorCodeMapping[$errorNumber])) {
return $errorCodeMapping[$errorNumber];
}

View File

@ -338,10 +338,10 @@ class SoapClient extends \SoapClient
$options['typemap'][] = array(
'type_name' => $converter->getTypeName(),
'type_ns' => $converter->getTypeNamespace(),
'from_xml' => function($input) use ($converter) {
'from_xml' => function ($input) use ($converter) {
return $converter->convertXmlToPhp($input);
},
'to_xml' => function($input) use ($converter) {
'to_xml' => function ($input) use ($converter) {
return $converter->convertPhpToXml($input);
},
);

View File

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

View File

@ -74,7 +74,7 @@ class WsSecurityUserPassAxisInteropTest extends TestCase
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $this->options);
$wssFilter = new BeSimpleWsSecurityFilter(true, 600);
$wssFilter->addUserData( 'libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_DIGEST );
$wssFilter->addUserData('libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_DIGEST);
$soapKernel = $sc->getSoapKernel();
$soapKernel->registerFilter($wssFilter);

View File

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

View File

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

View File

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

View File

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

View File

@ -63,7 +63,7 @@ class WsSecurityUserPassServerInteropTest extends TestCase
$sc = new BeSimpleSoapClient(__DIR__.'/Fixtures/WsSecurityUserPass.wsdl', $this->options);
$wssFilter = new BeSimpleWsSecurityFilter(true, 600);
$wssFilter->addUserData( 'libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_DIGEST );
$wssFilter->addUserData('libuser', 'books', BeSimpleWsSecurityFilter::PASSWORD_TYPE_DIGEST);
$soapKernel = $sc->getSoapKernel();
$soapKernel->registerFilter($wssFilter);

View File

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

View File

@ -157,7 +157,6 @@ class WsAddressingFilter implements SoapRequestFilter, SoapResponseFilter
public function getReferenceParameter($ns, $parameter)
{
if (isset($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
&& (null === $this->userSecurityKey
|| (null !== $this->userSecurityKey && !$this->userSecurityKey->hasPrivateKey()))) {
if (self::PASSWORD_TYPE_DIGEST === $this->passwordType) {
$nonce = mt_rand();
$password = base64_encode(sha1($nonce . $createdTimestamp . $this->password, true));

View File

@ -56,7 +56,7 @@ class WsdlDownloader
/**
* Resolve WSDl/XSD includes.
*
* @var boolean
* @var bool
*/
protected $resolveRemoteIncludes = true;
@ -64,13 +64,13 @@ class WsdlDownloader
* Constructor.
*
* @param \BeSimple\SoapClient\Curl $curl Curl instance
* @param boolean $resolveRemoteIncludes WSDL/XSD include enabled?
* @param boolean $cacheWsdl Cache constant
* @param bool $resolveRemoteIncludes WSDL/XSD include enabled?
* @param bool $cacheWsdl Cache constant
*/
public function __construct(Curl $curl, $resolveRemoteIncludes = true, $cacheWsdl = Cache::TYPE_DISK)
{
$this->curl = $curl;
$this->resolveRemoteIncludes = (Boolean) $resolveRemoteIncludes;
$this->resolveRemoteIncludes = (bool) $resolveRemoteIncludes;
// get current WSDL caching config
$this->cacheEnabled = $cacheWsdl === Cache::TYPE_NONE ? Cache::DISABLED : Cache::ENABLED == Cache::isEnabled();
@ -101,19 +101,33 @@ class WsdlDownloader
if ($responseSuccessfull) {
$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) {
$this->resolveRemoteIncludes($response, $cacheFilePath, $wsdl);
} else {
file_put_contents($cacheFilePath, $response);
}
} else {
throw new \ErrorException("SOAP-ERROR: Parsing WSDL: Couldn't load from '" . $wsdl ."'");
throw new \ErrorException("SOAP-ERROR: Parsing WSDL: Couldn't load from '".$wsdl."'");
}
} elseif (file_exists($wsdl)) {
$response = file_get_contents($wsdl);
$this->resolveRemoteIncludes($response, $cacheFilePath);
} else {
throw new \ErrorException("SOAP-ERROR: Parsing WSDL: Couldn't load from '" . $wsdl ."'");
throw new \ErrorException("SOAP-ERROR: Parsing WSDL: Couldn't load from '".$wsdl."'");
}
}
@ -122,7 +136,7 @@ class WsdlDownloader
return realpath($wsdl);
}
throw new \ErrorException("SOAP-ERROR: Parsing WSDL: Couldn't load from '" . $wsdl ."'");
throw new \ErrorException("SOAP-ERROR: Parsing WSDL: Couldn't load from '".$wsdl."'");
}
/**
@ -130,7 +144,7 @@ class WsdlDownloader
*
* @param string $file File URL/path
*
* @return boolean
* @return bool
*/
private function isRemoteFile($file)
{
@ -149,9 +163,7 @@ class WsdlDownloader
*
* @param string $xml XML file
* @param string $cacheFilePath Cache file name
* @param boolean $parentFilePath Parent file name
*
* @return void
* @param bool $parentFilePath Parent file name
*/
private function resolveRemoteIncludes($xml, $cacheFilePath, $parentFilePath = null)
{
@ -214,10 +226,10 @@ class WsdlDownloader
$urlParts = parse_url($base);
// 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 /)
$path = $relative;
} elseif (isset($urlParts['path']) && strrpos($urlParts['path'], '/') === (strlen($urlParts['path']) )) {
} elseif (isset($urlParts['path']) && strrpos($urlParts['path'], '/') === (strlen($urlParts['path']))) {
// base path is directory
$path = $urlParts['path'].$relative;
} elseif (isset($urlParts['path'])) {
@ -247,7 +259,7 @@ class WsdlDownloader
break;
}
$keyToDelete--;
--$keyToDelete;
}
unset($parts[$key]);

View File

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

View File

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

View File

@ -25,24 +25,24 @@ class Cache
const TYPE_MEMORY = WSDL_CACHE_MEMORY;
const TYPE_DISK_MEMORY = WSDL_CACHE_BOTH;
static protected $types = array(
protected static $types = array(
self::TYPE_NONE,
self::TYPE_DISK,
self::TYPE_MEMORY,
self::TYPE_DISK_MEMORY,
);
static public function getTypes()
public static function getTypes()
{
return self::$types;
}
static public function isEnabled()
public static function isEnabled()
{
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)) {
throw new \InvalidArgumentException();
@ -51,12 +51,12 @@ class Cache
self::iniSet('soap.wsdl_cache_enabled', $enabled);
}
static public function getType()
public static function getType()
{
return self::iniGet('soap.wsdl_cache');
}
static public function setType($type)
public static function setType($type)
{
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');
@ -65,12 +65,12 @@ class Cache
self::iniSet('soap.wsdl_cache', $type);
}
static public function getDirectory()
public static function getDirectory()
{
return self::iniGet('soap.wsdl_cache_dir');
}
static public function setDirectory($directory)
public static function setDirectory($directory)
{
if (!is_dir($directory)) {
mkdir($directory, 0777, true);
@ -79,32 +79,32 @@ class Cache
self::iniSet('soap.wsdl_cache_dir', $directory);
}
static public function getLifetime()
public static function getLifetime()
{
return self::iniGet('soap.wsdl_cache_ttl');
}
static public function setLifetime($lifetime)
public static function setLifetime($lifetime)
{
self::iniSet('soap.wsdl_cache_ttl', $lifetime);
}
static public function getLimit()
public static function getLimit()
{
return self::iniGet('soap.wsdl_cache_limit');
}
static public function setLimit($limit)
public static function setLimit($limit)
{
self::iniSet('soap.wsdl_cache_limit', $limit);
}
static protected function iniGet($key)
protected static function iniGet($key)
{
return ini_get($key);
}
static protected function iniSet($key, $value)
protected static function iniSet($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'));
}
}

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'));
}
}

View File

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

View File

@ -28,5 +28,5 @@ interface SoapKernelAwareInterface
*
* @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));
if (null !== ($part = $this->soapKernel->getAttachment($contentId))) {
return $part->getContent();
} else {
return null;
}
}

View File

@ -74,10 +74,10 @@ class TypeConverterCollection
$typemap[] = array(
'type_name' => $converter->getTypeName(),
'type_ns' => $converter->getTypeNamespace(),
'from_xml' => function($input) use ($converter) {
'from_xml' => function ($input) use ($converter) {
return $converter->convertXmlToPhp($input);
},
'to_xml' => function($input) use ($converter) {
'to_xml' => function ($input) use ($converter) {
return $converter->convertPhpToXml($input);
},
);

View File

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

View File

@ -25,7 +25,7 @@ class Message
public function __construct($name)
{
$this->name = $name;
$this->parts = array();
$this->parts = [];
}
public function getName()
@ -48,13 +48,13 @@ class Message
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) {
$phpType = $phpType->getPhpType();
}
$this->parts[$name] = new Part($name, $phpType, $nillable, $attribute);
$this->parts[$name] = new Part($name, $phpType, $nillable, $minOccurs);
return $this;
}

View File

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

View File

@ -20,14 +20,14 @@ class Part
protected $name;
protected $type;
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->type = $type;
$this->minOccurs = $minOccurs;
$this->setNillable($nillable);
$this->setAttribute($attribute);
}
public function getName()
@ -35,26 +35,6 @@ class Part
return $this->name;
}
/**
* @return bool
*/
public function isAttribute()
{
return $this->attribute;
}
/**
* @param bool $attribute
*
* @return $this
*/
public function setAttribute($attribute)
{
$this->attribute = $attribute;
return $this;
}
public function getType()
{
return $this->type;
@ -72,6 +52,16 @@ class Part
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(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
// 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"
mt_rand(0, 0xffff),
// 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
mt_rand(0, 0x3fff) | 0x8000,
// 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)
*/
static protected $versionToContentTypeMap = array(
protected static $versionToContentTypeMap = array(
SOAP_1_1 => 'text/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
{
}

View File

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

View File

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

View File

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

View File

@ -131,13 +131,13 @@ class MultiPartTest extends \PHPUnit_Framework_TestCase
$mp->addPart($p2);
$withoutMain = array(
trim($p2->getHeader('Content-ID'),'<>') => $p2,
trim($p2->getHeader('Content-ID'), '<>') => $p2,
);
$this->assertEquals($withoutMain, $mp->getParts());
$withMain = array(
trim($p1->getHeader('Content-ID'),'<>') => $p1,
trim($p2->getHeader('Content-ID'),'<>') => $p2,
trim($p1->getHeader('Content-ID'), '<>') => $p1,
trim($p2->getHeader('Content-ID'), '<>') => $p2,
);
$this->assertEquals($withMain, $mp->getParts(true));
}

View File

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

View File

@ -62,7 +62,7 @@ class SoapRequest extends CommonSoapRequest
} else {
$url .= 'http://';
}
$url .= isset( $_SERVER['SERVER_NAME'] ) ? $_SERVER['SERVER_NAME'] : '';
$url .= isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : '';
if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80) {
$url .= ":{$_SERVER['SERVER_PORT']}";
}

View File

@ -100,34 +100,6 @@ class SoapServer extends \SoapServer
parent::handle($soapRequest->getContent());
$response = ob_get_clean();
$dom = \DOMDocument::loadXML($response);
/** @var \DOMElement $envelop */
$envelop = $dom->childNodes->item(0);
$ns1 = $envelop->getAttribute('xmlns:ns1');
$envelop->removeAttributeNS($ns1, 'ns1');
$envelop->prefix = 'soap';
$envelop->setAttribute('soap:encodingStyle', 'http://schemas.xmlsoap.org/soap/encoding/');
$envelop->setAttribute('xmlns:soapenc', 'http://schemas.xmlsoap.org/soap/encoding/');
$envelop->setAttribute('xmlns:xsd', 'http://www.w3.org/2001/XMLSchema');
$envelop->setAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
/** @var \DOMElement $body */
$body = $envelop->childNodes->item(0);
$body->prefix = 'soap';
/** @var \DOMElement $responseRoot */
$responseRoot = $body->childNodes->item(0);
$responseRoot->setAttribute('xmlns', $ns1);
$envelop->removeAttributeNS('http://schemas.xmlsoap.org/soap/envelope/', 'SOAP-ENV');
$envelop->removeAttributeNS('http://schemas.xmlsoap.org/soap/encoding/', 'SOAP-ENC');
$response = $dom->saveXML();
$response = preg_replace('/xsi:type="ns1:\w*"/', '', $response);
// Remove headers added by SoapServer::handle() method
header_remove('Content-Length');
header_remove('Content-Type');
@ -159,9 +131,7 @@ class SoapServer extends \SoapServer
/**
* Configure filter and type converter for SwA/MTOM.
*
* @param array &$options SOAP constructor options array.
*
* @return void
* @param array &$options SOAP constructor options array
*/
private function configureMime(array &$options)
{
@ -186,10 +156,10 @@ class SoapServer extends \SoapServer
$options['typemap'][] = array(
'type_name' => $converter->getTypeName(),
'type_ns' => $converter->getTypeNamespace(),
'from_xml' => function($input) use ($converter) {
'from_xml' => function ($input) use ($converter) {
return $converter->convertXmlToPhp($input);
},
'to_xml' => function($input) use ($converter) {
'to_xml' => function ($input) use ($converter) {
return $converter->convertPhpToXml($input);
},
);

View File

@ -33,7 +33,7 @@ class SoapServerBuilder extends AbstractSoapBuilder
*
* @return \BeSimple\SoapServer\SoapServerBuilder
*/
static public function createWithDefaults()
public static function createWithDefaults()
{
return parent::createWithDefaults()
->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) {
$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->addSoapBinding();
@ -75,7 +75,7 @@ abstract class AbstractVersion implements VersionInterface
if (!$this->servicePortNode) {
$this->servicePortNode = $this->document->createElement('port');
$this->servicePortNode->setAttribute('name', $this->name.'Port');
$this->servicePortNode->setAttribute('binding', $this->typeNs.':'.$this->name.'_SOAP');
$this->servicePortNode->setAttribute('binding', $this->typeNs.':'.$this->name.'Binding');
$this->addSoapAddress();
}

View File

@ -54,7 +54,7 @@ class Dumper
protected $domService;
protected $domPortType;
public function __construct(Definition $definition, array $options = array())
public function __construct(Definition $definition, array $options = [])
{
$this->definition = $definition;
$this->document = new \DOMDocument('1.0', 'utf-8');
@ -64,15 +64,15 @@ class Dumper
public function setOptions(array $options)
{
$this->options = array(
$this->options = [
'version11_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version11',
'version12_class' => 'BeSimple\\SoapWsdl\\Dumper\\Version12',
'version11_name' => $this->definition->getName(),
'version12_name' => $this->definition->getName().'12',
'version12_name' => $this->definition->getName() . '12',
'stylesheet' => null,
);
];
$invalid = array();
$invalid = [];
foreach ($options as $key => $value) {
if (array_key_exists($key, $this->options)) {
$this->options[$key] = $value;
@ -114,7 +114,7 @@ class Dumper
$this->addMethods();
$this->addService();
foreach (array($this->version11, $this->version12) as $version) {
foreach ([$this->version11, $this->version12] as $version) {
if (!$version) {
continue;
}
@ -143,7 +143,7 @@ class Dumper
protected function addService()
{
$this->domService = $this->document->createElement('service');
$this->domService->setAttribute('name', $this->definition->getName().'Service');
$this->domService->setAttribute('name', $this->definition->getName() . 'Service');
$this->domDefinitions->appendChild($this->domService);
@ -154,15 +154,15 @@ class Dumper
{
$this->domDefinitions = $this->document->createElement('definitions');
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS, static::WSDL_NS_URI);
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS.':'.static::TYPES_NS, $this->definition->getNamespace());
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS.':'.static::SOAP_NS, static::SOAP_NS_URI);
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS.':'.static::SOAP12_NS, static::SOAP12_NS_URI);
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS.':'.static::XSD_NS, static::XSD_NS_URI);
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS.':'.static::SOAP_ENC_NS, static::SOAP_ENC_URI);
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS.':'.static::WSDL_NS, static::WSDL_NS_URI);
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS . ':' . static::TYPES_NS, $this->definition->getNamespace());
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS . ':' . static::SOAP_NS, static::SOAP_NS_URI);
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS . ':' . static::SOAP12_NS, static::SOAP12_NS_URI);
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS . ':' . static::XSD_NS, static::XSD_NS_URI);
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS . ':' . static::SOAP_ENC_NS, static::SOAP_ENC_URI);
$this->domDefinitions->setAttributeNS(static::XML_NS_URI, static::XML_NS . ':' . static::WSDL_NS, static::WSDL_NS_URI);
foreach ($this->definition->getTypeRepository()->getXmlNamespaces() as $prefix => $uri) {
$this->domDefinitions->setAttributeNs(static::XML_NS_URI, static::XML_NS.':'.$prefix, $uri);
$this->domDefinitions->setAttributeNs(static::XML_NS_URI, static::XML_NS . ':' . $prefix, $uri);
}
$this->domDefinitions->setAttribute('name', $this->definition->getName());
@ -203,9 +203,9 @@ class Dumper
$partElement->setAttribute('name', $part->getName());
if ($type instanceof ComplexType) {
$partElement->setAttribute('element', static::TYPES_NS.':'.$type->getXmlType());
$partElement->setAttribute('type', static::TYPES_NS . ':' . $type->getXmlType());
} else {
$partElement->setAttribute('element', $type);
$partElement->setAttribute('type', $type);
}
$messageElement->appendChild($partElement);
@ -217,13 +217,11 @@ class Dumper
protected function addComplexTypes()
{
$types = $this->document->createElement(static::WSDL_NS . ':types');
$types = $this->document->createElement('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('elementFormDefault', 'unqualified');
$this->domSchema->setAttribute(static::XML_NS.':'.static::XSD_NS, static::XSD_NS_URI);
$types->appendChild($this->domSchema);
foreach ($this->definition->getTypeRepository()->getComplexTypes() as $type) {
@ -235,21 +233,16 @@ class Dumper
protected function addComplexType(ComplexType $type)
{
$complexType = $this->document->createElement(static::XSD_NS.':complexType');
$complexType = $this->document->createElement(static::XSD_NS . ':complexType');
$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);
foreach ($type->all() as $child) {
$isArray = false;
$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());
if ($childType instanceof ComplexType) {
@ -258,29 +251,26 @@ class Dumper
$name = $childType->getName();
}
$element->setAttribute('type', static::TYPES_NS.':'.$name);
$element->setAttribute('type', static::TYPES_NS . ':' . $name);
} else {
$element->setAttribute('type', $childType);
}
if ($child->isNillable()) {
$element->setAttribute('minOccurs', 0);
} else {
$element->setAttribute('minOccurs', 1);
$element->setAttribute('nillable', 'true');
}
if ($type instanceof ArrayOfType || $isArray) {
if ($type instanceof ArrayOfType) {
$element->setAttribute('minOccurs', 0);
$element->setAttribute('maxOccurs', 'unbounded');
} else {
$element->setAttribute('maxOccurs', 1);
}
if ($child->isAttribute()) {
$complexType->appendChild($element);
} else {
$all->appendChild($element);
// 1 is the default value of minOccurs.
if (1 != $child->getMinOccurs()) {
$element->setAttribute('minOccurs', $child->getMinOccurs());
}
$all->appendChild($element);
}
$this->domSchema->appendChild($complexType);
@ -289,7 +279,7 @@ class Dumper
protected function addPortType()
{
$this->domPortType = $this->document->createElement('portType');
$this->domPortType->setAttribute('name', $this->definition->getName().'PortType');
$this->domPortType->setAttribute('name', $this->definition->getName() . 'PortType');
$this->domDefinitions->appendChild($this->domPortType);
}
@ -299,13 +289,13 @@ class Dumper
$operation = $this->document->createElement('operation');
$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()) {
continue;
}
$node = $this->document->createElement($type);
$node->setAttribute('message', static::TYPES_NS.':'.$message->getName());
$node->setAttribute('message', static::TYPES_NS . ':' . $message->getName());
$operation->appendChild($node);
}
@ -341,7 +331,7 @@ class Dumper
static::TYPES_NS,
$this->options['version11_name'],
$this->definition->getNamespace(),
static::TYPES_NS.':'.$this->definition->getName().'PortType',
static::TYPES_NS . ':' . $this->definition->getName() . 'PortType',
$this->definition->getOption('location'),
$this->definition->getOption('style')
);
@ -358,7 +348,7 @@ class Dumper
static::TYPES_NS,
$this->options['version12_name'],
$this->definition->getNamespace(),
static::TYPES_NS.':'.$this->definition->getName().'PortType',
static::TYPES_NS . ':' . $this->definition->getName() . 'PortType',
$this->definition->getOption('location'),
$this->definition->getOption('style')
);