php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #44469 problems with creating xml from array(SOAPCLIENT)
Submitted: 2008-03-18 15:40 UTC Modified: 2009-05-06 01:00 UTC
Votes:6
Avg. Score:5.0 ± 0.0
Reproduced:6 of 6 (100.0%)
Same Version:5 (83.3%)
Same OS:1 (16.7%)
From: potyomkine at gmail dot com Assigned:
Status: No Feedback Package: SOAP related
PHP Version: 5.2.5 OS: FreeBSD
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: potyomkine at gmail dot com
New email:
PHP Version: OS:

 

 [2008-03-18 15:40 UTC] potyomkine at gmail dot com
Description:
------------
problem with creating xml from array 
I call function
$client = new SoapClient(WSDL);

$client->function($arr);

where var_dump($arr) === array(1) {
  ["Items"]=>
  array(1) {
    ["BatchFileItem"]=>
    array(1) {
      [0]=>
      array(9) {
        ["ProgMFG"]=>
        string(13) "progmfg-00000"
        ["ProdLine"]=>
        string(14) "prodline-00000"
        ["ArtNumber"]=>
        string(9) "art-00000"
        ["Vendor"]=>
        string(5) "Luval"
        ["Measure"]=>
        string(2) "kg"
        ["Group"]=>
        string(10) "skovorodki"
        ["Cube"]=>
        string(8) "232.5655"
        ["Weight"]=>
        string(9) "2323.2323"
        ["DescriptionList"]=>
        array(1) {
          ["LocalizedDescription"]=>
          array(3) {
            [0]=>
            array(2) {
              ["Language"]=>
              string(2) "EN"
              ["Description"]=>
              array(2) {
                ["Short"]=>
                string(15) "eng short descr"
                ["Long"]=>
                string(24) "english long description"
              }
            }
            [1]=>
            array(2) {
              ["Language"]=>
              string(2) "RU"
              ["Description"]=>
              array(2) {
                ["Short"]=>
                string(15) "rus short descr"
                ["Long"]=>
                string(24) "russian long description"
              }
            }
            [2]=>
            array(2) {
              ["Language"]=>
              string(2) "RU"
              ["Description"]=>
              array(2) {
                ["Short"]=>
                string(15) "rus short descr"
                ["Long"]=>
                string(24) "russian long description"
              }
            }
          }
        }
      }
    }
  }
}


but when I see request it is look like this

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/">
	<SOAP-ENV:Body>
		<ns1:function>
			
				<ns1:Items>
					<ns1:BatchFileItem>
						<ns1:ProgMFG>progmfg-00000</ns1:ProgMFG>
						<ns1:ProdLine>prodline-00000</ns1:ProdLine>
						<ns1:ArtNumber>art-00000</ns1:ArtNumber>
						<ns1:Vendor>Luval</ns1:Vendor>
						<ns1:Measure>kg</ns1:Measure>
						<ns1:Group>skovorodki</ns1:Group>
						<ns1:Cube>232.5655</ns1:Cube>
						<ns1:Weight>2323.2323</ns1:Weight>
					</ns1:BatchFileItem>
				</ns1:Items>
			
			</ns1:function>
	</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Reproduce code:
---------------
$client->function($arr);

where var_dump($arr) === array(1) {
  ["Items"]=>
  array(1) {
    ["BatchFileItem"]=>
    array(1) {
      [0]=>
      array(9) {
        ["ProgMFG"]=>
        string(13) "progmfg-00000"
        ["ProdLine"]=>
        string(14) "prodline-00000"
        ["ArtNumber"]=>
        string(9) "art-00000"
        ["Vendor"]=>
        string(5) "Luval"
        ["Measure"]=>
        string(2) "kg"
        ["Group"]=>
        string(10) "skovorodki"
        ["Cube"]=>
        string(8) "232.5655"
        ["Weight"]=>
        string(9) "2323.2323"
        ["DescriptionList"]=>
        array(1) {
          ["LocalizedDescription"]=>
          array(3) {
            [0]=>
            array(2) {
              ["Language"]=>
              string(2) "EN"
              ["Description"]=>
              array(2) {
                ["Short"]=>
                string(15) "eng short descr"
                ["Long"]=>
                string(24) "english long description"
              }
            }
            [1]=>
            array(2) {
              ["Language"]=>
              string(2) "RU"
              ["Description"]=>
              array(2) {
                ["Short"]=>
                string(15) "rus short descr"
                ["Long"]=>
                string(24) "russian long description"
              }
            }
            [2]=>
            array(2) {
              ["Language"]=>
              string(2) "RU"
              ["Description"]=>
              array(2) {
                ["Short"]=>
                string(15) "rus short descr"
                ["Long"]=>
                string(24) "russian long description"
              }
            }
          }
        }
      }
    }
  }
}


Expected result:
----------------
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/">
 <SOAP-ENV:Body>
  <ns1:function>
    <ns1:Items>
     <ns1:BatchFileItem>
      <ns1:ProgMFG>progmfg-00000</ns1:ProgMFG>
      <ns1:ProdLine>prodline-00000</ns1:ProdLine>
      <ns1:ArtNumber>art-00000</ns1:ArtNumber>
      <ns1:Vendor>Luval</ns1:Vendor>
      <ns1:Measure>kg</ns1:Measure>
      <ns1:Group>skovorodki</ns1:Group>
      <ns1:Cube>232.5655</ns1:Cube>
      <ns1:Weight>2323.2323</ns1:Weight>
      <ns1:DescriptionList>
        <ns1:LocalizedDescription>
          <ns1:Language>EN</ns1:Language>
          <ns1:Description>
           <ns1:Short>eng short descr</ns1:Short>
           <ns1:Long>english long description</ns1:Long>
          </ns1:Description>
        </ns1:LocalizedDescription>
        <ns1:LocalizedDescription>
          <ns1:Language>RU</ns1:Language>
          <ns1:Description>
           <ns1:Short>rus short descr</ns1:Short>
           <ns1:Long>russian long description</ns1:Long>
          </ns1:Description>
        </ns1:LocalizedDescription>
        <ns1:LocalizedDescription>
          <ns1:Language>RU</ns1:Language>
          <ns1:Description>
           <ns1:Short>rus short descr</ns1:Short>
           <ns1:Long>russian long description</ns1:Long>
          </ns1:Description>
        </ns1:LocalizedDescription>

      </ns1:DescriptionList>
     </ns1:BatchFileItem>
    </ns1:Items>
  </ns1:function>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Actual result:
--------------
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/">
 <SOAP-ENV:Body>
  <ns1:function>
    <ns1:Items>
     <ns1:BatchFileItem>
      <ns1:ProgMFG>progmfg-00000</ns1:ProgMFG>
      <ns1:ProdLine>prodline-00000</ns1:ProdLine>
      <ns1:ArtNumber>art-00000</ns1:ArtNumber>
      <ns1:Vendor>Luval</ns1:Vendor>
      <ns1:Measure>kg</ns1:Measure>
      <ns1:Group>skovorodki</ns1:Group>
      <ns1:Cube>232.5655</ns1:Cube>
      <ns1:Weight>2323.2323</ns1:Weight>
     </ns1:BatchFileItem>
    </ns1:Items>
  </ns1:function>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-07 15:41 UTC] aurelien at proprenetworks dot net
Maybe the same bug here with a simple case :

The array used to construct the xml

<?php
$param_searchPlace = array(
  'idProduct'	=>'15',
  'idSite'	=>'17'
);

$param_ctx = array(
  'idUser'	=>'someUser',
  'password'	=>'somePassword',
  'language'	=>'fr',
  'arrival'	=>'2008-10-01T00:00:00+02:00',
  'duration'	=>'P5D',
  'person'	=>'4',
  'deltaArrival'	=>'3',
  'deltaDuration'	=>'2',
  'searchPlace'	=>$param_searchPlace
);

$parametres = array( 'RequestCpgAvailability'	=>$param_ctx );
?>

The resulting XML :
<soap-env:body>
  <ns1:cpg_Availability>
    <RequestCpgAvailability_1>
      <idUser>someUser</idUser>
      <password>somePassword</password>
      <language>fr</language>
      <arrival>2008-10-01T00:00:00+02:00</arrival>
      <deltaArrival>3</deltAarrival>
      <deltaDuration>2</deltaDuration>
      <duration>P5D</duration>
      <person>4</person>
      <searchPlace>
        <idProduct>
          <idSite>17</idSite>
        </idProduct>
      </searchPlace>
    </RequestCpgAvailability_1>
  </ns1:cpg_Availability>
</soap-env:body>

The expected XML :
<soap-env:body>
  <ns1:cpg_Availability>
    <RequestCpgAvailability_1>
      <idUser>someUser</idUser>
      <password>somePassword</password>
      <language>fr</language>
      <arrival>2008-10-01T00:00:00+02:00</arrival>
      <deltaArrival>3</deltAarrival>
      <deltaDuration>2</deltaDuration>
      <duration>P5D</duration>
      <person>4</person>
      <searchPlace>
        <idProduct>15</idProduct>
        <idSite>17</idSite>
      </searchPlace>
    </RequestCpgAvailability_1>
  </ns1:cpg_Availability>
</soap-env:body>
 [2008-10-02 19:16 UTC] bugs dot php dot net at ceesco dot com
I think the SOAP client can't handle complex types and nested nodes.
 [2009-04-28 18:37 UTC] jani@php.net
Please try using this CVS snapshot:

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

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


 [2009-05-06 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC