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 #9875

SOAP response decoded incorrectly when duplicate xml elements present

Details

Submitted2007-01-19 06:14 UTC
Fromvanslyck at gmail dot com
StatusNo Feedback
PackageSOAP
PHP Version5.2.0
OSIrrelevant
Roadmaps(Not assigned)

Comments

[2007-01-19 06:14 UTC] vanslyck at gmail dot com

Description:
------------
When calling a web service which can return multiple XML elements with the same name, an array is returned rather than an object.

For example the xml response below is incorrectly decoded
<book>
<author>Bob</author>
<author>Sue</author>
<title>My Book</title>
</book>

Test script:
---------------
Patch:
Base.php, Line 905
//$return = array($return->{$item->name}, $d); $return->{$item->name} = array($return->{$item->name}, $d);

Test Script:
<?php

require_once 'SOAP/Client.php';

$wsdl_url =
'http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl';
$WSDL = new SOAP_WSDL($wsdl_url);
$client = $WSDL->getProxy();

$params = array(
'SearchIndex' => 'Books',
'Power' => 'asin: 1592289800',
'Sort' => 'salesrank',
'ResponseGroup' => 'ItemAttributes',
'AWSAccessKeyId' => 'XXXXXXXXXXXXXX',
'AssociateTag' => 'XXXXX-20',
'Version' => '2006-11-14'
);

echo("<pre>");
print_r($client->ItemSearch($params));
echo("</pre>");

?>

Expected result:
----------------
[Item] => stdClass Object
(
[ASIN] => 1592289800
[DetailPageURL] => http://www.amazon.com/gp/redirect.html%3FASIN=1592289800%26tag=sweetgeek-20%26lcode=sp1%26cID=2025%26ccmID=165953%26location=/o/ASIN/1592289800%253FSubscriptionId=1XCJZQH0D3BYHJMXGCG2
[ItemAttributes] => stdClass Object
(
[Author] => Array
(
[0] => Jay Kopelman
[1] => Melinda Roth
)

[Binding] => Hardcover
...

Actual result:
--------------
[Item] => stdClass Object
(
[ASIN] => 1592289800
[DetailPageURL] => http://www.amazon.com/gp/redirect.html%3FASIN=1592289800%26tag=sweetgeek-20%26lcode=sp1%26cID=2025%26ccmID=165953%26location=/o/ASIN/1592289800%253FSubscriptionId=1XCJZQH0D3BYHJMXGCG2
[ItemAttributes] => Array
(
[0] => Jay Kopelman
[1] => Melinda Roth
[2] => Hardcover
...

[2007-01-19 06:17 UTC] vanslyck at gmail dot com

Sorry, I mangled the patch...

Base.php, Line 905
//$return = array($return->{$item->name},$d);
$return->{$item->name} = array($return->{$item->name}, $d);