Edit report at https://bugs.php.net/bug.php?id=78749&edit=1
ID: 78749
User updated by: tony at marston-home dot demon dot co dot uk
Reported by: tony at marston-home dot demon dot co dot uk
Summary: Wrong error message when maxOccurs is exceeded
Status: Open
Type: Bug
Package: SOAP related
Operating System: Windows 10
PHP Version: 7.3.11
Block user comment: N
Private report: N
New Comment:
That structure is perfectly valid according to the WSDL definition, and it validates using third
party tools such as OxygenXML and SOAPUI.
The XML I supplied contains three occurrences of <contact> and the SOAP Server ->handle()
method deals properly with these when the WSDL specifies maxOccurs of 3 or more.
If I set maxOccurs to 1 the error message is entirely wrong.
If I set maxOccurs to 2 there is no error message complaining that I have exceeded maxOccurs.
It is your validation of the structure which is wrong and not the structure itself.
Previous Comments:
------------------------------------------------------------------------
[2019-11-04 21:31:18] camporter1 at gmail dot com
It's possible that I'm not understanding the issue properly, but it seems like the issue
here is that 'first_name' is trying to be accessed on the array of 'contact',
which won't map to the type.
Replacing ArrayOfContactInfo with:
<xsd:complexType name="ArrayOfContactInfo">
<complexContent>
<restriction base="SOAP-ENC:Array">
<attribute ref="SOAP-ENC:arrayType" wsdl:arrayType="tns:contact[]"/>
</restriction>
</complexContent>
</xsd:complexType>
and removing the extra 'contact' array:
'contacts' => [
'0' => [
'title' => 'Mr',
'first_name' => 'Joe',
'middle_name' => 'Xavier',
'last_name' => 'Soap',
'contact_role' => 'Account Manager',
'telephone' => '075 40008000'
],
'1' => [
'title' => 'Mrs',
'first_name' => 'Jane',
'last_name' => 'Doe',
'contact_role' => 'Assistant Account Manager',
'telephone' => '075 40008001'
],
'2' => [
'title' => 'Miss',
'first_name' => 'Dee',
'last_name' => 'Meanour',
'contact_role' => 'Deputy Assistant Account Manager',
'telephone' => '075 40008003',
],
],
seems like it might be more in line with the expected behavior?
------------------------------------------------------------------------
[2019-10-25 17:11:24] tony at marston-home dot demon dot co dot uk
I have created a zip file containing the two files necessary to reproduce this fault as it simply
cannot be done in 20 lines of code or less. The WSDL file alone requires over 80 lines. This zip
file is available at:
https://www.tonymarston.net/php-mysql/gmx_soap_bug_report.zip
The 'contact' element in the WSDL file has a 'maxOccurs' attribute which I am
testing by sending 3 occurrences. If I set 'maxOccurs' to 1 it fails with
"SOAP-ERROR: Encoding object has no 'first_name' property" even though the array
does contain a value.
If I set 'maxOccurs' to 2 it does not fail (which it should as I have violated the
maximum) and it also sends all 3 occurrences to the server.
------------------------------------------------------------------------
[2019-10-24 19:43:07] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.
A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.
Please avoid embedding huge scripts into the report.
I may be misreading the source, but it looks like you're triggering a code path that only
occurs when there is no value available.
------------------------------------------------------------------------
[2019-10-24 18:29:46] tony at marston-home dot demon dot co dot uk
Description:
------------
In my WSDL I have a complexType entry which has a maxOccurs set to 1. If I exceed this limit the
error message says "SOAP-ERROR: Encoding object has no 'first_name' property"
where 'first_name' is the first required field in the enclosed structure.
Test script:
---------------
WSDL:
<xsd:complexType name="ArrayOfContactInfo">
<xsd:sequence>
<xsd:element name="contact" type="tns:contact" minOccurs="0"
maxOccurs="1"/>
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="contact">
<xsd:all>
<xsd:element name="title" type="xsd:string" minOccurs="0"
maxOccurs="1"/>
<xsd:element name="first_name" type="xsd:string" minOccurs="1"
maxOccurs="1"/>
<xsd:element name="middle_name" type="xsd:string" minOccurs="0"
maxOccurs="1"/>
<xsd:element name="last_name" type="xsd:string" minOccurs="1"
maxOccurs="1"/>
</xsd:all>
</xsd:complexType>
Expected result:
----------------
I expect a more meaningful error message such as "More than N occurrences exceeded"
Actual result:
--------------
The error message is totally misleading.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78749&edit=1