复代码 代码如下:
class MyFramework_Soap_server는 Zend_Soap_Server를 확장합니다. {
protected $_login = '' ;
보호된 $_password = '';
공용 함수 __construct($wsdl = null, 배열 $options = null) {
parent::__construct($wsdl,$options);
if(isset($options['login'])){
$this->_login=$options['login'];
$this->_password=$options['password'];
$this->_authenticate();
}
}
비공개 함수 _authenticate(){
$this->setAuthenticate($this->_login,$this->_password);
}
공용 함수 setHttpLogin($login){
$this->_login=$login;
}
공용 함수 setHttpPassword($password){
$this->_password=$password;
if(isset($this->_login)){
$this->_authenticate();
}
}
공용 함수 setAuthenticate($login,$password){
if ($_SERVER['PHP_AUTH_USER']!=$login || $_SERVER['PHP_AUTH_PW']!=$ 비밀번호) {
header('WWW-Authenticate: Basic realm="MyFramework Realm"');
header('HTTP/1.0 401 권한 없음');
echo "이 리소스에 액세스하려면 유효한 로그인 ID와 비밀번호를 입력해야 합니다.n";
퇴장;
}
}
}
?>
复system代码 代码如下:
class Soap_server_test {
공개 $view = '';
공개 $params = '';
공개 $requestObj = '';
공개 $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();
퇴장;
} else {
//$opti => 'UTF-8','로그인'=>'탕젠','비밀번호'=>'123456');
$옵티 => '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();
퇴장;
}
}
function clientAction() {
//$opti => 'UTF-8','로그인'=>'tangjian','password'=>'123456',
// '압축' =>SOAP_COMPRESSION_GZIP);
$옵티 => 'UTF-8',
'압축' =>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代码에 새로운 기능을 추가하여 zend_soap을 안전하게 보호하세요.帮助。