php.net |  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: -
Votes:2
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
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:
46 - 29 = ?
Subscribe to this entry?

 
 [2010-09-07 11:22 UTC] privat at timohummel dot com
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();

?>


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sat Jun 03 21:03:40 2023 UTC