本文整理汇总了PHP中SoapServer::setPersistence方法的典型用法代码示例。如果您正苦于以下问题:PHP SoapServer::setPersistence方法的具体用法?PHP SoapServer::setPersistence怎么用?PHP SoapServer::setPersistence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoapServer
的用法示例。
在下文中一共展示了SoapServer::setPersistence方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build
/**
* Finally returns a SoapClient instance.
*
* @return \BeSimple\SoapServer\SoapServer
*/
public function build()
{
$this->validateOptions();
use_soap_error_handler($this->errorReporting);
$server = new SoapServer($this->wsdl, $this->getSoapOptions());
if (null !== $this->persistence) {
$server->setPersistence($this->persistence);
}
if (null !== $this->handlerClass) {
$server->setClass($this->handlerClass);
} elseif (null !== $this->handlerObject) {
$server->setObject($this->handlerObject);
}
return $server;
}
示例2: _getSoap
/**
* Get SoapServer object
*
* Uses {@link $_wsdl} and return value of {@link getOptions()} to instantiate
* SoapServer object, and then registers any functions or class with it, as
* well as peristence.
*
* @return SoapServer
*/
protected function _getSoap()
{
$options = $this->getOptions();
$server = new SoapServer($this->_wsdl, $options);
if (!empty($this->_functions)) {
$server->addFunction($this->_functions);
}
if (!empty($this->_class)) {
$args = $this->_classArgs;
array_unshift($args, $this->_class);
call_user_func_array(array($server, 'setClass'), $args);
}
if (!empty($this->_object)) {
$server->setObject($this->_object);
}
if (null !== $this->_persistence) {
$server->setPersistence($this->_persistence);
}
return $server;
}
示例3: run
/**
* Handles the web service request.
*/
public function run()
{
header('Content-Type: text/xml;charset=' . $this->encoding);
if (YII_DEBUG) {
ini_set("soap.wsdl_cache_enabled", 0);
}
$server = new SoapServer($this->wsdlUrl, $this->getOptions());
Yii::app()->attachEventHandler('onError', array($this, 'handleError'));
try {
if ($this->persistence !== null) {
$server->setPersistence($this->persistence);
}
if (is_string($this->provider)) {
$provider = Yii::createComponent($this->provider);
} else {
$provider = $this->provider;
}
if (method_exists($server, 'setObject')) {
if (is_array($this->generatorConfig) && isset($this->generatorConfig['bindingStyle']) && $this->generatorConfig['bindingStyle'] === 'document') {
$server->setObject(new CDocumentSoapObjectWrapper($provider));
} else {
$server->setObject($provider);
}
} else {
if (is_array($this->generatorConfig) && isset($this->generatorConfig['bindingStyle']) && $this->generatorConfig['bindingStyle'] === 'document') {
$server->setClass('CDocumentSoapObjectWrapper', $provider);
} else {
$server->setClass('CSoapObjectWrapper', $provider);
}
}
if ($provider instanceof IWebServiceProvider) {
if ($provider->beforeWebMethod($this)) {
$server->handle();
$provider->afterWebMethod($this);
}
} else {
$server->handle();
}
} catch (Exception $e) {
if ($e->getCode() !== self::SOAP_ERROR) {
// only log for non-PHP-error case because application's error handler already logs it
// php <5.2 doesn't support string conversion auto-magically
Yii::log($e->__toString(), CLogger::LEVEL_ERROR, 'application');
}
$message = $e->getMessage();
if (YII_DEBUG) {
$message .= ' (' . $e->getFile() . ':' . $e->getLine() . ")\n" . $e->getTraceAsString();
}
// We need to end application explicitly because of
// http://bugs.php.net/bug.php?id=49513
Yii::app()->onEndRequest(new CEvent($this));
$server->fault(get_class($e), $message);
exit(1);
}
}
示例4: check_connection
//for checking the connection
public function check_connection($data)
{
if ($this->valid($data[0])) {
return 'ok';
} else {
return 'notok';
}
}
/**
* Checks whether a module is installed or not
* @param type $parameter_array
* @return type
*/
public function checkModuleInstalled($parameter_array = array())
{
if ($this->valid($parameter_array[0])) {
$module_name = isset($parameter_array[1]) ? $parameter_array[1] : '';
$sql = "SELECT mod_id FROM modules WHERE mod_name = ? AND mod_active = '1'";
$res = sqlStatement($sql, array($module_name));
$row = sqlFetchArray($res);
return !empty($row);
} else {
return 'noauth';
}
}
}
$server = new SoapServer(null, array('uri' => "urn://portal/res"));
$server->setClass('UserService');
$server->setPersistence(SOAP_PERSISTENCE_SESSION);
$server->handle();
示例5: _getSoap
/**
* Get SoapServer object
*
* Uses {@link $_wsdl} and return value of {@link getOptions()} to instantiate
* SoapServer object, and then registers any functions or class with it, as
* well as peristence.
*
* @return SoapServer
*/
protected function _getSoap()
{
$options = $this->getOptions();
$server = new SoapServer($this->_wsdl, $options);
if (!empty($this->_functions)) {
$server->addFunction($this->_functions);
}
if (!empty($this->_class)) {
$args = $this->_classArgs;
array_unshift($args, $this->_class);
if ($this->_wsiCompliant) {
#require_once 'Zend/Soap/Server/Proxy.php';
array_unshift($args, 'Zend_Soap_Server_Proxy');
}
call_user_func_array(array($server, 'setClass'), $args);
}
if (!empty($this->_object)) {
$server->setObject($this->_object);
}
if (null !== $this->_persistence) {
$server->setPersistence($this->_persistence);
}
return $server;
}
示例6: run
/**
* Handles the web service request.
*/
public function run()
{
$response = \Yii::$app->response;
$response->format = Response::FORMAT_RAW;
$response->charset = $this->encoding;
$response->headers->add('Content-Type', 'text/xml');
if (YII_DEBUG) {
ini_set("soap.wsdl_cache_enabled", 0);
}
$server = new \SoapServer($this->wsdlUrl, $this->getOptions());
// \Yii::$app->on($name, $behavior)EventHandler('onError',array($this,'handleError'));
try {
if ($this->persistence !== null) {
$server->setPersistence($this->persistence);
}
if (is_string($this->provider)) {
$provider = \Yii::createObject($this->provider);
} else {
$provider = $this->provider;
}
if (method_exists($server, 'setObject')) {
if (is_array($this->generatorConfig) && isset($this->generatorConfig['bindingStyle']) && $this->generatorConfig['bindingStyle'] === 'document') {
$server->setObject(new DocumentSoapObjectWrapper($provider));
} else {
$server->setObject($provider);
}
} else {
if (is_array($this->generatorConfig) && isset($this->generatorConfig['bindingStyle']) && $this->generatorConfig['bindingStyle'] === 'document') {
$server->setClass(DocumentSoapObjectWrapper::className(), $provider);
} else {
$server->setClass(SoapObjectWrapper::className(), $provider);
}
}
if ($provider instanceof IWebServiceProvider) {
if ($provider->beforeWebMethod($this)) {
$server->handle();
$provider->afterWebMethod($this);
}
} else {
$server->handle();
}
} catch (\Exception $e) {
if ($e->getCode() !== self::SOAP_ERROR) {
// only log for non-PHP-error case because application's error handler already logs it
// php <5.2 doesn't support string conversion auto-magically
\Yii::error($e->__toString());
}
$message = $e->getMessage();
if (YII_DEBUG) {
$message .= ' (' . $e->getFile() . ':' . $e->getLine() . ")\n" . $e->getTraceAsString();
}
// We need to end application explicitly because of
// http://bugs.php.net/bug.php?id=49513
\Yii::$app->state = Application::STATE_AFTER_REQUEST;
\Yii::$app->trigger(Application::EVENT_AFTER_REQUEST);
$reflect = new \ReflectionClass($e);
$server->fault($reflect->getShortName(), $message);
exit(1);
}
}
示例7: authenticate
$url = "https://" . $_SERVER[HTTP_HOST] . $_SERVER[REQUEST_URI];
$delay = 1;
die('<meta http-equiv="refresh" content="' . $delay . ';url=' . $url . '">');
}
include_once "moodleplugin.php";
ini_set('soap.wsdl_cache_enabled', 0);
$server = new SoapServer("moodleplugin.wsdl", array('soap_version' => SOAP_1_2, 'encoding' => "UTF-8"));
$server->setClass("MoodlePlugin");
session_start();
session_name('PHPMOODLEWSSESSID');
/*if (!(adminlogin($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']))) { // Check username and password
authenticate(); // Send basic authentication headers because username and/or password didnot match
}
else {*/
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$server->setPersistence(SOAP_PERSISTENCE_REQUEST);
try {
$server->handle();
} catch (Exception $exc) {
$server->fault($exc->getCode(), $exc->getMessage());
}
} else {
#output function list of webserver
$functions = $server->getFunctions();
foreach ($functions as $func) {
echo $func . "<br>";
}
}
//}
// Call authentication display
function authenticate()
示例8: run
/**
* Handles the web service request.
*/
public function run()
{
header('Content-Type: text/xml;charset=' . $this->encoding);
if (YII_DEBUG) {
ini_set("soap.wsdl_cache_enabled", 0);
}
$server = new SoapServer($this->wsdlUrl, $this->getOptions());
Yii::app()->attachEventHandler('onError', array($this, 'handleError'));
try {
if ($this->persistence !== null) {
$server->setPersistence($this->persistence);
}
if (is_string($this->provider)) {
$provider = Yii::createComponent($this->provider);
} else {
$provider = $this->provider;
}
if (method_exists($server, 'setObject')) {
$server->setObject($provider);
} else {
$server->setClass('CSoapObjectWrapper', $provider);
}
if ($provider instanceof IWebServiceProvider) {
if ($provider->beforeWebMethod($this)) {
$server->handle();
$provider->afterWebMethod($this);
}
} else {
$server->handle();
}
} catch (Exception $e) {
if ($e->getCode() === self::SOAP_ERROR) {
// a PHP error
$message = $e->getMessage();
} else {
$message = $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ')';
// only log for non-PHP-error case because application's error handler already logs it
// php <5.2 doesn't support string conversion auto-magically
Yii::log($e->__toString(), CLogger::LEVEL_ERROR, 'application');
}
if (YII_DEBUG) {
$message .= "\n" . $e->getTraceAsString();
}
$server->fault(get_class($e), $message);
}
}
示例9: RunServer
//.........这里部分代码省略.........
$i = -1;
$len = sizeof($this->Files);
while (++$i < $len) {
self::Debug('Load ' . $this->Files[$i]);
require_once $this->Files[$i];
}
if (!class_exists($class)) {
// Try class.webservice.php
if (file_exists('class.webservice.php')) {
self::Debug('Try to load class.webservice.php');
require_once 'class.webservice.php';
if (class_exists($class)) {
$this->Files[] = 'class.webservice.php';
}
}
if (!class_exists($class)) {
if (file_exists(dirname(__FILE__) . '/class.webservice.php')) {
self::Debug('Try to load ' . dirname(__FILE__) . '/class.webservice.php');
require_once dirname(__FILE__) . '/class.webservice.php';
if (class_exists($class)) {
$this->Files[] = dirname(__FILE__) . '/class.webservice.php';
}
}
}
if (!class_exists($class)) {
// A handler class or object is required when using non-global methods!
throw new Exception('Webservice handler class not present');
}
}
}
}
// Prepare the PhpWsdlHandler
if ($this->CreateHandler) {
self::Debug('Use PhpWsdlHandler');
if (is_null($class)) {
$class = $this->Name;
}
$class = $this->CreateHandler($class);
}
// Prepare the SOAP server
$this->SoapServer = null;
if (self::CallHook('PrepareServerHook', array('server' => $this, 'soapserver' => &$this->SoapServer, 'wsdlfile' => &$wsdlFile, 'class' => &$class, 'useproxy' => &$useProxy, 'forcenowsdl' => &$forceNoWsdl, 'andexit' => &$andExit, 'user' => &$user, 'password' => &$password))) {
self::Debug('Prepare the SOAP server');
// WSDL file
$wsdlFile = $forceNoWsdl || $useProxy && !self::$UseProxyWsdl ? null : $wsdlFile;
if (!is_null($wsdlFile)) {
self::Debug('Using WSDL file ' . $wsdlFile);
} else {
self::Debug('No WSDL file');
}
// Server options
$temp = array('actor' => $this->EndPoint, 'uri' => $this->NameSpace);
$temp = array_merge($this->SoapServerOptions, $temp);
if (self::$Debugging) {
self::Debug('Server options: ' . print_r($temp, true));
}
// Create the server object
self::Debug('Creating PHP SoapServer object');
$this->SoapServer = new SoapServer($wsdlFile, $temp);
// Set the handler class or object
if ($useProxy || !is_object($class)) {
$temp = $useProxy ? 'PhpWsdlProxy' : $class;
if (!is_null($temp)) {
self::Debug('Setting server class ' . $temp);
$this->SoapServer->setClass($temp);
} else {
self::Debug('No server class or object');
}
} else {
self::Debug('Setting server object ' . get_class($class));
$this->SoapServer->setObject($class);
}
// Add global methods
if (!$useProxy && !$this->CreateHandler) {
$i = -1;
$len = sizeof($this->Methods);
while (++$i < $len) {
if ($this->Methods[$i]->IsGlobal) {
self::Debug('Adding global method ' . $this->Methods[$i]->Name);
$this->SoapServer->addFunction($this->Methods[$i]->Name);
}
}
} else {
self::Debug('Omit adding global methods to the SoapServer object since they will be called by the proxy or the PhpWsdlHandler object');
}
}
// Run the SOAP server
if (self::CallHook('RunServerHook', array('server' => $this, 'soapserver' => &$this->SoapServer, 'wsdlfile' => &$wsdlFile, 'class' => &$class, 'useproxy' => &$useProxy, 'forcenowsdl' => &$forceNoWsdl, 'andexit' => &$andExit, 'user' => &$user, 'password' => &$password))) {
self::Debug('Run the SOAP server');
//Ignatyev begin
$this->SoapServer->setPersistence(SOAP_PERSISTENCE_SESSION);
//Ignatyev end
$this->SoapServer->handle();
if ($andExit) {
self::Debug('Exit script execution');
exit;
}
}
return true;
}
示例10: run
/**
* Handles the web service request.
*/
public function run()
{
header('Content-Type: text/xml;charset=' . $this->encoding);
if (YII_DEBUG) {
ini_set("soap.wsdl_cache_enabled", 0);
}
list(, $hash) = explode(' ', \Yii::$app->getRequest()->getHeaders()->get('authorization') . ' ');
$auth = $hash ? base64_decode($hash) . '@' : '';
$server = new \SoapServer(str_replace('http://', 'http://' . $auth, $this->wsdlUrl), $this->getOptions());
try {
if ($this->persistence !== null) {
$server->setPersistence($this->persistence);
}
if (is_string($this->provider)) {
$provider = $this->provider;
$provider = new $provider();
} else {
$provider = $this->provider;
}
$server->setObject($provider);
ob_start();
$server->handle();
$soapXml = ob_get_contents();
ob_end_clean();
return $soapXml;
} catch (Exception $e) {
if ($e->getCode() !== self::SOAP_ERROR) {
// only log for non-PHP-error case because application's error handler already logs it
// php <5.2 doesn't support string conversion auto-magically
\Yii::error($e->__toString());
}
$message = $e->getMessage();
if (YII_DEBUG) {
$message .= ' (' . $e->getFile() . ':' . $e->getLine() . ")\n" . $e->getTraceAsString();
}
// We need to end application explicitly because of
// http://bugs.php.net/bug.php?id=49513
$server->fault(get_class($e), $message);
exit(1);
}
}
示例11: autoinclude
<?php
require_once 'Ahorcado.class.php';
function autoinclude($className)
{
$className = str_replace('\\', '/', $className) . '.php';
require_once $className;
}
spl_autoload_register('autoinclude');
if (isset($_GET['wsdl'])) {
header('Content-Type: application/soap+xml; charset=utf-8');
echo file_get_contents('Ahorcado.wsdl');
} else {
session_start();
if (!isset($_SESSION['service'])) {
$_SESSION['service'] = new Ahorcado();
}
$servidorSoap = new SoapServer('C:\\Users\\Iva\\Documents\\II-2015\\Apps\\TareaWebService\\TPRepo\\Ahorcado.wsdl');
//poner la ruta en tu compu
//Para evitar la excepción por defecto de SOAP PHP cuando no existe HTTP_RAW_POST_DATA,
//se regresa explícitamente el siguiente fallo cuando no hay solicitud (v.b. desde un navegador)
if (!@$HTTP_RAW_POST_DATA) {
$servidorSoap->fault('SOAP-ENV:Client', 'Invalid Request');
exit;
}
$servidorSoap->setObject(new Zend\Soap\Server\DocumentLiteralWrapper($_SESSION['service']));
$servidorSoap->setPersistence(SOAP_PERSISTENCE_SESSION);
$servidorSoap->handle();
}