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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: privat at timohummel dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 17:01:29 2024 UTC