|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #52791 SoapServer doesn't convert objects into SOAP Response
Submitted: 2010-09-07 11:22 UTC Modified: -
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: privat at timohummel dot com Assigned:
Status: Open Package: SOAP related
PHP Version: 5.3.3 OS: Gentoo
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-09-07 11:22 UTC] privat at timohummel dot com

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 

I have created a simple WSDL (see ) 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);


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:
/* Use the example WSDL from 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")));



Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 23 19:01:38 2024 UTC