Bug #45155 [Com]: Constructors not called when using classmap option in SoapClient

From: Date: Fri, 04 Sep 2015 10:51:38 +0000
Subject: Bug #45155 [Com]: Constructors not called when using classmap option in SoapClient
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195758@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=45155&edit=1 ID: 45155 Comment by: php at hotblocks dot nl Reported by: david at globulebleu dot com Summary: Constructors not called when using classmap option in SoapClient Status: Open Type: Bug Package: SOAP related Operating System: * PHP Version: 5.2.6 Block user comment: N Private report: N New Comment: Still a problem on PHP 5.5.21-1+deb.sury.org~precise+2 Neither __construct nor __wakeup is called. @miceleparkip The server doesn't create objects, it sends XML. The client decodes that XML and creates the objects. Source: http://lxr.php.net/xref/PHP_5_5/ext/soap/php_encoding.c#1479 (I think) Previous Comments: ------------------------------------------------------------------------ [2012-11-16 10:40:48] miceleparkip at web dot de This is not a bug. It's quite normal. The soap object is created on the server side. So the constructor is just called on the server. Note: This is not a technical question - the programmers of Soap-PHP just couldn't implement it. It's against the principle of webserivces. Logical on the client no __construct neither __wakeup is called. On the other hand no __destruct neither __sleep is called on the server - but on the client. If you want to initialize some data after receiving the soap object, you have to use a conventional function. "webservice objects" are NEVER created on the client side! ------------------------------------------------------------------------ [2012-05-03 13:09:10] andyidol at gmail dot com 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(); } ?> ------------------------------------------------------------------------ [2011-05-04 18:22:02] kissifrot at gmail dot com Same problems happens with PHP 5.3.6 (dotdeb version) on Lenny. This is quite annoying as we cannot later call the created object's methods due to some logic done in the constructor (such as sanitizing for instance) which is missing. ------------------------------------------------------------------------ [2010-05-04 18:10:39] philipp dot kempgen at amooma dot de Same thing applies to SoapServer as well. ------------------------------------------------------------------------ [2010-05-04 18:03:36] philipp dot kempgen at amooma dot de Bug still found in PHP 5.3.2. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=45155 -- Edit this bug report at https://bugs.php.net/bug.php?id=45155&edit=1

« previous php.bugs (#195758) next »