Bug #79210 [Com]: WSDL maxOccurs/minOccurs attributes are ignored when set in 'sequence' node

From: Date: Sun, 02 Feb 2020 01:21:32 +0000
Subject: Bug #79210 [Com]: WSDL maxOccurs/minOccurs attributes are ignored when set in 'sequence' node
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225299@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79210&edit=1 ID: 79210 Comment by: carlos dot godo at outlook dot com Reported by: carlos dot godo at outlook dot com Summary: WSDL maxOccurs/minOccurs attributes are ignored when set in 'sequence' node Status: Open Type: Bug Package: SOAP related Operating System: ubuntu18.04 PHP Version: 7.2.27 Block user comment: N Private report: N New Comment: Thanks for reviewing. For more than one element, my guess is that maxOccurs/minOccurs attributes apply to all child elements of the sequence that do not specify their own attributes. Yes, modifying the schema would be the easiest workaround. In my case that schema belongs to an external API, so I'll have to download the schema, parse it and fix it locally before consuming the API. Previous Comments: ------------------------------------------------------------------------ [2020-02-02 01:00:38] requinix@php.net Yes, you are right. There is a distinct issue here about maxOccurs only being respected for <element>s and <any>s, and not <sequence>s or other types. In the case of a sequence with one element, the obvious workaround is to put maxOccurs on the element. For more than one element, I'm not sure. ------------------------------------------------------------------------ [2020-02-02 00:28:13] carlos dot godo at outlook dot com I disagree about this being a duplicate of the other bug just because it also talks about maxOccurs. This bug talks about maxOccurs/minOccurs being ignored if it is set in the 'sentence' node. Meaning SoapClient won't accept an array as input when it should. In the other bug maxOccurs does not validate the number elements if set >1. It has nothing to do with this apart of talking about the same attribute. ------------------------------------------------------------------------ [2020-02-01 23:25:35] requinix@php.net Duplicate of bug #78749 ------------------------------------------------------------------------ [2020-02-01 23:16:35] carlos dot godo at outlook dot com Description: ------------ When parsing WSDL, SoapClient ignores maxOccurs or minOccurs attributes when they are set on the 'sequence' node, instead of on the 'element' node. Below there's an example of a WSDL type that causes the issue. See that the 'sequence' element for "persons" has maxOccurs="unbounded". <element name="persons"> <complexType> <sequence maxOccurs="unbounded"> <element name="person"> <complexType> <sequence> <element name="full_name" type="xsd:string"/> </sequence> </complexType> </element> </sequence> </complexType> </element> The data that would match this complexType would be: $data = (object)[ 'persons' => (object)[ 'person' => [ (object)['full_name' => 'Person One'], (object)['full_name' => 'Person Two'], (object)['full_name' => 'Person Three'], ] ], ]; However, since maxOccurs is ignored, SoapClient expects "person" to be an object containing a 'full_name' property. Since instead it finds an array, it fails with the following error: SOAP-ERROR: Encoding: object has no 'full_name' property. Expected result: ---------------- <persons> <person> <full_name>Person One</full_name> </person> <person> <full_name>Person Two</full_name> </person> <person> <full_name>Person Three</full_name> </person> </persons> Actual result: -------------- SOAP-ERROR: Encoding: object has no 'full_name' property ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79210&edit=1

« previous php.bugs (#225299) next »