PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Web Services » SOAP » Bug #5794

serializing an array of SOAP_Values is broken

Details

Submitted2005-10-27 11:36 UTC
Fromaschultz at warp10 dot net
Assignedyunosh
StatusClosed
PackageSOAP
PHP Version4.4.0
OSLinux
Roadmaps(Not assigned)

Comments

[2005-10-27 11:36 UTC] aschultz at warp10 dot net

Description:
------------
Serializing an array of SOAP_Value objects duplicates the element name.

Test script:
---------------
<?php

require_once('SOAP/Base.php');
require_once('SOAP/Value.php');

$values = array();
for ($i = 1; $i < 4; $i++) {
$v = new stdClass();
$v->Name = "name_$i";
$v->Value = "value_$i";

$values[] = new SOAP_Value('DemoItem', 'ValueStruc', $v);
}

$base = new SOAP_Base();
echo $base->_serializeValue($values, 'ValueArray');
?>

Expected result:
----------------
<ValueArray xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="ValueStruc[3]" SOAP-ENC:offset="[0]">
<DemoItem>
<Name xsi:type="xsd:string">name_1</Name>
<Value xsi:type="xsd:string">value_1</Value></DemoItem>
<DemoItem>
<Name xsi:type="xsd:string">name_2</Name>
<Value xsi:type="xsd:string">value_2</Value></DemoItem>
<DemoItem>
<Name xsi:type="xsd:string">name_3</Name>
<Value xsi:type="xsd:string">value_3</Value></DemoItem></ValueArray>

Actual result:
--------------
<ValueArray xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="ValueStruc[3]" SOAP-ENC:offset="[0]">
<DemoItem>
<DemoItem>
<Name xsi:type="xsd:string">name_1</Name>
<Value xsi:type="xsd:string">value_1</Value></DemoItem></DemoItem>
<DemoItem>
<DemoItem>
<Name xsi:type="xsd:string">name_2</Name>
<Value xsi:type="xsd:string">value_2</Value></DemoItem></DemoItem>
<DemoItem>
<DemoItem>
<Name xsi:type="xsd:string">name_3</Name>
<Value xsi:type="xsd:string">value_3</Value></DemoItem></DemoItem></ValueArray>

[2005-10-27 11:39 UTC] aschultz at warp10 dot net

this fixes it for me:

diff -uNr /usr/share/php/SOAP/Base.php SOAP/Base.php
--- /usr/share/php/SOAP/Base.php 2005-10-27 13:20:21.000000000 +0200
+++ SOAP/Base.php 2005-10-27 13:10:29.000000000 +0200
@@ -525,8 +533,7 @@
if ($this->_isSoapValue($array_val)) {
$array_type = $array_val->type;
$array_types[$array_type] = 1;
- $array_type_ns = $array_val->type_namespace;
- $xmlout_value .= $this->_serializeValue($array_val, $array_val->name, $array_type, $array_type_ns);
+ $xmlout_value .= $array_val->serialize($this);
} else {
$array_type = $this->_getType($array_val);
$array_types[$array_type] = 1;

[2005-10-27 11:49 UTC] aschultz at warp10 dot net

uhm, the last patch removed the array_type_ns assigment, which is needed.
So it should be:
diff -uNr /usr/share/php/SOAP/Base.php SOAP/Base.php
--- /usr/share/php/SOAP/Base.php 2005-10-27 13:20:21.000000000 +0200
+++ SOAP/Base.php 2005-10-27 13:10:29.000000000 +0200
@@ -525,8 +533,7 @@
if ($this->_isSoapValue($array_val)) {
$array_type = $array_val->type;
$array_types[$array_type] = 1;
$array_type_ns = $array_val->type_namespace;
- $xmlout_value .= $this->_serializeValue($array_val, $array_val->name, $array_type, $array_type_ns);
+ $xmlout_value .= $array_val->serialize($this);
} else {
$array_type = $this->_getType($array_val);
$array_types[$array_type] = 1;