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

Bug #10131 incorrect return value in case of an empty array
Submitted: 2007-02-20 00:39 UTC
From: the-savior at freenet dot de Assigned: cweiske
Status: Closed Package: SOAP (version 0.10.1)
PHP Version: 4.4.1 OS: debian linux etch
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 36 + 34 = ?

 
 [2007-02-20 00:39 UTC] the-savior at freenet dot de (Andre Kroll)
Description: ------------ if a soap server response an empty array (attribute xsi:nil="true"), PEAR::SOAP on client side returns an empty string instead of an empty array. this can be really confusing if you want to count the elements of the returned array for example. Sample: <?php ... // get the wsdl-proxy $oProxyRef = $oWSDLRef->getProxy(); // call a function which should return an array $mResult = $oProxyRef->returnArray(); /* --- soap response --- ... <ns4:returnArrayResponse> <list xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:int[0]" xsi:nil="true"/> </ns4:returnArrayResponse> ... */ var_dump($mResult); // prints: string(0) "" count($mResult); // 1 ... ?> after some debugging i found a solution to fix this problem: i think the method "buildResponse()" in Parser.php refers a wrong value when creating a new Soap_Value on Line 221: current Parser.php [Line 210] // Add current node's value. [Line 211] if ($response) { [Line 212] $nqn =& new Qname($this->message[$pos]['name'], $this->message[$pos]['namespace']); [Line 213] $tqn =& new Qname($this->message[$pos]['type'], $this->message[$pos]['type_namespace']); [Line 214] $response =& new SOAP_Value($nqn->fqn(), $tqn->fqn(), $response, $attrs); [Line 215] if (isset($this->message[$pos]['arrayType'])) { [Line 216] $response->arrayType = $this->message[$pos]['arrayType']; [Line 217] } [Line 218] } else { [Line 219] $nqn =& new Qname($this->message[$pos]['name'], $this->message[$pos]['namespace']); [Line 220] $tqn =& new Qname($this->message[$pos]['type'], $this->message[$pos]['type_namespace']); [Line 221] $response =& new SOAP_Value($nqn->fqn(), $tqn->fqn(), $this->message[$pos]['cdata'], $attrs); [Line 222] } fixed Parser.php [Line 210] // Add current node's value. [Line 211] if ($response) { [Line 212] $nqn =& new Qname($this->message[$pos]['name'], $this->message[$pos]['namespace']); [Line 213] $tqn =& new Qname($this->message[$pos]['type'], $this->message[$pos]['type_namespace']); [Line 214] $response =& new SOAP_Value($nqn->fqn(), $tqn->fqn(), $response, $attrs); [Line 215] if (isset($this->message[$pos]['arrayType'])) { [Line 216] $response->arrayType = $this->message[$pos]['arrayType']; [Line 217] } [Line 218] } else { [Line 219] $nqn =& new Qname($this->message[$pos]['name'], $this->message[$pos]['namespace']); [Line 220] $tqn =& new Qname($this->message[$pos]['type'], $this->message[$pos]['type_namespace']); [Line 221*] // Check if value is an empty array [Line 222*] if ($tqn->name == 'Array') { [Line 223*] $response =& new SOAP_Value($nqn->fqn(), $tqn->fqn(), array(), $attrs); [Line 224*] } else { [Line 225*] $response =& new SOAP_Value($nqn->fqn(), $tqn->fqn(), $this->message[$pos]['cdata'], $attrs); [Line 226*] } [Line 227] } maybe the wrong position to fix the problem - but for me it worked.

Comments

 [2007-06-27 07:33 UTC] cweiske (Christian Weiske)
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.