php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #38665 SOAP calls constructor twice when returning "void"
Submitted: 2006-08-31 07:59 UTC Modified: 2006-09-12 10:56 UTC
From: jsgoupil@php.net Assigned: dmitry (profile)
Status: Not a bug Package: SOAP related
PHP Version: 5.1.6 OS: WinXP
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 !
Your email address:
MUST BE VALID
Solve the problem:
47 - 45 = ?
Subscribe to this entry?

 
 [2006-08-31 07:59 UTC] jsgoupil@php.net
Description:
------------
I found a weird bug with SOAP/WSDL.
When calling a method which returns nothing (no output) at first time, the second method will call the constructor of the class again even if we are using the Persistence with SESSION.

Here 3 files:
 - test.wsdl
 - test.server.php
 - test.client.php

You have to change the url at the end of the test.wsdl to test this script

In the WSDL, the method "getTest1" returns nothing and "getTest2" returns a string.
If you run the script test.client.php now, you will get a file test.txt containing :

Call Constructor
Call Method 2
Call Method 1


Now, swap the rows 
var_dump($clientSOAP->getTest2());
var_dump($clientSOAP->getTest1());

and now the test.txt contains :

Call Constructor
Call Method 1
Call Constructor
Call Method 2

Reproduce code:
---------------
test.server.php
http://pastebin.com/780399

test.client.php
http://pastebin.com/780404

test.wsdl
http://pastebin.com/780402


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-31 08:26 UTC] tony2001@php.net
Assigned to the maintainer.
 [2006-08-31 11:01 UTC] dmitry@php.net
In your examle "getTest1" is one way operation, by default ext/soap doesn't wait response from such operations. It just send request and forget about it. As result client doesn't recives session id cookie and cannot establish session.

As workaround you can wait for one way operation.
To do this you should use "feature" option in SoapClient constructor.

$clientSOAP = new SoapClient('test.wsdl', array("features"=>SOAP_WAIT_ONE_WAY_CALLS));

As another workaround you can use two way operation first.

 [2006-09-09 04:18 UTC] jsgoupil@php.net
ok, that works.
Now, 
I set the SOAP_WAIT_ONE_WAY_CALLS into the client
and check the server now :

the test.txt contains :
Call Constructor
Call Method 2 VAL
Call Method 1 

and should contain : Call Method 1 VAL at the end...

test.server.php:
http://paste.uni.cc/9943

test.client.php
http://paste.uni.cc/9944

test.wsdl
http://paste.uni.cc/9945


 [2006-09-12 08:04 UTC] dmitry@php.net
SoapServer::setPersistence(SOAP_PERSISTENCE_SESSION) makes persistent only object of given class, but not the class staic data. Use "$this->v" instead of "self::$v" in your example and you will get that you like.
 [2006-09-12 10:56 UTC] jsgoupil@php.net
Ok, it's good to know, I'll document it in

/phpdoc/en/reference/soap/functions/soap-soapserver-setpersistence.xml
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 21:01:30 2024 UTC