BeSimpleSoap/ServiceBinding/ServiceBinder.php
Francis Besset 4fa893042f New definition of complex type
The exposure of complex type properties was done only with public property.
Now you can expose properties and public methods.

Before:
  In a complex type:
    /**
     * @var string
     */
   public $var;

After:
  In a complex type:
    use BeSimple\SoapBundle\ServiceDefinition\Annotation as Soap;

    /**
     * @Soap\PropertyComplexType("string", name="var", nillable="true")
     */
    public $username;

    private $email;

    /**
     * @Soap\MethodComplexType("string", name="email", nillable="true", setter="setEmail")
     */
    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }

name, nillable are optionnal.
setter is optional and only available for MethodComplexType.
2011-07-23 21:24:59 +02:00

82 lines
2.6 KiB
PHP

<?php
/*
* This file is part of the BeSimpleSoapBundle.
*
* (c) Christian Kerl <christian-kerl@web.de>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace BeSimple\SoapBundle\ServiceBinding;
use BeSimple\SoapBundle\ServiceDefinition\Header;
use BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition;
use BeSimple\SoapBundle\Soap\SoapHeader;
use BeSimple\SoapBundle\Util\QName;
class ServiceBinder
{
/**
* @var \BeSimple\SoapBundle\ServiceDefinition\ServiceDefinition
*/
private $definition;
/**
* @var \BeSimple\SoapBundle\ServiceBinding\MessageBinderInterface
*/
private $requestMessageBinder;
/**
* @var \BeSimple\SoapBundle\ServiceBinding\MessageBinderInterface
*/
private $responseMessageBinder;
public function __construct(ServiceDefinition $definition, MessageBinderInterface $requestMessageBinder, MessageBinderInterface $responseMessageBinder) {
$this->definition = $definition;
$this->requestMessageBinder = $requestMessageBinder;
$this->responseMessageBinder = $responseMessageBinder;
}
public function isServiceHeader($name)
{
return $this->definition->getHeaders()->has($name);
}
public function isServiceMethod($name)
{
return $this->definition->getMethods()->has($name);
}
public function processServiceHeader($name, $data)
{
$headerDefinition = $this->definition->getHeaders()->get($name);
return $this->createSoapHeader($headerDefinition, $data);
}
public function processServiceMethodArguments($name, $arguments)
{
$methodDefinition = $this->definition->getMethods()->get($name);
$result = array();
$result['_controller'] = $methodDefinition->getController();
$result = array_merge($result, $this->requestMessageBinder->processMessage($methodDefinition, $arguments, $this->definition->getDefinitionComplexTypes()));
return $result;
}
public function processServiceMethodReturnValue($name, $return)
{
$methodDefinition = $this->definition->getMethods()->get($name);
return $this->responseMessageBinder->processMessage($methodDefinition, $return, $this->definition->getDefinitionComplexTypes());
}
protected function createSoapHeader(Header $headerDefinition, $data)
{
$qname = QName::fromPackedQName($headerDefinition->getType()->getXmlType());
return new SoapHeader($qname->getNamespace(), $qname->getName(), $data);
}
}