Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.14.0

Bug #12615 Decoded arrays missing some values
Submitted: 2007-12-05 05:13 UTC
From: paulschreiber Assigned: dufuz
Status: Closed Package: SOAP (version 0.11.0)
PHP Version: 5.2.4 OS:
Roadmaps: (Not assigned)    
Subscription  


 [2007-12-05 05:13 UTC] paulschreiber (Paul Schreiber)
Description: ------------ Line 786 of Base.php is this line: //$isstruct = false; Why is it commented out? I was debugging for quite some time before I came across this. Uncommenting it fixed my problem. I have some XML that looks like this: <multiRef id="id0" soapenc:root="0" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encod ing/" xsi:type="ns2:Map" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns2="http://xml.apache.org/xml-soap"> <item> <key xsi:type="xsd:string">A</key> <value xsi:type="xsd:string">SomeValue</value> </item> <item> <key xsi:type="xsd:string">B</key> <value xsi:type="xsd:string">TestValue</value> </item> <item> <key xsi:type="xsd:string">C</key> <value xsi:type="xsd:string">More Data</value> </item> <item> <key xsi:type="xsd:string">D</key> <value xsi:type="xsd:string">La la la</value> </item> ... I called Server::service, which called parseRequest(), which called __decodeRequest(), which called Base::_decode(), which has the above bug. Test script: --------------- $server = new SOAP_Server; $server->setCallHandler("myHandler",false); $result = $server->service($HTTP_RAW_POST_DATA); function myHandler($methodname, $args) { var_dump($args); } Expected result: ---------------- With the line commented, my result array only contain C, D, E, F, ... and their values. the first two items were missing, Actual result: -------------- With the line uncommented, I saw A, B, C, D, E, F ... and their values.

Comments

 [2007-12-20 15:41 UTC] northmh (Matthew North)
This appears to be the same issue as bug #12099. Only here we have a solution (thanks, Paul). We have the same issue, trying to consume Java 5.0 web services through PEAR::SOAP 0.11.0. Win XP, Apache 2.2.4, PHP 5.2.5. We were forced to downgrade back to 0.9.1 (the last version we know worked -- later versions other than 0.11.0 might in fact work as well).
 [2008-01-10 09:48 UTC] ggramlich (Gregor Gramlich)
I put up a complete .phpt unit test which succeeds on 0.9.1 and on 0.11 with line 786 modified, but fails on the original 0.11 --TEST-- Test for Bug #12099 Client of .Net SOAP server is missing first two rows of data? Bug #12615 Decoded arrays missing some values Bug #12774 I am Missing Response Information. --FILE-- <?php require_once 'includes.php'; require_once 'SOAP/Parser.php'; // Special cases for no string and a single string $stringarray = array(); $decoded = parseXml(getXml($stringarray)); printassert (($decoded == ''), '0'); $stringarray[] = 'a1'; $decoded = parseXml(getXml($stringarray)); // I would expect a string in this case, since the parser // can't distinguish between a string and an array containing // a single string. // Actually an object with string property is returned. printassert (is_object($decoded) && ($decoded->string == 'a1'), '1'); for ($i = 2; $i < 6; $i++) { $stringarray[] = 'a' . $i; $xml = getXml($stringarray); //echo $xml . "\n\n"; $decoded = parseXml($xml); //print_r($decoded); printassert (($decoded == $stringarray), $i); } // Helper functions /** * If flag is true, echo OK - otherwise echo Error * * @param bool $flag * @param string $message * @return void */ function printassert($flag, $message) { if ($flag) echo "OK $message.\n"; else echo "Error $message.\n"; } /** * Parse the XML string using SOAP_Parser. * * @param string $xml The xml string to be parsed * @return mixed Parsed result for the xml string. */ function parseXml($xml) { $response =& new SOAP_Parser($xml, 'UTF-8', $v = null); // This still looks normal. $return = $response->getResponse(); // print_r($return); // This loses the first two items for $i > 3 and // has an unexpected key 'string' for $i == 3. $decoded = $response->_decode($return); //print_r($decoded); return $decoded->return; } /** * Generate a simple SOAP response XML packing the $stringarray * * @param array $stringarray * @return string SOAP xml response */ function getXml($stringarray) { $xml = '<?xml version="1.0" encoding="utf-8"?> <soap:Envelope><soap:Body><trg:SomeResponse><return>'; foreach($stringarray as $string) { $xml .= "\n <string>$string</string>"; } $xml .= '</return></trg:SomeResponse></soap:Body></soap:Envelope>'; return $xml; } ?> --DONE-- <?php exit; ?> --EXPECT-- OK 0. OK 1. OK 2. OK 3. OK 4. OK 5.
 [2008-03-22 13:07 UTC] yunosh (Jan Schneider)
It would help a lot if the unit test could be incorporated into parser.phpt instead.
 [2008-07-03 22:08 UTC] dufuz (Helgi Þormar Þorbjörnsson)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. didn't add it as parser.phpt, used the bug name instead - might look into it later to salvage some of the test into the test.util file