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); $webServiceContext = $this->getWebServiceContext($webservice);
$this->serviceBinder = $webServiceContext->getServiceBinder(); $this->serviceBinder = $webServiceContext->getServiceBinder();
//$this->serviceBinder->fixXmlRequestContent();
$this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request')); $this->soapRequest = SoapRequest::createFromHttpRequest($this->container->get('request'));
//$this->soapRequest->setContent($this->serviceBinder->fixXmlRequestContent($this->soapRequest->getContent())); $this->soapServer = $webServiceContext->getServerFactory()->create($this->soapRequest, new SoapResponse());
$this->soapServer = $webServiceContext->getServerFactory()->create($this->soapRequest, $this->soapResponse);
$this->soapServer->setObject($this); $this->soapServer->setObject($this);

View File

@ -40,7 +40,12 @@ class TypeRepository
Assert::thatArgumentNotNull('phpType', $phpType); Assert::thatArgumentNotNull('phpType', $phpType);
Assert::thatArgumentNotNull('xmlType', $xmlType); 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) public function fixTypeInformation(ServiceDefinition $definition)
@ -56,36 +61,10 @@ class TypeRepository
} }
if (null === $xmlType) { if (null === $xmlType) {
if (!isset($typeMap[$phpType])) { $xmlType = $this->getXmlTypeMapping($phpType);
$parts = explode('\\', $phpType);
$xmlTypeName = ucfirst(end($parts));
if (String::endsWith($phpType, self::ARRAY_SUFFIX)) {
$xmlTypeName = str_replace(self::ARRAY_SUFFIX, 'Array', $xmlTypeName);
} }
$typeMap[$phpType] = new QName($definition->getNamespace(), $xmlTypeName); $type->setXmlType($xmlType);
}
$xmlType = $typeMap[$phpType];
} else {
$xmlType = $this->getQName($xmlType);
}
$type->setXmlType((string) $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%"> <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.definition.loader.annot_complextype" />
<argument type="service" id="besimple.soap.type.repository" />
<argument type="collection"> <argument type="collection">
<argument key="stylesheet">%besimple.soap.definition.dumper.options.stylesheet%</argument> <argument key="stylesheet">%besimple.soap.definition.dumper.options.stylesheet%</argument>
</argument> </argument>
@ -66,7 +67,7 @@
<argument>xsd:int</argument> <argument>xsd:int</argument>
</call> </call>
<call method="addDefaultTypeMapping"> <call method="addDefaultTypeMapping">
<argument>bool</argument> <argument>boolean</argument>
<argument>xsd:boolean</argument> <argument>xsd:boolean</argument>
</call> </call>
<call method="addDefaultTypeMapping"> <call method="addDefaultTypeMapping">
@ -74,7 +75,7 @@
<argument>xsd:float</argument> <argument>xsd:float</argument>
</call> </call>
<call method="addDefaultTypeMapping"> <call method="addDefaultTypeMapping">
<argument>DateTime</argument> <argument>dateTime</argument>
<argument>xsd:dateTime</argument> <argument>xsd:dateTime</argument>
</call> </call>
</service> </service>

View File

@ -10,6 +10,8 @@
namespace BeSimple\SoapBundle\ServiceDefinition\Dumper; namespace BeSimple\SoapBundle\ServiceDefinition\Dumper;
use BeSimple\SoapBundle\Converter\TypeRepository;
use BeSimple\SoapBundle\ServiceDefinition\Type;
use Zend\Soap\Wsdl as BaseWsdl; use Zend\Soap\Wsdl as BaseWsdl;
/** /**
@ -17,6 +19,26 @@ use Zend\Soap\Wsdl as BaseWsdl;
*/ */
class Wsdl extends 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) public function addBindingOperationHeader(\DOMElement $bindingOperation, array $headers, array $baseBinding)
{ {
foreach ($headers as $header) { foreach ($headers as $header) {

View File

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