From: Operating system: Gentoo PHP version: 5.3.3 Package: SOAP related Bug Type: Bug Bug description:SoapServer doesn't convert objects into SOAP Response
Description: ------------ Hi, I'm using SoapServer and the classmap feature to convert WSDL Types into PHP classes. This works fine for input (SOAP-Envelope=>PHP), but not for output (PHP=>SOAP-Envelope). I have created a simple WSDL (see http://www.timohummel.com/test.wsdl ) which accepts the same WSDL type for input and output. For testing purposes, I simply return the input from the test call to the output, which fails with "SOAP-ERROR: Encoding: object hasn't 'username' property". If I add a "serialize" around $user, no error is thrown, but an empty object is returned. See below for the code. In my example PHP code, if I replace return array("User" => $user); with return array("User" => array("username" => 1, "password" => 2); it works. This means that the PHP SOAP extension does not convert an object to the WSDL datatype. If this is intentional, please document this in the online manual. Test script: --------------- <?php /* Use the example WSDL from http://www.timohummel.com/test.wsdl to test */ class User { public $username; public $password; } class UserService { public function createUser (User $user) { return array("User" => $user); // -> this doesn't work, throws an encoding error //return array("User" => array("username" => "1", "password" => "2">); -> this works, but isn't intented //return array("User" => serialize($user)); -> this doesn't work, returns an empty <User/> tag } } $server = new SoapServer("test.wsdl", array("cache_wsdl" => WSDL_CACHE_NONE, "classmap" => array("User" => "User"))); $server->setClass("UserService"); $server->handle(); ?> -- Edit bug report at http://bugs.php.net/bug.php?id=52791&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=52791&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=52791&r=trysnapshot53 Try a snapshot (trunk): http://bugs.php.net/fix.php?id=52791&r=trysnapshottrunk Fixed in SVN: http://bugs.php.net/fix.php?id=52791&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=52791&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=52791&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=52791&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=52791&r=needscript Try newer version: http://bugs.php.net/fix.php?id=52791&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=52791&r=support Expected behavior: http://bugs.php.net/fix.php?id=52791&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=52791&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=52791&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=52791&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52791&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=52791&r=dst IIS Stability: http://bugs.php.net/fix.php?id=52791&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=52791&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=52791&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=52791&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=52791&r=mysqlcfg