1

I create a web service of authentication with the Zend Framework Here is my Server :

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

Client:

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


}

the class that I use as webservice

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


}
?>

My problem is when i write

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

and i pass the parameter in the prototype of the function 'authentification' the web service doesn't work

but when i set the parameter directly

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

it work.

I can't understand why the parameters doesn't pass from the protoype of the function 'authentification' to setIdentity and setCredential.

I will be gratefull if you can help me

hakre
  • 193,403
  • 52
  • 435
  • 836
Marwa Mhamdi
  • 79
  • 1
  • 9
  • 1
    var_dump your variables in the `authentification` method and see what's getting there from the `indexAction()`. There is obviously something wrong with the string being sent. Sorry but that's all I got. The results of a var_dump should provide clues. – RockyFord Mar 24 '12 at 12:43
  • Can you see what is being actually passed through the authentification function? It is coming into the function empty? A var_dump like RockyFord suggested might shed some light on this issue. – Marcel Jul 02 '12 at 02:12

0 Answers0