Edit report at https://bugs.php.net/bug.php?id=47492&edit=1

 ID:                 47492
 Comment by:         jboffel at gmail dot com
 Reported by:        florian dot eberle at gmail dot com
 Summary:            SOAP_SINGLE_ELEMENT_ARRAYS has no effect
 Status:             Feedback
 Type:               Bug
 Package:            SOAP related
 Operating System:   Debian Lenny
 PHP Version:        5.2CVS-2009-02-24 (CVS)
 Block user comment: N
 Private report:     N

 New Comment:

Hi all,

I think for people without WSDL, you shouldn't expect 
SOAP_SINGLE_ELEMENT_ARRAYS to work.

To know it, SoapClient need a XSD saying it could be or not more than one 
result to decide it must be in array or not.

Just with SOAP answer it is technically impossible to make a difference between 
an anwser that is just 1 element but could have N and an answer that is known 
to be only 1.

Exemple :
<body>
<brotherdetail>age: 17</brotherdetail>
</body>

<body>
<brotherdetail>age: 17</brotherdetail>
<brotherdetail>sister : 1</brotherdetail>
</body>

In first case, if you don't have a XSD to say brotherdetail is a type and have 
rule maxOccurs = unbounded, how do you expect SoapClient will know it could 
have been more than one detail ?
Of course with second example, SoapClient will now it could be because it'll 
find more than one so it will naturally make an array...


Previous Comments:
------------------------------------------------------------------------
[2010-11-04 08:08:54] timothee dot groleau at mig33global dot com

Oh duh, I forgot to add some version information:

$ php -version
PHP 5.3.3 (cli) (built: Oct 29 2010 14:24:39) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies


I'm on Mac OS, php was installed from macports

------------------------------------------------------------------------
[2010-11-04 07:55:50] timothee dot groleau at mig33global dot com

Same problem here. xsi:type="ns2:Vector" entries are not translated to arrays 
if there is only one element inside. Example below:



soap client created like so:
============================================================
$client = new soapclient(null, array(
  'location' => $soap_ejb_service_url,
  'uri' => $soap_ejb_service_name,
  'features' => SOAP_SINGLE_ELEMENT_ARRAYS | SOAP_USE_XSI_ARRAY_TYPE,
  'trace' => true)
);
$response = $client->__soapCall($function, $parameters);
============================================================


raw soap response:
============================================================
<?xml version='1.0' encoding='UTF-8'?>
<SOAP-ENV:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/";>
<SOAP-ENV:Body>
<ns1:searchChatroomResponse xmlns:ns1="urn:fusion" 
SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
<return xmlns:ns2="http://xml.apache.org/xml-soap"; xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">totalpages</key>
<value xsi:type="xsd:double">1.0</value>
</item>
<item>
<key xsi:type="xsd:string">totalresults</key>
<value xsi:type="xsd:int">1</value>
</item>
<item>
<key xsi:type="xsd:string">chatrooms</key>
<value xsi:type="ns2:Vector">
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">name</key>
<value xsi:type="xsd:string">tim_test</value>
</item>
<item>
<key xsi:type="xsd:string">id</key>
<value xsi:type="xsd:string">6</value>
</item>
<item>
<key xsi:type="xsd:string">status</key>
<value xsi:type="xsd:string">ACTIVE</value>
</item>
<item>
<key xsi:type="xsd:string">language</key>
<value xsi:type="xsd:string">ENG</value>
</item>
</item>
</value>
</item>
<item>
<key xsi:type="xsd:string">page</key>
<value xsi:type="xsd:int">1</value>
</item>
</return>
</ns1:searchChatroomResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
============================================================


$response returned by php client:
============================================================
array(4) {
  ["totalpages"]=>
  float(1)
  ["totalresults"]=>
  int(1)
  ["chatrooms"]=>
  object(stdClass)#2 (1) {
    ["item"]=>
    array(16) {
      ["name"]=>
      string(8) "tim_test"
      ["id"]=>
      string(1) "6"
      ["status"]=>
      string(6) "ACTIVE"
      ["language"]=>
      string(3) "ENG"
    }
  }
  ["page"]=>
  int(1)
}
============================================================

------------------------------------------------------------------------
[2010-06-20 21:27:41] fel...@php.net

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.



------------------------------------------------------------------------
[2009-11-27 13:45:55] niek at signet dot nl

This bug was filed a long time ago, still no replies. Is there going to be some 
kind of fix for this?

------------------------------------------------------------------------
[2009-11-27 08:35:52] niek at signet dot nl

I've the same problem; but I use WSDL with my SOAP.

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=47492


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=47492&edit=1

Reply via email to