Fixed issue #5

This commit is contained in:
Francis Besset 2011-08-26 23:39:43 +02:00
parent 6290ea268a
commit ce5c46408a
5 changed files with 41 additions and 38 deletions

View File

@ -56,11 +56,9 @@ class SoapWebServiceController extends ContainerAware
$webServiceContext = $this->getWebServiceContext($webservice);
$this->serviceBinder = $webServiceContext->getServiceBinder();
//$this->serviceBinder->fixXmlRequestContent();
$this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request'));
//$this->soapRequest->setContent($this->serviceBinder->fixXmlRequestContent($this->soapRequest->getContent()));
$this->soapServer = $webServiceContext->getServerFactory()->create($this->soapRequest, $this->soapResponse);
$this->soapServer = $webServiceContext->getServerFactory()->create($this->soapRequest, new SoapResponse());
$this->soapServer->setObject($this);

View File

@ -40,7 +40,12 @@ class TypeRepository
Assert::thatArgumentNotNull('phpType', $phpType);
Assert::thatArgumentNotNull('xmlType', $xmlType);
$this->defaultTypeMap[$phpType] = $this->getQName($xmlType);
$this->defaultTypeMap[$phpType] = $xmlType;
}
public function getXmlTypeMapping($phpType)
{
return isset($this->defaultTypeMap[$phpType]) ? $this->defaultTypeMap[$phpType] : null;
}
public function fixTypeInformation(ServiceDefinition $definition)
@ -56,36 +61,10 @@ class TypeRepository
}
if (null === $xmlType) {
if (!isset($typeMap[$phpType])) {
$parts = explode('\\', $phpType);
$xmlTypeName = ucfirst(end($parts));
if (String::endsWith($phpType, self::ARRAY_SUFFIX)) {
$xmlTypeName = str_replace(self::ARRAY_SUFFIX, 'Array', $xmlTypeName);
$xmlType = $this->getXmlTypeMapping($phpType);
}
$typeMap[$phpType] = new QName($definition->getNamespace(), $xmlTypeName);
}
$xmlType = $typeMap[$phpType];
} else {
$xmlType = $this->getQName($xmlType);
}
$type->setXmlType((string) $xmlType);
$type->setXmlType($xmlType);
}
}
private function getQName($xmlType)
{
if (QName::isPrefixedQName($xmlType)) {
return QName::fromPrefixedQName($xmlType, array($this, 'getXmlNamespace'));
} else {
return QName::fromPackedQName($xmlType);
}
}
public function createComplexTypeMap(ServiceDefinition $definition)
{
}
}

View File

@ -47,6 +47,7 @@
<service id="besimple.soap.definition.dumper.wsdl.rpcliteral" class="%besimple.soap.definition.dumper.wsdl.rpcliteral.class%">
<argument type="service" id="besimple.soap.definition.loader.annot_complextype" />
<argument type="service" id="besimple.soap.type.repository" />
<argument type="collection">
<argument key="stylesheet">%besimple.soap.definition.dumper.options.stylesheet%</argument>
</argument>
@ -66,7 +67,7 @@
<argument>xsd:int</argument>
</call>
<call method="addDefaultTypeMapping">
<argument>bool</argument>
<argument>boolean</argument>
<argument>xsd:boolean</argument>
</call>
<call method="addDefaultTypeMapping">
@ -74,7 +75,7 @@
<argument>xsd:float</argument>
</call>
<call method="addDefaultTypeMapping">
<argument>DateTime</argument>
<argument>dateTime</argument>
<argument>xsd:dateTime</argument>
</call>
</service>

View File

@ -10,6 +10,8 @@
namespace BeSimple\SoapBundle\ServiceDefinition\Dumper;
use BeSimple\SoapBundle\Converter\TypeRepository;
use BeSimple\SoapBundle\ServiceDefinition\Type;
use Zend\Soap\Wsdl as BaseWsdl;
/**
@ -17,6 +19,26 @@ use Zend\Soap\Wsdl as BaseWsdl;
*/
class Wsdl extends BaseWsdl
{
private $typeRepository;
public function __construct(TypeRepository $typeRepository, $name, $uri, $strategy = true)
{
$this->typeRepository = $typeRepository;
parent::__construct($name, $uri, $strategy);
}
public function getType($type)
{
if ($type instanceof Type) {
$xmlType = $type->getXmlType();
} else {
$xmlType = $this->typeRepository->getXmlTypeMapping($type);
}
return $xmlType ?: $this->addComplexType($type);
}
public function addBindingOperationHeader(\DOMElement $bindingOperation, array $headers, array $baseBinding)
{
foreach ($headers as $header) {

View File

@ -10,6 +10,7 @@
namespace BeSimple\SoapBundle\ServiceDefinition\Dumper;
use BeSimple\SoapBundle\Converter\TypeRepository;
use BeSimple\SoapBundle\ServiceDefinition\Method;
use BeSimple\SoapBundle\ServiceDefinition\Type;
use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
@ -23,14 +24,16 @@ use BeSimple\SoapBundle\Util\QName;
class WsdlDumper implements DumperInterface
{
private $loader;
private $typeRepository;
private $options;
private $wsdl;
private $definition;
public function __construct(AnnotationComplexTypeLoader $loader, array $options)
public function __construct(AnnotationComplexTypeLoader $loader, TypeRepository $typeRepository, array $options)
{
$this->loader = $loader;
$this->typeRepository = $typeRepository;
$this->options = $options;
}
@ -39,7 +42,7 @@ class WsdlDumper implements DumperInterface
Assert::thatArgumentNotNull('definition', $definition);
$this->definition = $definition;
$this->wsdl = new Wsdl($definition->getName(), $definition->getNamespace(), new WsdlTypeStrategy($this->loader, $definition));
$this->wsdl = new Wsdl($this->typeRepository, $definition->getName(), $definition->getNamespace(), new WsdlTypeStrategy($this->loader, $definition));
$port = $this->wsdl->addPortType($this->getPortTypeName());
$binding = $this->wsdl->addBinding($this->getBindingName(), $this->qualify($this->getPortTypeName()));