php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39121 Incorrect return array handling in non-wsdl soap client.
Submitted: 2006-10-10 22:32 UTC Modified: 2006-11-06 16:38 UTC
Votes:5
Avg. Score:5.0 ± 0.0
Reproduced:4 of 5 (80.0%)
Same Version:4 (100.0%)
Same OS:0 (0.0%)
From: sos at sokhapkin dot dyndns dot org Assigned: dmitry (profile)
Status: Closed Package: SOAP related
PHP Version: 5.1.6 OS: Gentoo linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sos at sokhapkin dot dyndns dot org
New email:
PHP Version: OS:

 

 [2006-10-10 22:32 UTC] sos at sokhapkin dot dyndns dot org
Description:
------------
Return soap type array needs special handling in non-wsdl mode. The return array should have numeric indexes only because all elements of returned array have the same name.

Here is the pacth to fix the problem:

--- php_packet_soap.c.orig      2006-01-01 07:50:13.000000000 -0500
+++ php_packet_soap.c   2006-10-10 17:50:50.000000000 -0400
@@ -338,9 +338,18 @@
                                if (val != NULL) {
                                        if (!node_is_equal_ex(val,"result",RPC_SOAP12_NAMESPACE)) {
                                                zval *tmp;
+                                               int isarray = 0;

+                                               if(xmlHasProp(val, "type")) {
+                                                       xmlChar *type;
+                                                       type = xmlGetProp(val, "type");
+                                                       if(strstr(type, ":Array"))
+                                                               isarray = 1;
+                                                       xmlFree(type);
+                                               }
+
                                                tmp = master_to_zval(NULL, val);
-                                               if (val->name) {
+                                               if (val->name && !isarray) {
                                                        add_assoc_zval(return_value, (char*)val->name, tmp);
                                                } else {
                                                        add_next_index_zval(return_value, tmp);



Reproduce code:
---------------
Here is an example of soap return xml:
<soapenc:Array soapenc:arrayType="xsd:anyType[4]" xsi:type="soapenc:Array"><item xsi:type="xsd:long">17326080650</item><item xsi:type="xsd:int">1</item><item xsi:type="xsd:float">1.99</item><item xsi:type="xsd:int">0</item></soapenc:Array><soapenc:Array soapenc:arrayType="xsd:anyType[4]" xsi:type="soapenc:Array"><item xsi:type="xsd:long">17325882599</item><item xsi:type="xsd:int">1</item><item xsi:type="xsd:float">1.99</item><item xsi:type="xsd:int">0</item></soapenc:Array>

Expected result:
----------------
Array => (
        [0] => Array => (
                [0] => 17326080650
                [1] => 1
                [2] => 1.99
                [3] => 0
               )
        [1] => Array => (
                [0] => 17325882599
                [1] => 1
                [2] => 1.99
                [3] => 0
               )
)

Actual result:
--------------
Array => (
        [Array] => Array => (
                [0] => 17325882599
                [1] => 1
                [2] => 1.99
                [3] => 0
               )
)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-10-10 22:42 UTC] tony2001@php.net
Assigned to the maintainer.
 [2006-10-23 06:46 UTC] dmitry@php.net
I cannot analyze the report without full SOAP Envelope. I fixed one bug related to this report, but I cannot be sure that it fixes your issue.

(Your pathch is completly wrong).
 [2006-10-23 15:07 UTC] sos at sokhapkin dot dyndns dot org
I emailed the soap message, the bugtracker did not accept 
it.
 [2006-11-01 16:55 UTC] hpuiu at xentra dot ro
Hi,

I am using PHP 5.1.6 on Windows XP and I have also 
encountered this issue while trying to work with
DIDX.org SOAP. There are functions that should return 
arrays, but instead, all I get is an array that contains
the last record and not a multidimensional array as
I expect. I have downloaded PHP 5.2-dev and the problem is
still there.

Puiu Hrenciuc
 [2006-11-06 16:38 UTC] dmitry@php.net
The bug is fixed in CVS HEAD and PHP_5_2.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 14:01:29 2024 UTC