1

Zend Framework を使用して認証の Web サービスを作成します。これが私のサーバーです。

<?php

require_once APPLICATION_PATH . '/controllers/services/Authentification.php';

class ServController extends Zend_Controller_Action
{
    private $_WSDL_URI = 'http://127.0.0.1/EverTags1/webAuthentification/public/Serv/?wsdl';

    public function init()
    {
    }

    public function indexAction()
    {
        $this->_helper->viewRenderer->setNoRender();    
        if(isset($_GET['wsdl'])) {
            $this->hadleWSDL(); //return the WSDL
        } else {
            $this->handleSOAP(); //handle SOAP request
                }               
    }

    private function hadleWSDL()
    {
        $autodiscover = new Zend_Soap_AutoDiscover();//Zend_Soap_AutoDiscover which will create the WSDL file
        $autodiscover->setClass('Authentification');// class that we use as webservice
        $autodiscover->handle();
    }

    public function handleSOAP()
    {
    $soap = new Zend_Soap_Server($this->_WSDL_URI); 
        $soap->setClass('Authentification');
        $soap->handle();    
    }
}

クライアント:

<?php

class ClientController extends Zend_Controller_Action
{
    private $_WSDL_URI = 'http://127.0.0.1/EverTags1/webAuthentification/public/Serv/?wsdl';

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
       $client = new Zend_Soap_Client($this->_WSDL_URI);

        $this->view->UserInformation = $client->authentification('marwa','password');
    }


}

私がWebサービスとして使用するクラス

<?php

ini_set("soap.wsdl_cache_enabled", "0");
//require_once realpath(APPLICATION_PATH . '/../library/').'/UserClass.php';

class Authentification {
    /**
     *
     * @param string $username
     * @param string $password
     * @return string
     */
 public function authentification($username,$password) {

        $dbAdapter = Zend_Db_Table::getDefaultAdapter();
        $authAdapter = new Zend_Auth_Adapter_DbTable($dbAdapter);

        $authAdapter->setTableName('standard_users')
                    ->setIdentityColumn('username')
                    ->setCredentialColumn('password');


        $authAdapter->setIdentity($username);
        $authAdapter->setCredential($password);
        //authentification
        $auth = Zend_Auth::getInstance();
        $result = $auth->authenticate($authAdapter);
        if ($result->isValid()) {
         //Authentification Réussie : on stocke les informations de l'utilisateur sauf le mot de passe !

           $user = $authAdapter->getResultRowObject();
           $UserName = $auth->getIdentity();

        }
        else  $UserName = 'Authentication failed (Unknown user or incorrect password)! Please Retry !';

  return $UserName;          
 }


}
?>

私の問題は私が書くときです

 $authAdapter->setIdentity($username);
            $authAdapter->setCredential($password);

そして、関数「認証」のプロトタイプにパラメーターを渡しますWebサービスが機能しません

しかし、パラメータを直接設定すると

$authAdapter->setIdentity('username');
                $authAdapter->setCredential('password');

それは動作します。

パラメータが関数「authentification」のプロトタイプから setIdentity および setCredential に渡されない理由がわかりません。

あなたが私を助けることができれば私は感謝します

4

0 に答える 0