重新封装zend_soap实现http连接安全认证的php代码
程序员文章站
2022-05-14 12:30:07
复制代码 代码如下:
<?php
class myframework_soap_server extends zend_soap_server {
protected $_login = '';
protected $_password = '';
public function __construct($wsdl = null, array $options = null) {
parent::__construct($wsdl,$options);
if(isset($options['login'])){
$this->_login=$options['login'];
$this->_password=$options['password'];
$this->_authenticate();
}
}
private function _authenticate(){
$this->setauthenticate($this->_login,$this->_password);
}
public function sethttplogin($login){
$this->_login=$login;
}
public function sethttppassword($password){
$this->_password=$password;
if(isset($this->_login)){
$this->_authenticate();
}
}
public function setauthenticate($login,$password){
if ($_server['php_auth_user']!=$login || $_server['php_auth_pw']!=$password) {
header('www-authenticate: basic realm="myframework realm"');
header('http/1.0 401 unauthorized');
echo "you must enter a valid login id and password to access this resource.\n";
exit;
}
}
}
?>
<?php
class soap_server_test {
public $view = '';
public $params = '';
public $requestobj = '';
public $dbobj = '';
function __construct() {
$this->view = $globals['view'];
$this->params = $globals['params'];
$this->requestobj = $globals['requestobj'];
$this->dbobj = $globals['dbobj'];
}
function indexaction(){
if(isset($_get['wsdl'])) {
$autodiscover = new myframework_soap_autodiscover();
$autodiscover->setclass('model_service_soapclasssettest');
$autodiscover->handle();
exit;
} else {
//$options= array('encoding' => 'utf-8','login'=>'tangjian','password'=>'123456');
$options= array('encoding' => 'utf-8');
$soap = new myframework_soap_server("http://tj.myframework.com/default/soap_server_test/index?wsdl",$options);
$soap->sethttplogin('tangjian');
$soap->sethttppassword('123456');
$soap->setclass('model_service_soapclasssettest');
$soap->handle();
exit;
}
}
function clientaction() {
//$options= array('encoding' => 'utf-8','login'=>'tangjian','password'=>'123456',
// 'compression' =>soap_compression_gzip);
$options= array('encoding' => 'utf-8',
'compression' =>soap_compression_gzip);
$client = new myframework_soap_client('http://tj.myframework.com/default/soap_server_test/index?wsdl',$options);
$client->sethttplogin('tangjian');
$client->sethttppassword('123456');
$result=$client->getpass('tang',"man");
print_r($result);
}
}
?>
复制代码 代码如下:
<?php
class myframework_soap_server extends zend_soap_server {
protected $_login = '';
protected $_password = '';
public function __construct($wsdl = null, array $options = null) {
parent::__construct($wsdl,$options);
if(isset($options['login'])){
$this->_login=$options['login'];
$this->_password=$options['password'];
$this->_authenticate();
}
}
private function _authenticate(){
$this->setauthenticate($this->_login,$this->_password);
}
public function sethttplogin($login){
$this->_login=$login;
}
public function sethttppassword($password){
$this->_password=$password;
if(isset($this->_login)){
$this->_authenticate();
}
}
public function setauthenticate($login,$password){
if ($_server['php_auth_user']!=$login || $_server['php_auth_pw']!=$password) {
header('www-authenticate: basic realm="myframework realm"');
header('http/1.0 401 unauthorized');
echo "you must enter a valid login id and password to access this resource.\n";
exit;
}
}
}
?>
复制代码 代码如下:
<?php
class soap_server_test {
public $view = '';
public $params = '';
public $requestobj = '';
public $dbobj = '';
function __construct() {
$this->view = $globals['view'];
$this->params = $globals['params'];
$this->requestobj = $globals['requestobj'];
$this->dbobj = $globals['dbobj'];
}
function indexaction(){
if(isset($_get['wsdl'])) {
$autodiscover = new myframework_soap_autodiscover();
$autodiscover->setclass('model_service_soapclasssettest');
$autodiscover->handle();
exit;
} else {
//$options= array('encoding' => 'utf-8','login'=>'tangjian','password'=>'123456');
$options= array('encoding' => 'utf-8');
$soap = new myframework_soap_server("http://tj.myframework.com/default/soap_server_test/index?wsdl",$options);
$soap->sethttplogin('tangjian');
$soap->sethttppassword('123456');
$soap->setclass('model_service_soapclasssettest');
$soap->handle();
exit;
}
}
function clientaction() {
//$options= array('encoding' => 'utf-8','login'=>'tangjian','password'=>'123456',
// 'compression' =>soap_compression_gzip);
$options= array('encoding' => 'utf-8',
'compression' =>soap_compression_gzip);
$client = new myframework_soap_client('http://tj.myframework.com/default/soap_server_test/index?wsdl',$options);
$client->sethttplogin('tangjian');
$client->sethttppassword('123456');
$result=$client->getpass('tang',"man");
print_r($result);
}
}
?>
上一篇: Python 建模步骤
下一篇: 把PHP安装为Apache DSO
推荐阅读
-
重新封装zend_soap实现http连接安全认证的php代码
-
重新封装zend_soap实现http连接安全认证的php代码_PHP教程
-
重新封装zend_soap实现http连接安全认证的php代码
-
重新封装zend_soap实现http连接安全认证的php代码_php技巧
-
重新封装zend_soap实现http连接安全认证的php代码_php技巧
-
重新封装zend_soap实现http连接安全认证的php代码_PHP教程
-
重新封装zend_soap实现http连接安全认证的php代码
-
重新封装zend_soap实现http连接安全认证的php代码
-
php代码 重新封装zend_soap实现http连接安全认证的php代码