PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

SoapVar->__construct()> <SoapServer->setClass()
Last updated: Fri, 11 Apr 2008

view this page in

SoapServer->setPersistence()

(PHP 5 >= 5.1.2)

SoapServer->setPersistence() — Sets persistence mode of SoapServer

Descrizione

SoapServer
void setPersistence ( int $mode )

This function allows saving data between requests in a PHP session. It works only with a server that exports functions from a class with SoapServer->setClass().

Elenco dei parametri

mode

One of the SOAP_PERSISTENCE_XXX constants.

Valori restituiti

Nessun valore viene restituito.

Esempi

Example #1 Some examples

<?php

$server
->setPersistence(SOAP_PERSISTENCE_SESSION);

$server->setPersistence(SOAP_PERSISTENCE_REQUEST);

?>

Nota: The persistence SOAP_PERSISTENCE_SESSION makes persistent only object of given class, but not the class static data. You may use $this->bar instead of self::$bar.



SoapVar->__construct()> <SoapServer->setClass()
Last updated: Fri, 11 Apr 2008
 
add a note add a note User Contributed Notes
SoapServer->setPersistence()
boogiebug at gmail dot com
25-Mar-2008 08:40
setPersistence works only for a single instance of service class.

To use multiple instance of services objects, you need to instantiate the classes into objects and use an undocumented SoapServer's method - setObject() to add the service object into the SoapServer object, and handle the service object persistence with $_SESSION instead.

For example:

$ServiceObjects = array()
$ServiceObjects[0] = new ServiceClass1();
$ServiceObjects[1] = new ServiceClass2();
$ServiceObjects[2] = new ServiceClass3();

$_SESSION['ServiceClass1'] = $ServiceObjects[0];
$_SESSION['ServiceClass2'] = $ServiceObjects[1];
$_SESSION['ServiceClass3'] = $ServiceObjects[2];

...

$Servers = array()
for ( $i = 0; $i < count($ServiceObjects); i++)
{
  $s = new SoapServer($wsdl);
  $s->setObject($ServiceObject[$i]);
  $Servers[] = $s;
}

...

$Server[$i]->handle()

...
jan at pinna dot nl
26-Jan-2008 03:28
I found that using both modes (SOAP_PERSISTENCE_SESSION and SOAP_PERSISTENCE_REQUEST) cannot be used simultaniously. Because it didn't work at once, I started experimenting by using different settings and as stated below in the comments, "...also use SOAP_PERSISTENCE_REQUEST to save objects between requests" led me to think it was nessecary to use both modes. Well, it might for others, be but for me it turned out a day of freaking out ;) (trying all kinds of session stuff, etc etc).
Also, if persistence doesn't work, please check if session_start() is called somewhere in the script and try not to call it twice or whatsoever: it won't work...
leon at leonsio dot com
05-Jan-2008 01:10
attention, if you are using a custon session-handler, the SOAP_PERSISTENCE_SESSION methode will use the files-session handler and not your custom handler. also use SOAP_PERSISTENCE_REQUEST to save objects between requests
jared at ws-db dot com
28-Aug-2005 12:07
I had some issues getting session persistence (SOAP_PERSISTENCE_SESSION) to work. I finally got it working after setting session.auto_start=0, and then only calling session_start() in the script containing the SoapServer. Maybe this is obvious, but took me a bit to figure it out.

I only tried it with session.use_cookies=1, so if the settings above don't work for you, make sure cookies are enabled, though it may work without the need for cookies.
cperez1000 at hotmail dot com
28-May-2005 08:54
Always remember to place the "setPersistence" method before the handle method, otherwise it won't work.  It sounds obvious, but it's still a very common mistake, since no errors are shown.

SoapVar->__construct()> <SoapServer->setClass()
Last updated: Fri, 11 Apr 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites