Strange problems with PHP SOAP (private variable not persist + variables passed from client not work
- by Tamas Gal
I have a very strange problems in a PHP Soap implementation.
I have a private variable in the Server class which contains the DB name for further reference. The private variable name is "fromdb". I have a public function on the soap server where I can set this variable. $client-setFromdb. When I call it form my client works perfectly and the fromdb private variable can be set. But a second soap client call this private variable loses its value... Here is my soap server setup:
ini_set('soap.wsdl_cache_enabled', 0);
ini_set('session.auto_start', 0);
ini_set('always_populate_raw_post_data', 1);
global $config_dir;
session_start();
/*if(!$HTTP_RAW_POST_DATA){
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
}*/
$server = new SoapServer("{$config_dir['template']}import.wsdl");
$server-setClass('import');
$server-setPersistence(SOAP_PERSISTENCE_SESSION);
$server-handle();
Problem is that I passed this to the server:
$client = new SoapClient('http://import.ingatlan.net/wsdl', array('trace' = 1));
$xml='';
$xml.='';
$xml.='';
$xml.='';
$xml.='Valaki';
$xml.='';
$xml.='';
$xml.='';
$xml.='';
$tarray = array("type" = 1, "xml" = $xml);
try{
$s = $client-sendXml( $tarray );
print "$s";
}
catch( SOAPFault $exception){
print "--- SOAP exception :{$exception}---";
print "LAST REQUEST :";
var_dump($client-_getLastRequest());
print "---";
print "LAST RESPONSE :".$client-_getLastResponse();
}
So passed an Array of informations to the server. Then I got this exception:
LAST REQUEST :
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><type>Array</type><xml/></SOAP-ENV:Body></SOAP-ENV:Envelope>
Can you see the Array word between the type tag? Seems that the client only passed a reference or something like this. So I totaly missed :(