Used MessageBinder of BeSimpleSoapCommon component
This commit is contained in:
parent
a86c680263
commit
794d6cf8c2
|
@ -43,6 +43,8 @@ User class
|
||||||
|
|
||||||
You can expose only the properties (public, protected or private) of a complex type.
|
You can expose only the properties (public, protected or private) of a complex type.
|
||||||
|
|
||||||
|
**For performance reasons, we advise to create getter and setter for each property.**
|
||||||
|
|
||||||
.. code-block:: php
|
.. code-block:: php
|
||||||
|
|
||||||
namespace Acme\DemoBundle\Entity;
|
namespace Acme\DemoBundle\Entity;
|
||||||
|
@ -75,6 +77,56 @@ You can expose only the properties (public, protected or private) of a complex t
|
||||||
* @Soap\ComplexType("string")
|
* @Soap\ComplexType("string")
|
||||||
*/
|
*/
|
||||||
private $email;
|
private $email;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Soap\ComplexType("boolean")
|
||||||
|
*/
|
||||||
|
private $newsletter;
|
||||||
|
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUsername()
|
||||||
|
{
|
||||||
|
return $this->username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEmail()
|
||||||
|
{
|
||||||
|
return $this->email;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFirstname()
|
||||||
|
{
|
||||||
|
return $this->firstname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFirstname($firstname)
|
||||||
|
{
|
||||||
|
$this->firstname = $firstname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLastname()
|
||||||
|
{
|
||||||
|
return $this->lastname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setLastname($lastname)
|
||||||
|
{
|
||||||
|
$this->lastname = $lastname;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasNewsletter()
|
||||||
|
{
|
||||||
|
return $this->newsletter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setNewsletter($newsletter)
|
||||||
|
{
|
||||||
|
$this->newletter = (Boolean) $newsletter
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ComplexType
|
ComplexType
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the BeSimpleSoapBundle.
|
* This file is part of the BeSimpleSoapBundle.
|
||||||
*
|
*
|
||||||
* (c) Christian Kerl <christian-kerl@web.de>
|
* (c) Christian Kerl <christian-kerl@web.de>
|
||||||
|
* (c) Francis Besset <francis.besset@gmail.com>
|
||||||
*
|
*
|
||||||
* This source file is subject to the MIT license that is bundled
|
* This source file is subject to the MIT license that is bundled
|
||||||
* with this source code in the file LICENSE.
|
* with this source code in the file LICENSE.
|
||||||
|
@ -13,8 +15,7 @@ namespace BeSimple\SoapBundle\ServiceBinding;
|
||||||
use BeSimple\SoapBundle\ServiceDefinition\Method;
|
use BeSimple\SoapBundle\ServiceDefinition\Method;
|
||||||
use BeSimple\SoapBundle\ServiceDefinition\Strategy\MethodComplexType;
|
use BeSimple\SoapBundle\ServiceDefinition\Strategy\MethodComplexType;
|
||||||
use BeSimple\SoapBundle\ServiceDefinition\Strategy\PropertyComplexType;
|
use BeSimple\SoapBundle\ServiceDefinition\Strategy\PropertyComplexType;
|
||||||
|
use BeSimple\SoapCommon\Util\MessageBinder;
|
||||||
use Zend\Soap\Wsdl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christian Kerl <christian-kerl@web.de>
|
* @author Christian Kerl <christian-kerl@web.de>
|
||||||
|
@ -86,24 +87,15 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
|
||||||
|
|
||||||
$this->messageRefs[$hash] = $message;
|
$this->messageRefs[$hash] = $message;
|
||||||
|
|
||||||
$r = new \ReflectionClass($message);
|
$messageBinder = new MessageBinder($message);
|
||||||
foreach ($this->definitionComplexTypes[$phpType] as $type) {
|
foreach ($this->definitionComplexTypes[$phpType] as $type) {
|
||||||
$p = $r->getProperty($type->getName());
|
$property = $type->getName();
|
||||||
if ($p->isPublic()) {
|
$value = $messageBinder->readProperty($property);
|
||||||
$value = $message->{$type->getName()};
|
|
||||||
} else {
|
|
||||||
$p->setAccessible(true);
|
|
||||||
$value = $p->getValue($message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $value) {
|
if (null !== $value) {
|
||||||
$value = $this->processType($type->getValue(), $value);
|
$value = $this->processType($type->getValue(), $value);
|
||||||
|
|
||||||
if ($p->isPublic()) {
|
$messageBinder->writeProperty($property, $value);
|
||||||
$message->{$type->getName()} = $value;
|
|
||||||
} else {
|
|
||||||
$p->setValue($message, $value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$type->isNillable() && null === $value) {
|
if (!$type->isNillable() && null === $value) {
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This file is part of the BeSimpleSoapBundle.
|
* This file is part of the BeSimpleSoapBundle.
|
||||||
*
|
*
|
||||||
* (c) Christian Kerl <christian-kerl@web.de>
|
* (c) Christian Kerl <christian-kerl@web.de>
|
||||||
|
* (c) Francis Besset <francis.besset@gmail.com>
|
||||||
*
|
*
|
||||||
* This source file is subject to the MIT license that is bundled
|
* This source file is subject to the MIT license that is bundled
|
||||||
* with this source code in the file LICENSE.
|
* with this source code in the file LICENSE.
|
||||||
|
@ -13,8 +15,7 @@ namespace BeSimple\SoapBundle\ServiceBinding;
|
||||||
use BeSimple\SoapBundle\ServiceDefinition\Method;
|
use BeSimple\SoapBundle\ServiceDefinition\Method;
|
||||||
use BeSimple\SoapBundle\ServiceDefinition\Strategy\PropertyComplexType;
|
use BeSimple\SoapBundle\ServiceDefinition\Strategy\PropertyComplexType;
|
||||||
use BeSimple\SoapBundle\ServiceDefinition\Strategy\MethodComplexType;
|
use BeSimple\SoapBundle\ServiceDefinition\Strategy\MethodComplexType;
|
||||||
|
use BeSimple\SoapCommon\Util\MessageBinder;
|
||||||
use Zend\Soap\Wsdl;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Christian Kerl <christian-kerl@web.de>
|
* @author Christian Kerl <christian-kerl@web.de>
|
||||||
|
@ -71,24 +72,15 @@ class RpcLiteralResponseMessageBinder implements MessageBinderInterface
|
||||||
throw new \InvalidArgumentException(sprintf('The instance class must be "%s", "%s" given.', get_class($message), $phpType));
|
throw new \InvalidArgumentException(sprintf('The instance class must be "%s", "%s" given.', get_class($message), $phpType));
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = new \ReflectionClass($message);
|
$messageBinder = new MessageBinder($message);
|
||||||
foreach ($this->definitionComplexTypes[$phpType] as $type) {
|
foreach ($this->definitionComplexTypes[$phpType] as $type) {
|
||||||
$p = $r->getProperty($type->getName());
|
$property = $type->getName();
|
||||||
if ($p->isPublic()) {
|
$value = $messageBinder->readProperty($property);
|
||||||
$value = $message->{$type->getName()};
|
|
||||||
} else {
|
|
||||||
$p->setAccessible(true);
|
|
||||||
$value = $p->getValue($message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (null !== $value) {
|
if (null !== $value) {
|
||||||
$value = $this->processType($type->getValue(), $value);
|
$value = $this->processType($type->getValue(), $value);
|
||||||
|
|
||||||
if ($p->isPublic()) {
|
$messageBinder->writeProperty($property, $value);
|
||||||
$message->{$type->getName()} = $value;
|
|
||||||
} else {
|
|
||||||
$p->setValue($message, $value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$type->isNillable() && null === $value) {
|
if (!$type->isNillable() && null === $value) {
|
||||||
|
|
Loading…
Reference in New Issue