note 119719 added to soapclient.soapcall
| From: | arturklesun at gmail dot com | Date: | Wed, 10 Aug 2016 18:16:34 +0000 |
| Subject: | note 119719 added to soapclient.soapcall | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-206253@lists.php.net to get a copy of this message | ||
Sharing my experience cuz i believe it is most important for you if you decide to use this Soap
Client implementation.
At php 7.0.8 the stdClass generated by SoapClient from the response does not use
"minOccurs" and "maxOccurs" WSDL modifiers to distinct properties in stdClass-es
(aka keys in "associative arrays") and elements in arrays ("aka indexed
arrays").
Instead, the implementation decides whether tag is _a key in associative array_ or _one of elements
with same tag in indexed array_ by simply the fact whether there is just one element with such tag
in the sequence or many.
Consider alive example from my case:
<?php
response xml:
...
<ValidatingCarrier>
<Alternate>AA</Alternate>
</ValidatingCarrier>
...
<ValidatingCarrier>
<Alternate>AA</Alternate>
<Alternate>AY</Alternate>
</ValidatingCarrier>
...
response structure generated by SoapClient:
...
[ValidatingCarrier] => stdClass Object(
[Alternate] => AA // here it is a string
)
...
[ValidatingCarrier] => stdClass Object (
[Alternate] => Array ( // and here this is an array
[0] => AA
[1] => AY
)
)
...
field XSD definition:
<xs:element name="Alternate" type="CarrierCode" minOccurs="0"
maxOccurs="24">
?>
You see, the definition in XSD tells us this tag can be repeated up to 24 times, what means it would
be an indexed array, but SoapClient does not take that into account and treats the first
<Alternate> in example as a value instead of array containing this value.
Undoubtedly, a value should be a property in the stdClass (a key in associative array) _only_ when
maxOccurs is 1 or less or not specified (default is 1, see https://www.w3.org/TR/xmlschema-0/#OccurrenceConstraints).
Hope this info will be useful for you when you will be implementing your own, correctly working,
SoapClient.
----
Server IP: 72.52.91.14
Probable Submitter: 91.90.249.76
----
Manual Page -- http://php.net/manual/en/soapclient.soapcall.php
Edit -- https://master.php.net/note/edit/119719
Del: integrated -- https://master.php.net/note/delete/119719/integrated
Del: useless -- https://master.php.net/note/delete/119719/useless
Del: bad code -- https://master.php.net/note/delete/119719/bad+code
Del: spam -- https://master.php.net/note/delete/119719/spam
Del: non-english -- https://master.php.net/note/delete/119719/non-english
Del: in docs -- https://master.php.net/note/delete/119719/in+docs
Del: other reasons-- https://master.php.net/note/delete/119719
Reject -- https://master.php.net/note/reject/119719
Search -- https://master.php.net/manage/user-notes.php