|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-06-03 09:43 UTC] david at globulebleu dot com
Description:
------------
When using classmap to map the SOAP results to a class, the constructor of the object you've mapped to is not called.
Reproduce code:
---------------
$client = new SoapClient("url_to_wsdl",
array('classmap' => array('contact' => "Contact"));
$params = array("1");
$contact = $client->__soapCall("get_contact", $params);
Expected result:
----------------
A contact object that has properties initialized (i.e. db connections, ...).
Actual result:
--------------
A contact object without the properties.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 03:00:02 2025 UTC |
Same here with 5.3.10. Maybe such classes should implement some specific interface (to avoid situation when class constructor has some required arguments) and to add some extra functionality, e.g: <?php interface SoapResult { public function __construct(); public function afterDeserialize(); } ?>It's even weirder than just that. This will fail silently, no errors, just no results: ==== class MySoapObject {} abstract class MyAppointment extends MySoapObject { abstract function getLabel(); } class MyClientAppointment extends MyAppointment { // NO implementation of getLabel() } $soap = new SoapClient($wsdl, array('classmap' => array('Appointment' => 'MyClientAppointment'))); $appointments = $soap->GetAppointmentsList(array('foo' => 'bar')); ==== $appointments will be FALSE or NULL. No errors. The reason is that `MyClientAppointment` doesn't implement `getLabel()`. I would have expected a very fatal error about that missing implementation. After implementing `getLabel()`, it works like a charm. Normal PHP would complain about this, wouldn't it? 'classmap' really needs normal object instantiation...