4 Replies Latest reply on Nov 20, 2010 7:20 PM by Miggl

    ZendAMF Server Class Throwing Errors

    Miggl Level 1

       

      (mx.messaging.messages::ErrorMessage)#0

        body = (Object)#1

        clientId = (null)

        correlationId = "14E5A70F-0829-9D09-D237-61B6A51ED666"

        destination = ""

        extendedData = (null)

        faultCode = "Client.Error.MessageSend"

        faultDetail = "Channel.Connect.Failed error NetConnection.Call.BadVersion: : url: 'http://[servername]/development/'"

        faultString = "Send failed"

        headers = (Object)#2

        messageId = "55E31D60-FFC1-82EB-A00A-61B6A7F95FAF"

        rootCause = (mx.messaging.events::ChannelFaultEvent)#3

          bubbles = false

          cancelable = false

          channel = (mx.messaging.channels::AMFChannel)#4

            authenticated = false

            channelSets = (Array)#5

            connected = false

            connectTimeout = -1

            enableSmallMessages = true

            endpoint = "http://[servername]/development/"

            failoverURIs = (Array)#6

            id = "zend-endpoint"

            mpiEnabled = false

            netConnection = (flash.net::NetConnection)#7

              client = (mx.messaging.channels::AMFChannel)#4

              connected = false

              maxPeerConnections = 8

              objectEncoding = 3

              proxyType = "none"

              uri = "http://[servername]/development/"

            piggybackingEnabled = false

            polling = false

            pollingEnabled = true

            pollingInterval = 3000

            protocol = "http"

            reconnecting = false

            recordMessageSizes = false

            recordMessageTimes = false

            requestTimeout = -1

            uri = "http://[servername]/development/"

            url = "http://[servername]/development/"

            useSmallMessages = false

          channelId = "zend-endpoint"

          connected = false

          currentTarget = (mx.messaging.channels::AMFChannel)#4

          eventPhase = 2

          faultCode = "Channel.Connect.Failed"

          faultDetail = "NetConnection.Call.BadVersion: : url: 'http://[servername]/development/'"

          faultString = "error"

          reconnecting = false

          rejected = false

          rootCause = (Object)#8

            code = "NetConnection.Call.BadVersion"

            description = ""

            details = ""

            level = "error"

          target = (mx.messaging.channels::AMFChannel)#4

          type = "channelFault"

        timestamp = 0

        timeToLive = 0

       

       

      I'm getting this error message when trying to use a RemoteObject that ties to ZendAMF server class.

       

      This is the RemoteObject:

       

      
      
                     [Bindable]
                     private var companyResults:ArrayCollection;
                     private function findAll_companyServiceHandler(event:ResultEvent):void
                     {
                          this.companyResults = new ArrayCollection(event.result as Array);
                          Alert.show(this.companyResults.length.toString());
                          for (var i:uint = 0; i < this.companyResults.length; i++)
                          {
                               Alert.show(CompanyVO(this.companyResults[i]).name);
                          }
                     }
      
                     protected function button1_clickHandler(event:MouseEvent):void
                     {
                          this.leadlawService.CompanyAmfService.findAll();
                          this.leadlawService.findAll();
                     }
                     protected function leadlawService_faultHandler(event:FaultEvent):void
                     {
                          Alert.show(event.message.toString());
                     }
                ]]>
           </fx:Script>
           <fx:Declarations>
                <s:RemoteObject
                     id="leadlawService"
                     destination="zend"
                     showBusyCursor="true"
                     fault="leadlawService_faultHandler(event)"
                >
                     <s:method name="findAll" result="findAll_companyServiceHandler(event)" />
                </s:RemoteObject>
           </fx:Declarations>
      
      
      

       

       

      And here's the corresponding controller code using Zend Framework:

       

      <?php
      
      /**
       * ServicesController
       * 
       * @author
       * @version 
       */
      require_once 'Zend/Controller/Action.php';
      
      class ServicesController extends Zend_Controller_Action
      {
           public function init()
           {
                $this->_helper->viewRenderer->setNoRender();
           }
      
           public function amfAction()
           {
                $server = new Zend_Amf_Server();
                $server->addDirectory(APPLICATION_PATH . '/services/');
                echo $server->handle();
           }
      }
      
      

       

       

      And here the class that is in the services directory:

       

      <?php
      
      require_once APPLICATION_PATH . '/models/CompanyVO.php';
      
      class CompanyAmfService
      {
           /**
            * @return array
            */
           public function findAll()
           {
                $results = array();
                $companyVO = new CompanyVO();
                $companies = $companyVO->fetchAll($companyVO->select());
      
                foreach ($companies as $company)
                {
                     array_push($results, $company);
                }
                return $results;
           }
      }
      
      

       

       

      And here the CompanyVO model class:

       

      <?php
      class CompanyVO extends Zend_Db_Table
      {
           protected $_name = "company";
           public $_explicitType = "CompanyVO";
           public $id;
           public $name;
      }
      
      

       

       

       

      Everything appears to look in order, and I tried to create my code according to the example in ZendAMF documentation. Can anyone see what is amiss here?

       

      Thanks for all your help!

      ~Mike

       

      Update 1:

      I forgot to add my services-config.xml:

       

      <?xml version="1.0" encoding="UTF-8"?>
      <services-config>
           <services>
                <service id="zend-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage">
                     <destination id="zend">
                          <channels>
                               <channel ref="zend-endpoint" />
                          </channels>
                          <properties>
                               <source>*</source>
                          </properties>
                     </destination>
                </service>
           </services>
           <channels>
                <channel-definition id="zend-endpoint" class="mx.messaging.channels.AMFChannel">
                     <endpoint uri="http://[servername]/development/" class="flex.messaging.endpoints.AMFEndpoint" />
                </channel-definition>
           </channels>
      </services-config>