php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46616 Value dropped when Soap response with nodes containing attributes and value
Submitted: 2008-11-19 14:49 UTC Modified: 2009-12-09 18:22 UTC
Votes:10
Avg. Score:4.6 ± 0.7
Reproduced:8 of 8 (100.0%)
Same Version:1 (12.5%)
Same OS:2 (25.0%)
From: justin dot hendrickson at gmail dot com Assigned:
Status: Open Package: SOAP related
PHP Version: 5.2.6 OS: Ubuntu 8.04
Private report: No CVE-ID: None
 [2008-11-19 14:49 UTC] justin dot hendrickson at gmail dot com
Description:
------------
When casting a Soap response to a PHP value, if a node containing both attributes and a value is encountered, the value is dropped. There's not much information about what is suppose to happen in this case, but from what I gathered, the value is suppose to end up in a property named "_".

Reproduce code:
---------------
The service is private, so I cannot provide the URL, but I can supply the WSDL file upon email request.

I can provide the result of the Soap request:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soap:Body>
        <SearchResult xmlns="http://com.etilize.spexlive" count="921">
            <products>
                <productSummary id="1011038602"><manufacturer sku="MFC-9440CN" name="Brother Industries, Ltd" id="10328"/>
                    <skus>
                        <sku val="MFC-9440CN" type="MFGPARTNUMBER"/>
                        <sku val="BRT MFC9440CN" type="SP Richards Catalog"/>
                        <sku val="BRTMFC9440CN" type="SP Richards"/>
                        <sku val="BRTMFC9440CN" type="United"/>
                        <sku val="BRTMFC9440CN" type="IS Group"/>
                        <sku val="BRTMFC9440CN" type="TriMega"/>
                    </skus>
                    <descriptions>
                        <pd t="2">Brother MFC-9440CN Multifunction Printer</pd>
                        <pd t="1">Brother MFC-9440CN Multifunction Printer - Color Laser - 21 ppm Mono - 21 ppm Color - 2400 x 600 dpi - Fax, Copier, Scanner, Printer - PictBridge - Mac</pd>
                        <pd t="3">Multifunction Network Printer - Color Laser - 21 ppm Mono - 21 ppm Color - 2400 x 600 dpi - Fax, Copier, Scanner, Printer - PictBridge - Mac</pd>
                        <pd t="0">MFC-9440CN CLR LASER P/S/C/F USB 2400X600 64MB 21PPM</pd>
                    </descriptions>
                </productSummary>
            </products>
        </SearchResult>
    </soap:Body>
</soap:Envelope>

Expected result:
----------------
object(stdClass)#2 (2) {
  ["products"]=>
  object(stdClass)#3 (1) {
    ["productSummary"]=>
    array(1) {
      [0]=>
      object(stdClass)#4 (4) {
        ["manufacturer"]=>
        object(stdClass)#5 (3) {
          ["id"]=>
          int(10328)
          ["name"]=>
          string(23) "Brother Industries, Ltd"
          ["sku"]=>
          string(10) "MFC-9440CN"
        }
        ["skus"]=>
        object(stdClass)#6 (1) {
          ["sku"]=>
          array(6) {
            [0]=>
            object(stdClass)#7 (2) {
              ["val"]=>
              string(10) "MFC-9440CN"
              ["type"]=>
              string(13) "MFGPARTNUMBER"
            }
            [1]=>
            object(stdClass)#8 (2) {
              ["val"]=>
              string(13) "BRT MFC9440CN"
              ["type"]=>
              string(19) "SP Richards Catalog"
            }
            [2]=>
            object(stdClass)#9 (2) {
              ["val"]=>
              string(12) "BRTMFC9440CN"
              ["type"]=>
              string(11) "SP Richards"
            }
            [3]=>
            object(stdClass)#10 (2) {
              ["val"]=>
              string(12) "BRTMFC9440CN"
              ["type"]=>
              string(6) "United"
            }
            [4]=>
            object(stdClass)#11 (2) {
              ["val"]=>
              string(12) "BRTMFC9440CN"
              ["type"]=>
              string(8) "IS Group"
            }
            [5]=>
            object(stdClass)#12 (2) {
              ["val"]=>
              string(12) "BRTMFC9440CN"
              ["type"]=>
              string(7) "TriMega"
            }
          }
        }
        ["descriptions"]=>
        object(stdClass)#13 (1) {
          ["pd"]=>
          array(4) {
            [0]=>
            object(stdClass)#14 (1) {
              ["_"]=>
              "Brother MFC-9440CN Multifunction Printer"
              ["t"]=>
              int(2)
            }
            [1]=>
            object(stdClass)#15 (1) {
              ["_"]=>
              "Brother MFC-9440CN Multifunction Printer - Color Laser - 21 ppm Mono - 21 ppm Color - 2400 x 600 dpi - Fax, Copier, Scanner, Printer - PictBridge - Mac"
              ["t"]=>
              int(1)
            }
            [2]=>
            object(stdClass)#16 (1) {
              ["_"]=>
              "Multifunction Network Printer - Color Laser - 21 ppm Mono - 21 ppm Color - 2400 x 600 dpi - Fax, Copier, Scanner, Printer - PictBridge - Mac"
              ["t"]=>
              int(3)
            }
            [3]=>
            object(stdClass)#17 (1) {
              ["_"]=>
              "MFC-9440CN CLR LASER P/S/C/F USB 2400X600 64MB 21PPM"
              ["t"]=>
              int(0)
            }
          }
        }
        ["id"]=>
        int(1011038602)
      }
    }
  }
  ["count"]=>
  int(921)
}

Actual result:
--------------
object(stdClass)#2 (2) {
  ["products"]=>
  object(stdClass)#3 (1) {
    ["productSummary"]=>
    array(1) {
      [0]=>
      object(stdClass)#4 (4) {
        ["manufacturer"]=>
        object(stdClass)#5 (3) {
          ["id"]=>
          int(10328)
          ["name"]=>
          string(23) "Brother Industries, Ltd"
          ["sku"]=>
          string(10) "MFC-9440CN"
        }
        ["skus"]=>
        object(stdClass)#6 (1) {
          ["sku"]=>
          array(6) {
            [0]=>
            object(stdClass)#7 (2) {
              ["val"]=>
              string(10) "MFC-9440CN"
              ["type"]=>
              string(13) "MFGPARTNUMBER"
            }
            [1]=>
            object(stdClass)#8 (2) {
              ["val"]=>
              string(13) "BRT MFC9440CN"
              ["type"]=>
              string(19) "SP Richards Catalog"
            }
            [2]=>
            object(stdClass)#9 (2) {
              ["val"]=>
              string(12) "BRTMFC9440CN"
              ["type"]=>
              string(11) "SP Richards"
            }
            [3]=>
            object(stdClass)#10 (2) {
              ["val"]=>
              string(12) "BRTMFC9440CN"
              ["type"]=>
              string(6) "United"
            }
            [4]=>
            object(stdClass)#11 (2) {
              ["val"]=>
              string(12) "BRTMFC9440CN"
              ["type"]=>
              string(8) "IS Group"
            }
            [5]=>
            object(stdClass)#12 (2) {
              ["val"]=>
              string(12) "BRTMFC9440CN"
              ["type"]=>
              string(7) "TriMega"
            }
          }
        }
        ["descriptions"]=>
        object(stdClass)#13 (1) {
          ["pd"]=>
          array(4) {
            [0]=>
            object(stdClass)#14 (1) {
              ["t"]=>
              int(2)
            }
            [1]=>
            object(stdClass)#15 (1) {
              ["t"]=>
              int(1)
            }
            [2]=>
            object(stdClass)#16 (1) {
              ["t"]=>
              int(3)
            }
            [3]=>
            object(stdClass)#17 (1) {
              ["t"]=>
              int(0)
            }
          }
        }
        ["id"]=>
        int(1011038602)
      }
    }
  }
  ["count"]=>
  int(921)
}

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-15 09:58 UTC] darkservant at gmail dot com
Also happens on Windows and PHP 5.2.9 where a soap response contains a namespace:

SOAP Response containing
<TOKEN xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:nil="false">xyz</TOKEN>

produces a

TOKEN => NULL

instead of 

TOKEN => xyz

inside the response object.
 [2009-12-08 20:48 UTC] felipe@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-12-09 18:22 UTC] justin dot hendrickson at gmail dot com
No good. The descriptions are still missing the relevant information.

  ["descriptions"]=>
  object(stdClass)#17 (1) {
    ["pd"]=>
    array(4) {
      [0]=>
      object(stdClass)#18 (1) {
        ["t"]=>
        int(1)
      }
      [1]=>
      object(stdClass)#19 (1) {
        ["t"]=>
        int(2)
      }
      [2]=>
      object(stdClass)#20 (1) {
        ["t"]=>
        int(3)
      }
      [3]=>
      object(stdClass)#21 (1) {
        ["t"]=>
        int(0)
      }
    }
  }

$> php -v
PHP 5.2.12RC4-dev (cli) (built: Dec  9 2009 09:56:13) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2009 Zend Technologies
 [2011-04-08 18:24 UTC] mail2alfonso at yahoo dot com
Was this bug ever assigned to anyone?

Still reproducible in 5.3.

SOAP XML Response:
------------------
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <soap:Header/>
  <soap:Body>
    <GetBeeSerialSavingsClubSummaryOpenResponse xmlns="[REMOVED]">
      <SerialSummaryResult>
        <SerialSummaries>
          <SavingsClubSerialSummary>
            <SerialNumber>69956</SerialNumber>
            <ExpirationDate IsNull="false" DateTimeValue="2011-08-07T09:21:44.1400000-05:00"/>
            <IssueDate IsNull="false" DateTimeValue="2011-02-07T09:21:44.1400000-06:00"/>
            <InitialValue IsNull="false" DecimalValue="100.0000"/>
            <CurrentValue IsNull="false" DecimalValue="100"/>
          </SavingsClubSerialSummary>
          <SavingsClubSerialSummary>
            <SerialNumber>77847</SerialNumber>
            <ExpirationDate IsNull="false" DateTimeValue="2011-09-04T10:23:05.5300000-05:00"/>
            <IssueDate IsNull="false" DateTimeValue="2011-03-04T10:23:05.5300000-06:00"/>
            <InitialValue IsNull="false" DecimalValue="100.0000"/>
            <CurrentValue IsNull="false" DecimalValue="100"/>
          </SavingsClubSerialSummary>
          <SavingsClubSerialSummary>
            <SerialNumber>76180</SerialNumber>
            <ExpirationDate IsNull="false" DateTimeValue="2011-08-19T04:13:01.0970000-05:00"/>
            <IssueDate IsNull="false" DateTimeValue="2011-02-19T04:13:01.0970000-06:00"/>
            <InitialValue IsNull="false" DecimalValue="100.0000"/>
            <CurrentValue IsNull="false" DecimalValue="100"/>
          </SavingsClubSerialSummary>
          <SavingsClubSerialSummary>
            <SerialNumber>09896</SerialNumber>
            <ExpirationDate IsNull="false" DateTimeValue="2011-07-26T10:21:46.4330000-05:00"/>
            <IssueDate IsNull="false" DateTimeValue="2011-01-26T10:21:46.4330000-06:00"/>
            <InitialValue IsNull="false" DecimalValue="100.0000"/>
            <CurrentValue IsNull="false" DecimalValue="100"/>
          </SavingsClubSerialSummary>
          <SavingsClubSerialSummary>
            <SerialNumber>MG_20110405-1</SerialNumber>
            <ExpirationDate IsNull="false" DateTimeValue="2011-10-02T17:17:46.1570000-05:00"/>
            <IssueDate IsNull="false" DateTimeValue="2011-04-05T00:00:00.0000000-05:00"/>
            <InitialValue IsNull="false" DecimalValue="500.0000"/>
            <CurrentValue IsNull="false" DecimalValue="500"/>
          </SavingsClubSerialSummary>
          <SavingsClubSerialSummary>
            <SerialNumber>07724</SerialNumber>
            <ExpirationDate IsNull="false" DateTimeValue="2011-07-31T22:33:00.1300000-05:00"/>
            <IssueDate IsNull="false" DateTimeValue="2011-01-31T22:33:00.1300000-06:00"/>
            <InitialValue IsNull="false" DecimalValue="100.0000"/>
            <CurrentValue IsNull="false" DecimalValue="100"/>
          </SavingsClubSerialSummary>
        </SerialSummaries>
      </SerialSummaryResult>
    </GetBeeSerialSavingsClubSummaryOpenResponse>
  </soap:Body>
</soap:Envelope>

Object Returned by SoapClient (in print_r format):
--------------------------------------------------

stdClass Object
(
    [SerialSummaries] => stdClass Object
        (
            [SavingsClubSerialSummary] => Array
                (
                    [0] => stdClass Object
                        (
                            [SerialNumber] => 69956
                            [ExpirationDate] =>
                            [IssueDate] =>
                            [InitialValue] =>
                            [CurrentValue] =>
                        )
                    [1] => stdClass Object
                        (
                            [SerialNumber] => 77847
                            [ExpirationDate] =>
                            [IssueDate] =>
                            [InitialValue] =>
                            [CurrentValue] =>
                        )
                    [2] => stdClass Object
                        (
                            [SerialNumber] => 76180
                            [ExpirationDate] =>
                            [IssueDate] =>
                            [InitialValue] =>
                            [CurrentValue] =>
                        )
                    [3] => stdClass Object
                        (
                            [SerialNumber] => 09896
                            [ExpirationDate] =>
                            [IssueDate] =>
                            [InitialValue] =>
                            [CurrentValue] =>
                        )
                    [4] => stdClass Object
                        (
                            [SerialNumber] => MG_20110405-1
                            [ExpirationDate] =>
                            [IssueDate] =>
                            [InitialValue] =>
                            [CurrentValue] =>
                        )
                    [5] => stdClass Object
                        (
                            [SerialNumber] => 07724
                            [ExpirationDate] =>
                            [IssueDate] =>
                            [InitialValue] =>
                            [CurrentValue] =>
                        )
                )
        )
)

As you can see, the attributes are NOT populated with the appropriate values.

$ php -v
PHP 5.3.2-1ubuntu4.7 with Suhosin-Patch (cli) (built: Jan 12 2011 18:36:55) 
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
    with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans
 [2016-03-17 09:02 UTC] florian dot eberle at gmail dot com
This annoying bug is sadly still present in the current version PHP 7.0.4. Id be happy if someone could have a look at this :/ Thanks!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC