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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC