No cache version.

Caching disabled. Default setting for this page:enabled (code LNG204)
If the display is too slow, you can disable the user mode to view the cached version.

Rechercher une fonction PHP

SoapServer::setPersistence

(PHP 5, PHP 7)

SoapServer::setPersistenceSets SoapServer persistence mode

Description

public SoapServer::setPersistence ( int $mode ) : void

This function allows changing the persistence state of a SoapServer object between requests. This function allows saving data between requests utilizing PHP sessions. This method only has an affect on a SoapServer after it has exported functions utilizing SoapServer::setClass().

Note:

The persistence of SOAP_PERSISTENCE_SESSION makes only objects of the given class persistent, but not the class static data. In this case, use $this->bar instead of self::$bar.

Note:

SOAP_PERSISTENCE_SESSION serializes data on the class object between requests. In order to properly utilize resources (e.g. PDO), __wakeup() and __sleep() magic methods should be utilized.

PHP: SoapServer::setPersistence - Manual Home of Manuel PHP  Contents Haut

Parameters

mode

One of the SOAP_PERSISTENCE_XXX constants.

SOAP_PERSISTENCE_REQUEST - SoapServer data does not persist between requests. This is the default behavior of any SoapServer object after setClass is called.

SOAP_PERSISTENCE_SESSION - SoapServer data persists between requests. This is accomplished by serializing the SoapServer class data into $_SESSION['_bogus_session_name'], because of this session_start() must be called before this persistence mode is set.

PHP: SoapServer::setPersistence - Manual Home of Manuel PHP  Contents Haut

Examples

Example #1 SoapServer::setPersistence() example

<?php
 
class MyFirstPersistentSoapServer {
     private 
$resource// (Such as PDO, mysqli, etc..)
     
public $myvar1;
     public 
$myvar2;

     public function 
__construct() {
         
$this->__wakeup(); // We're calling our wakeup to handle starting our resource
     
}

     public function 
__wakeup() {
         
$this->resource CodeToStartOurResourceUp();
     }

     public function 
__sleep() {
         
// We make sure to leave out $resource here, so our session data remains persistent
         // Failure to do so will result in the failure during the unserialization of data
         // on the next request; thus, our SoapObject would not be persistent across requests.
         
return array('myvar1','myvar2');
     }
 }

 try {
     
session_start();
     
$server = new SoapServer(null, array('uri' => $_SERVER['REQUEST_URI']));
     
$server->setClass('MyFirstPersistentSoapServer');
     
// setPersistence MUST be called after setClass, because setClass's
     // behavior sets SESSION_PERSISTENCE_REQUEST upon enacting the method.
     
$server->setPersistence(SOAP_PERSISTENCE_SESSION);
     
$server->handle();
 } catch(
SoapFault $e) {
     
error_log("SOAP ERROR: "$e->getMessage());
 }
?>

Find a PHP function

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 30/01/2003, last modified the 26/10/2018
Source of the printed document:https://www.gaudry.be/en/php-rf-soapserver.setpersistence.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.

References

  1. View the html document Language of the document:fr Manuel PHP : http://php.net

These references and links indicate documents consulted during the writing of this page, or which may provide additional information, but the authors of these sources can not be held responsible for the content of this page.
The author This site is solely responsible for the way in which the various concepts, and the freedoms that are taken with the reference works, are presented here. Remember that you must cross multiple source information to reduce the risk of errors.

Contents Haut