4 Replies Latest reply on May 13, 2009 10:57 AM by EvolvedDSM

    Getting "Method 'sign_in' does not exist" Error (using Charles)

    Miggl Level 1

      This may be a bit off the FLEX field, and have to do with Zend Framework's ZEND_AMF class. Unfortunately I haven't been able to dig anything up, and comments posted on Wade Arnolds site have not received any responses, so I thought I'd give it a go here.

       

      My ServiceController Class:

      public function loginAction()
      {
           $this->_helper->viewRenderer->setNoRender();
           $server = new Zend_Amf_Server();
           $server->setClass('LoginAmfService', 'LoginService');
           $server->setClassMap('CurrentUserVO', 'CurrentUserVO');
           $server->setProduction(false);
           print($server->handle());
      }
      

       

      My LoginAmfService class:

      class LoginAmfService
      {
           /**
            * Main login function.
            *
            * @param  string        $name
            * @param  string        $password
            * @return CurrentUserVO
            */
           public function sign_in($name, $password)
           {
                $authAdapter     = new Zend_Auth_Adapter_DbTable(Zend_Registry::get('db'), 'users', 'user_name', 'password', 'PASSWORD(?) AND active = 1');
                $returnValue     = new CurrentUserVO();
                
                $authAdapter->setIdentity(htmlspecialchars($name))
                     ->setCredential(htmlspecialchars($password));
                $authResult = $authAdapter->authenticate();
                if ($authResult->isValid())
                {
                     $userArray                          = $authAdapter->getResultRowObject(array('id', 'first_name', 'last_name', 'title', 'photo'));
                     $returnValue->first_name     = $userArray->first_name;
                     $returnValue->last_name          = $userArray->last_name;
                     $returnValue->title               = $userArray->title;
                     $returnValue->photo               = $userArray->photo;
                     $returnValue->token               = $userArray->id;
                }
                
                return $returnValue;
           }
           
           /**
            * Function used to log people off.
            *
            */
           public function sign_out()
           {
                $authAdapter = Zend_Auth::getInstance();
                $authAdapter->clearIdentity();
           }
      }
      

       

      My SignIn FLEX module (the relevant portions):

           <mx:RemoteObject
                id="LoginRemote"
                destination="login"
                source="SignIn"
                showBusyCursor="true"
                fault="parentDocument.handleFault(event)"
           >
                 <mx:method name="sign_in" result="signin_handle(event)" />
                 <mx:method name="sign_out" result="signout_handle(event)" />
           </mx:RemoteObject>
           <mx:Script>
                <![CDATA[
                     import mx.rpc.events.FaultEvent;
                     import mx.utils.ArrayUtil;
                     import mx.rpc.events.ResultEvent;
                     import mx.controls.Alert;
                     import com.brassworks.ValueObjects.CurrentUserVO;
                     import mx.events.VideoEvent;
                     
                     [Bindable]
                     private var this_user:CurrentUserVO = new CurrentUserVO();
                     
                     private function mdl_init():void
                     {
                          focusManager.setFocus(txt_username);
                     }
                     
                     private function signin_handle(event:ResultEvent):void
                     {
                               this_user = event.result as CurrentUserVO;
                               if (this_user.token == null) {Alert.show("Supplied login credentials are not valid. Please try again.");}
                               else
                               {
                                    this.parentApplication.setUser(this.this_user);
                               }
                     }
      
                     private function signout_handle(event:ResultEvent):void
                     {
                          
                     }
                     
                     private function sign_in(event:Event):void
                     {
                          try
                          {
                               //Alert.show(txt_name.text + "|" + txt_password.text);
                               LoginRemote.sign_in(txt_username.text, txt_password.text);
                          }
                          catch (error:Error)
                          {
                               this.parentDocument.handleFault(error);
                          }
                     }
      
                     private function sign_out(event:Event):void
                     {
                          
                     }
                     
                     private function show_error(error:Error, s_function:String):void
                     {
                          Alert.show("Method:" + s_function + "\nName: " + error.name + "\nID: " + error.errorID + "\nMessage: " + error.message + "\nStack Trace: " + error.getStackTrace() + "\nError: " + error.toString());
                     }
                     
                     private function handleFault(event:FaultEvent):void
                     {
                          Alert.show(event.fault.faultDetail, event.fault.faultString);
                     }
      
                ]]>
           </mx:Script>
      
      

       

       

      Now, all this is great and good, as it works with Zend Framework 1.7.6. However, when I try to upgrade to 1.7.8 (to take advantage of session management and other bug-fixes), I get the following error (using Charles):

      #1 /var/web/htdocs/core/library/Zend/Amf/Server.php(390): Zend_Amf_Server->_handle(Object(Zend_Amf_Request_Http))
      #2 /var/web/htdocs/core/application/default/controllers/ServicesController.php(73): Zend_Amf_Server->handle()
      #3 /var/web/htdocs/core/library/Zend/Controller/Action.php(503): ServicesController->loginAction()
      #4 /var/web/htdocs/core/library/Zend/Controller/Dispatcher/Standard.php(285): Zend_Controller_Action->dispatch('loginAction')
      #5 /var/web/htdocs/core/library/Zend/Controller/Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
      #6 /var/web/htdocs/core/application/bootstrap.php(39): Zend_Controller_Front->dispatch()
      #7 /var/web/htdocs/core/public/index.php(5): Bootstrap->runApp()
      #8 {main} ?Method "sign_in" does not exist
      

       

       

      I have no idea why this would not work anymore. My assumption is that I am not correctly setting up Zend_Amf (but then again, my counter-argument is that it worked before, so ..... ????)

       

      Thanks for any help!

      -Mike