IT. Expert System.

PHP

Sets SoapServer persistence mode


SoapServer::setPersistence

(PHP 5 >= 5.1.2)

SoapServer::setPersistenceSets SoapServer persistence mode

Description

public void SoapServer::setPersistence ( int $mode )

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.

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 does 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.

Return Values

No value is returned.

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());
 }
?>

See Also



Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

License.
All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 1298 / . Delta: 0.02891 с