Fixed bug if a complex type contains a collection
This commit is contained in:
parent
f0031e8923
commit
cfe949b781
|
@ -98,6 +98,12 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface
|
||||||
|
|
||||||
$value = $this->processType($type->getValue(), $value);
|
$value = $this->processType($type->getValue(), $value);
|
||||||
|
|
||||||
|
if ($p->isPublic()) {
|
||||||
|
$message->{$type->getName()} = $value;
|
||||||
|
} else {
|
||||||
|
$p->setValue($message, $value);
|
||||||
|
}
|
||||||
|
|
||||||
if (!$type->isNillable() && null === $value) {
|
if (!$type->isNillable() && null === $value) {
|
||||||
throw new \SoapFault('SOAP_ERROR_COMPLEX_TYPE', sprintf('"%s:%s" cannot be null.', ucfirst(Wsdl::translateType($phpType)), $type->getName()));
|
throw new \SoapFault('SOAP_ERROR_COMPLEX_TYPE', sprintf('"%s:%s" cannot be null.', ucfirst(Wsdl::translateType($phpType)), $type->getName()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,13 +76,17 @@ class RpcLiteralResponseMessageBinder implements MessageBinderInterface
|
||||||
$p = $r->getProperty($type->getName());
|
$p = $r->getProperty($type->getName());
|
||||||
if ($p->isPublic()) {
|
if ($p->isPublic()) {
|
||||||
$value = $message->{$type->getName()};
|
$value = $message->{$type->getName()};
|
||||||
|
|
||||||
$message->{$type->getName()} = $this->processType($type->getValue(), $value);
|
|
||||||
} else {
|
} else {
|
||||||
$p->setAccessible(true);
|
$p->setAccessible(true);
|
||||||
$value = $p->getValue($message);
|
$value = $p->getValue($message);
|
||||||
|
}
|
||||||
|
|
||||||
$p->setValue($message, $this->processType($type->getValue(), $value));
|
$value = $this->processType($type->getValue(), $value);
|
||||||
|
|
||||||
|
if ($p->isPublic()) {
|
||||||
|
$message->{$type->getName()} = $value;
|
||||||
|
} else {
|
||||||
|
$p->setValue($message, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$type->isNillable() && null === $value) {
|
if (!$type->isNillable() && null === $value) {
|
||||||
|
|
|
@ -115,6 +115,29 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals(array('fooBar' => $fooBar), $result);
|
$this->assertEquals(array('fooBar' => $fooBar), $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testProcessMessageComplexTypeWithArrays()
|
||||||
|
{
|
||||||
|
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||||
|
|
||||||
|
$array = array(1, 2, 3, 4);
|
||||||
|
$stdClass = new \stdClass();
|
||||||
|
$stdClass->item = $array;
|
||||||
|
$simpleArrays = new Fixtures\SimpleArrays(null, new \stdClass(), $stdClass);
|
||||||
|
|
||||||
|
$result = $messageBinder->processMessage(
|
||||||
|
new Definition\Method('complextype_with_array', null, array(), array(
|
||||||
|
new Definition\Argument('simple_arrays', new Definition\Type('BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\SimpleArrays')),
|
||||||
|
)),
|
||||||
|
array($simpleArrays),
|
||||||
|
$this->getDefinitionComplexTypes()
|
||||||
|
);
|
||||||
|
|
||||||
|
$result = $result['simple_arrays'];
|
||||||
|
$this->assertEquals(array(), $result->array1);
|
||||||
|
$this->assertEquals(array(), $result->getArray2());
|
||||||
|
$this->assertEquals($array, $result->getArray3());
|
||||||
|
}
|
||||||
|
|
||||||
public function testProcessMessageWithEmptyArrayComplexType()
|
public function testProcessMessageWithEmptyArrayComplexType()
|
||||||
{
|
{
|
||||||
$messageBinder = new RpcLiteralRequestMessageBinder();
|
$messageBinder = new RpcLiteralRequestMessageBinder();
|
||||||
|
@ -217,6 +240,12 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase
|
||||||
array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Bar'),
|
array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\Bar'),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\SimpleArrays'] = $this->createComplexTypeCollection(array(
|
||||||
|
array('array1', 'string[]', true),
|
||||||
|
array('array2', 'string[]'),
|
||||||
|
array('array3', 'string[]'),
|
||||||
|
));
|
||||||
|
|
||||||
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive'] = $this->createComplexTypeCollection(array(
|
$definitionComplexTypes['BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\FooRecursive'] = $this->createComplexTypeCollection(array(
|
||||||
array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\BarRecursive'),
|
array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\BarRecursive'),
|
||||||
));
|
));
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BeSimple\SoapBundle\Tests\fixtures\ServiceBinding;
|
||||||
|
|
||||||
|
class SimpleArrays
|
||||||
|
{
|
||||||
|
public $array1;
|
||||||
|
|
||||||
|
private $array2;
|
||||||
|
private $array3;
|
||||||
|
|
||||||
|
public function __construct($array1, $array2, $array3)
|
||||||
|
{
|
||||||
|
$this->array1 = $array1;
|
||||||
|
$this->array2 = $array2;
|
||||||
|
$this->array3 = $array3;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getArray2()
|
||||||
|
{
|
||||||
|
return $this->array2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getArray3()
|
||||||
|
{
|
||||||
|
return $this->array3;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue