php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34218 Problem with inheritance (by extension) in request (methods argument)
Submitted: 2005-08-23 10:16 UTC Modified: 2006-03-03 09:18 UTC
Votes:11
Avg. Score:5.0 ± 0.0
Reproduced:9 of 9 (100.0%)
Same Version:3 (33.3%)
Same OS:3 (33.3%)
From: Wojciech dot Szela at gmail dot com Assigned:
Status: No Feedback Package: SOAP related
PHP Version: 5.0.4 OS: SuSe Linux 9.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
48 - 7 = ?
Subscribe to this entry?

 
 [2005-08-23 10:16 UTC] Wojciech dot Szela at gmail dot com
Description:
------------
There's a problem with objects' class name received by soap server, when passed in request object is inheriting from other one. For example:
data type definition in wsdl:
<xsd:complexType name="Vehicle">
 <xsd:all>
  <xsd:element name="loadWeight" type="xsd:int"></xsd:element>
 </xsd:all>
</xsd:complexType>

<xsd:complexType name="Car">
 <xsd:complexContent>
  <xsd:extension base="tns:Vehicle">
   <xsd:all>
    <xsd:element name="engineNumber" type="xsd:string"></xsd:element>
   </xsd:all>
  </xsd:extension>
 </xsd:complexContent>
</xsd:complexType>

Second object is inheriting from the first one. And we have operation defined like that:
<wsdl:message name="addCarResponse">
 <wsdl:part name="return" type="tns:Car"></wsdl:part>
</wsdl:message>
<wsdl:message name="addCarRequest">
 <wsdl:part name="car" type="tns:Car"></wsdl:part>
</wsdl:message>

<wsdl:operation name="addCar">
 <soap:operation soapAction="http://www.foo.com/VehicleService/addCar"/>
  <wsdl:input>
   <soap:body use="encoded" namespace="http://www.foo.com/VehicleService/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  </wsdl:input>
  <wsdl:output><soap:body use="encoded" namespace="http://www.foo.com/VehicleService/" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  </wsdl:output>
</wsdl:operation>

Soap client is written in Java (axis). Method addCar is invoked with variable of type Car. Soap server (PHP5) receives proper structure of object - it has all fields, inherited from father and it's own, but get_class(passedObject) returns father's class name (Vehicle). Class mapping is correct. WSDL file is correct. Even returned object, also of type Car, is correct. 

Reproduce code:
---------------
$classmap = array( 'Car' => 'Car', 'Vehicle' => 'Vehicle' );
class fooService {
 public addCar($car) {
  $fh = fopen("foo.txt","a+"); fwrite($fh,get_class($car)+"\n"); fwrite($fh,var_export($car,true)); fclose($fh);
  $storedObject = $this->storeInDB($car);
  return $storedObject;
 }
ini_set('soap.wsdl_cache_enabled',"0");
$server = new SoapServer('fooService.wsdl',array('classmap' => $classmap');
$server->setClass(fooService);
$server->handle();

Expected result:
----------------
File content:
Car
Car: loadWeight->someValue
Car: engineNumber->someOtherValue

Actual result:
--------------
File content:
Vehicle
Vehicle: loadWeight->someValue
Vehicle: engineNumber->someOtherValue

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-08-23 13:24 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5-win32-latest.zip


 [2005-08-31 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".
 [2006-01-24 00:51 UTC] hjiverson at plauditdesign dot com
I have a little bit to add to this bug, I think I am experiencing it as well. There are two outcomes, depending if you add the base class to the classmap or not: 

If the base class IS in the classmap it gives the error "Cannot instantiate abstract class IProduct"; when I take away the xs:extension and paste the fields from IProduct to Product within the WSDL the problem goes away. So it is as if it's trying to instantiate the base class, as it is doing to the other person experiencing this bug.

If the base class is NOT in the classmap (but the subclass still is), it returns the result as a stdClass.

My WSDL schema is as follows:

 <xs:complexType name="IProduct">
    <xs:all>
     ...
    </xs:all>
 </xs:complexType>
 <xs:complexType name="Product">
 	 <xs:complexContent>
		<xs:extension base="tns:IProduct"> 
		    <xs:all>
		     ...
		    </xs:all>
	    </xs:extension> 
    </xs:complexContent>
 </xs:complexType>

Message:
    <message name="getProduct-response">
        <part name="result" type="types:Product"/>
    </message>

PHP classes:
abstract class IProduct {
    ...
}
class Product extends IProduct {
    ...
}

Classmap (shared by client and server):
array( 
    ...
    "IProduct" => "IProduct",
    "Product" => "Product"
);


Thanks,
Harlan Iverson
 [2006-03-03 09:18 UTC] dmitry@php.net
The same as #36575 (Incorrect complex type instantiation with hierarchies).
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 06:01:28 2024 UTC