php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53234 "SOAP-ERROR: Encoding: object hasn't 'xxx' property" for xsd-choice element
Submitted: 2010-11-03 10:51 UTC Modified: 2018-11-03 15:20 UTC
Votes:29
Avg. Score:4.5 ± 0.9
Reproduced:23 of 23 (100.0%)
Same Version:5 (21.7%)
Same OS:3 (13.0%)
From: vadim dot sacharow at pali dot de Assigned: cmb (profile)
Status: No Feedback Package: SOAP related
PHP Version: 5.2.14 OS: Windows XP
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-11-03 10:51 UTC] vadim dot sacharow at pali dot de
Description:
------------
I have the following xsd-part:
<xs:choice>
    <xs:sequence>
	<xs:element name="Company">
	    <xs:complexType>
		<xs:complexContent>
			<xs:extension base="Company"/>
		</xs:complexContent>
	    </xs:complexType>
	</xs:element>
	<xs:element name="ContactPerson" type="Person" minOccurs="0">
	</xs:element>
    </xs:sequence>
    <xs:element name="Person" type="Person">
    </xs:element>
</xs:choice>

Its a choice-element. I expect, that my request must have just one of following two elements:
a. sequence of Company and ContactPerson
b. Person

But when i try to send a request, that has a Person, i get the SOAP-ERROR: Encoding: object hasn't 'Company' property

If i change the places of a and b in wsdl definition file - everything works perfect with Person.

I think, that SoapClient working in wsdl-mode doesn't understand the choice-element in the right way. SoapClient just takes the first one and says, that this element is required - but its false, because just one of the both (a or b) is required, and not the first element in the choice-group.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-03 10:54 UTC] vadim dot sacharow at pali dot de
The bug 50997 seems to describe the same problem
 [2010-11-03 14:06 UTC] vadim dot sacharow at pali dot de
Some new information: the problem occurs, if the first element of the choice-group is a xs:sequence. If the first element is a xs:element (xs:sequence as second element), then everything works fine.
 [2015-05-27 21:07 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2015-05-27 21:07 UTC] cmb@php.net
Bug #50997 has been fixed since a long time. Can this ticket also
be closed, Vadim?
 [2015-06-07 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2018-11-03 15:02 UTC] xt8848 at 126 dot xom
So sad, I met this problem. Anyone can help me?

php version information is:
PHP 7.1.14 (cli) (built: Feb  7 2018 18:33:30) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies

details in wsdl:
<xs:complexType name="organizationResponse">
<xs:sequence>
<xs:element minOccurs="0" name="code" type="xs:string"/>
<xs:element minOccurs="0" name="errorInfo" type="xs:string"/>
<xs:element minOccurs="0" name="msg" type="xs:string"/>
<xs:element maxOccurs="unbounded" minOccurs="0" name="result" nillable="true" type="tns:organizationReturnDetails"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="organizationReturnDetails">
<xs:sequence>
<xs:element minOccurs="0" name="financeOrgName" type="xs:string"/>
<xs:element minOccurs="0" name="orgAssociate" type="xs:string"/>
<xs:element minOccurs="0" name="orgCode" type="xs:string"/>
<xs:element name="orgId" type="xs:int"/>
<xs:element minOccurs="0" name="orgName" type="xs:string"/>
<xs:element minOccurs="0" name="orgNamePy" type="xs:string"/>
<xs:element name="orgType" type="xs:int"/>
<xs:element minOccurs="0" name="parentFinanceOrgName" type="xs:string"/>
<xs:element name="parentOrgAssociate" type="xs:int"/>
<xs:element minOccurs="0" name="parentOrgCode" type="xs:string"/>
<xs:element name="parentOrgId" type="xs:int"/>
<xs:element minOccurs="0" name="parentOrgName" type="xs:string"/>
<xs:element minOccurs="0" name="parentOrgNamePy" type="xs:string"/>
<xs:element name="parentOrgType" type="xs:int"/>
</xs:sequence>
</xs:complexType>

The error:
Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no 'orgAssociate' property in /Users/taoli/php-workspace/vendor/zendframework/zend-soap/src/Client.php:1166 Stack trace: #0 /Users/taoli/php-workspace/vendor/zendframework/zend-soap/src/Client.php(1166): SoapClient->__soapCall('getOrganization', Array, Array, Array, Array) #1 /Users/taoli/php-workspace/soap.php(30): Zend\Soap\Client->__call('getOrganization', Array) #2 {main} thrown in /Users/taoli/php-workspace/vendor/zendframework/zend-soap/src/Client.php on line 1166
 [2018-11-03 15:20 UTC] cmb@php.net
@xt8848: your problem doesn't seem to be related to this ticket,
since there is no xs:choice involved in your WSDL.  Please open a
new ticket.
 [2019-03-26 11:43 UTC] shr3k1 at gmail dot com
Similar problem with this XSD:

<xs:complexType name="NajdiOSRequestType">
	<xs:sequence>
		<xs:choice>
			<xs:sequence>
				<xs:element name="ico" type="bt:IcoType" minOccurs="0" maxOccurs="1" />
				<xs:element name="nazev" type="NazevVyhledaniType" minOccurs="0" maxOccurs="1" />
			</xs:sequence>
			<xs:sequence>
				<xs:element name="jmeno" type="JmenoVyhledaniType" minOccurs="0" />
				<xs:element name="prijmeni" type="PrijmeniVyhledaniType" minOccurs="0" />
				<xs:choice minOccurs="0">
					<xs:element name="rc" type="bt:RcKompletniType" />
					<xs:element name="datumNarozeni" type="xs:date" />
				</xs:choice>
				<xs:element name="adresniUdaje" type="AdresniUdajeType"  minOccurs="0" maxOccurs="1"/>
			</xs:sequence>
		</xs:choice>
		<xs:element name="datumK" type="xs:dateTime" minOccurs="0">
		</xs:element>
	</xs:sequence>
</xs:complexType>

ico and nazev requests are generated. jmeno, prijmeni, rc and datumNarozeni not (NajdiOSRequestType is empty). XSD must be modified to this:

<xs:complexType name="NajdiOSRequestType">
	<xs:sequence>
		<xs:sequence>
			<xs:element name="ico" type="bt:IcoType" minOccurs="0" maxOccurs="1" />
			<xs:element name="nazev" type="NazevVyhledaniType" minOccurs="0" maxOccurs="1" />
		</xs:sequence>
		<xs:sequence>
			<xs:element name="jmeno" type="JmenoVyhledaniType" minOccurs="0" />
			<xs:element name="prijmeni" type="PrijmeniVyhledaniType" minOccurs="0" />
			<xs:element name="rc" type="bt:RcKompletniType" minOccurs="0" />
			<xs:element name="datumNarozeni" type="xs:date" minOccurs="0" />
			<xs:element name="adresniUdaje" type="AdresniUdajeType"  minOccurs="0" maxOccurs="1"/>
		</xs:sequence>
		<xs:element name="datumK" type="xs:dateTime" minOccurs="0">
		</xs:element>
	</xs:sequence>
</xs:complexType>

to make it work properly. PHP 7.1.27 ...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 02:01:29 2024 UTC