|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 14 05:00:01 2025 UTC |
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>