|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41151 SOAP request is wrong when using subclass
Submitted: 2007-04-20 16:47 UTC Modified: 2007-05-28 15:11 UTC
From: m dot necib at akrobat dot fr Assigned: dmitry (profile)
Status: Not a bug Package: SOAP related
PHP Version: 5.2.1 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: m dot necib at akrobat dot fr
New email:
PHP Version: OS:


 [2007-04-20 16:47 UTC] m dot necib at akrobat dot fr
When using subclass as a value in WSDL mode,
the properties are written in the wrong order :
the child class properties are written _before_
the parent properties.

Reproduce code:

class A
public $a ;

class B extends A
public $b ;

$client = new SoapClient(...) ;

$var = new SoapVar( new B(), SOAP_ENC_OBJECT, 'B', 'http://myns/' ) ;
$client->foo($var) ;

Expected result:
SOAP request :

<parametres xsi:type="B" >

Actual result:
SOAP request :

<parametres xsi:type="B" >


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-20 16:55 UTC] m dot necib at akrobat dot fr

<complexType name="A">
      <element name="a" type="xsd:int"/>

<complexType name="B">
     <extension base="impl:A">
          <element name="b" type="xsd:int"/>
 [2007-05-02 08:40 UTC]
I just committed test file ext/soap/tests/schema/schema085.phpt, that demonstrates proper element ordering. In your example you probably do somthing wrong. I cannot say that exactly is wrong as you didn't provide full reproduce case, probably you object isn't encoded using WSDL.
In case if you like me to look into problem please provide full example (without ...) including full WSDL file.
 [2007-05-10 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2007-05-10 10:24 UTC] m dot necib at akrobat dot fr
Hello Dmitry,

Our situation is a bit different than what you have tested.
Here is the link to the WSDL :

Look at the complexType named "WSParameters".
It contains an element "loan" which type is "WSLoan".
But two types extend WSLoan : "WSLoanClassic" and "WSLoanPerso".

The Web Service expects us to send either of the inherited type.
WSLoan is an abstract type.

So in our case the correct type is not directly defined like in your
test case.

We are using SoapVar to specify the correct type of our object.
Then the generated SOAP request references the correct type.
But the fields are in the wrong order.

As you can see the WSDL file is generated by Apache Axis.
 [2007-05-10 14:15 UTC]
Not reprodusable.

Reproduce code:
class Loan {
	public $startingDate = "01-Jan-2007";
	public $amount;
	public $duration;
class LoanPersoItem {
	public $year;
	public $amount;
class LoanPerso extends Loan {
	public $loans;

$client = new SoapClient("",
		"location" => "test://",
		"trace" => 1,
		"exceptions" => 0,
) ;

$v = new LoanPerso();
$v->loans = new LoanPersoItem();
$var = new SoapVar($v , SOAP_ENC_OBJECT, 'WSLoanPerso', 'http://pricing.aigvienet/gb/snc/' ) ;

		"insured" => array(
			"name" => "Aaa",
			"firstname" => "Bbb",
			"birthdate" => "01-Jan-2006"
		"premiumMode" => 0,
		"loan" => $var,
		"option" => array(),
		"productCode" => "XXX"
) ;
echo $client->__getLastRequest();

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="" xmlns:ns1="http://pricing.aigvienet/gb/snc/" xmlns:xsi=""><SOAP-ENV:Body><ns1:processPricingSNC><parametres><ns1:insured><ns1:name>Aaa</ns1:name><ns1:firstname>Bbb</ns1:firstname><ns1:birthdate>01-Jan-2006</ns1:birthdate><ns1:profession xsi:nil="true"/></ns1:insured><ns1:premiumMode>0</ns1:premiumMode><ns1:loan xsi:type="ns1:WSLoanPerso"><ns1:startingDate>01-Jan-2007</ns1:startingDate><ns1:amount xsi:nil="true"/><ns1:duration xsi:nil="true"/><ns1:loans><ns1:year xsi:nil="true"/><ns1:amount xsi:nil="true"/></ns1:loans></ns1:loan><ns1:option/><ns1:promotional xsi:nil="true"/><ns1:quotity xsi:nil="true"/><ns1:couple xsi:nil="true"/><ns1:smoker xsi:nil="true"/><ns1:ds xsi:nil="true"/><ns1:productCode>XXX</ns1:productCode></parametres></ns1:processPricingSNC></SOAP-ENV:Body></SOAP-ENV:Envelope>

 [2007-05-24 16:42 UTC] m dot necib at akrobat dot fr
Hi !

Thanks for your help.
We found the problem, the service provider had changed 
the namespace URI without notifying us.
it is working with the correct URI.
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Mon Mar 20 17:03:40 2023 UTC