Used BeSimple\SoapCommon\Classmap for the webservice context

This commit is contained in:
Francis Besset
2011-10-12 21:08:59 +02:00
parent 4a7ec164e5
commit 70a85460c9
7 changed files with 38 additions and 25 deletions

View File

@ -18,21 +18,25 @@ use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader;
use BeSimple\SoapBundle\Util\Assert;
use BeSimple\SoapBundle\Util\QName;
use BeSimple\SoapCommon\Classmap;
/**
* @author Christian Kerl <christian-kerl@web.de>
*/
class WsdlDumper implements DumperInterface
{
private $loader;
private $classmap;
private $typeRepository;
private $options;
private $wsdl;
private $definition;
public function __construct(AnnotationComplexTypeLoader $loader, TypeRepository $typeRepository, array $options)
public function __construct(AnnotationComplexTypeLoader $loader, Classmap $classmap, TypeRepository $typeRepository, array $options)
{
$this->loader = $loader;
$this->classmap = $classmap;
$this->typeRepository = $typeRepository;
$this->options = $options;
}
@ -42,7 +46,7 @@ class WsdlDumper implements DumperInterface
Assert::thatArgumentNotNull('definition', $definition);
$this->definition = $definition;
$this->wsdl = new Wsdl($this->typeRepository, $definition->getName(), $definition->getNamespace(), new WsdlTypeStrategy($this->loader, $definition));
$this->wsdl = new Wsdl($this->typeRepository, $definition->getName(), $definition->getNamespace(), new WsdlTypeStrategy($this->loader, $this->classmap, $definition));
$port = $this->wsdl->addPortType($this->getPortTypeName());
$binding = $this->wsdl->addBinding($this->getBindingName(), $this->qualify($this->getPortTypeName()));

View File

@ -15,6 +15,8 @@ use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader;
use BeSimple\SoapBundle\ServiceDefinition\Strategy\ComplexType;
use BeSimple\SoapBundle\Util\String;
use BeSimple\SoapCommon\Classmap;
use Zend\Soap\Exception;
use Zend\Soap\Wsdl as BaseWsdl;
use Zend\Soap\Wsdl\Strategy;
@ -30,14 +32,16 @@ class WsdlTypeStrategy implements Strategy
private $context;
private $loader;
private $classmap;
private $definition;
private $typeStrategy;
private $arrayStrategy;
public function __construct(AnnotationComplexTypeLoader $loader, ServiceDefinition $definition)
public function __construct(AnnotationComplexTypeLoader $loader, Classmap $classmap, ServiceDefinition $definition)
{
$this->loader = $loader;
$this->classmap = $classmap;
$this->definition = $definition;
}
@ -86,7 +90,7 @@ class WsdlTypeStrategy implements Strategy
private function getTypeStrategy()
{
if (!$this->typeStrategy) {
$this->typeStrategy = new ComplexType($this->loader, $this->definition);
$this->typeStrategy = new ComplexType($this->loader, $this->classmap, $this->definition);
$this->typeStrategy->setContext($this->context);
}

View File

@ -12,6 +12,7 @@ namespace BeSimple\SoapBundle\ServiceDefinition\Strategy;
use BeSimple\SoapBundle\ServiceDefinition\Loader\AnnotationComplexTypeLoader;
use BeSimple\SoapCommon\Classmap;
use Zend\Soap\Wsdl;
use Zend\Soap\Wsdl\Strategy\AbstractStrategy;
@ -21,11 +22,13 @@ use Zend\Soap\Wsdl\Strategy\AbstractStrategy;
class ComplexType extends AbstractStrategy
{
private $loader;
private $classmap;
private $definition;
public function __construct(AnnotationComplexTypeLoader $loader, $definition)
public function __construct(AnnotationComplexTypeLoader $loader, Classmap $classmap, $definition)
{
$this->loader = $loader;
$this->classmap = $classmap;
$this->definition = $definition;
}
@ -50,6 +53,8 @@ class ComplexType extends AbstractStrategy
$soapTypeName = Wsdl::translateType($type);
$soapType = 'tns:'.$soapTypeName;
$this->classmap->add($soapTypeName, $type);
// Register type here to avoid recursion
$this->getContext()->addType($type, $soapType);