diff --git a/ServiceBinding/RpcLiteralRequestMessageBinder.php b/ServiceBinding/RpcLiteralRequestMessageBinder.php index edef394..21cfe17 100644 --- a/ServiceBinding/RpcLiteralRequestMessageBinder.php +++ b/ServiceBinding/RpcLiteralRequestMessageBinder.php @@ -98,6 +98,12 @@ class RpcLiteralRequestMessageBinder implements MessageBinderInterface $value = $this->processType($type->getValue(), $value); + if ($p->isPublic()) { + $message->{$type->getName()} = $value; + } else { + $p->setValue($message, $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())); } diff --git a/ServiceBinding/RpcLiteralResponseMessageBinder.php b/ServiceBinding/RpcLiteralResponseMessageBinder.php index 5cb6310..d4e57df 100644 --- a/ServiceBinding/RpcLiteralResponseMessageBinder.php +++ b/ServiceBinding/RpcLiteralResponseMessageBinder.php @@ -76,13 +76,17 @@ class RpcLiteralResponseMessageBinder implements MessageBinderInterface $p = $r->getProperty($type->getName()); if ($p->isPublic()) { $value = $message->{$type->getName()}; - - $message->{$type->getName()} = $this->processType($type->getValue(), $value); } else { $p->setAccessible(true); $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) { @@ -92,4 +96,4 @@ class RpcLiteralResponseMessageBinder implements MessageBinderInterface return $message; } -} \ No newline at end of file +} diff --git a/Tests/ServiceBinding/RpcLiteralRequestMessageBinderTest.php b/Tests/ServiceBinding/RpcLiteralRequestMessageBinderTest.php index c656611..b48adf7 100644 --- a/Tests/ServiceBinding/RpcLiteralRequestMessageBinderTest.php +++ b/Tests/ServiceBinding/RpcLiteralRequestMessageBinderTest.php @@ -115,6 +115,29 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase $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() { $messageBinder = new RpcLiteralRequestMessageBinder(); @@ -217,6 +240,12 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase 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( array('bar', 'BeSimple\SoapBundle\Tests\fixtures\ServiceBinding\BarRecursive'), )); @@ -246,4 +275,4 @@ class RpcLiteralRequestMessageBinderTest extends \PHPUnit_Framework_TestCase return $collection; } -} \ No newline at end of file +} diff --git a/Tests/fixtures/ServiceBinding/SimpleArrays.php b/Tests/fixtures/ServiceBinding/SimpleArrays.php new file mode 100644 index 0000000..e17a640 --- /dev/null +++ b/Tests/fixtures/ServiceBinding/SimpleArrays.php @@ -0,0 +1,28 @@ +array1 = $array1; + $this->array2 = $array2; + $this->array3 = $array3; + } + + public function getArray2() + { + return $this->array2; + } + + public function getArray3() + { + return $this->array3; + } +}