Zend AMF

I've put my Zend folder into my web root.
From Flex, I'm calling amf.php:
<?
include '_services/Test/Main.php';
include 'Zend/Amf/Server.php';
$server = new Zend_Amf_Server();
$server->setProduction(false);
$server->setClass('Test_Main', 'test');
$response = $server->handle();
echo $response;
?>
My _services/Test/Main.php has a class called "Test_Main" and a public method "init()" which simply returns "this is a test".
I've used the services-config.xml file provided by Zend and modified the URI only to point to my amf.php file.
In Flex:
<fx:Declarations>
    <s:RemoteObject id="myAmf"
        fault="faultHandler(event)"
        showBusyCursor="true"
        destination="zend" />
</fx:Declarations>
protected function creationCompleteHandler(event:FlexEvent):void
    var message:String    =    myAmf.Test_Main.init();
    Alert.show(message);
When I run the application, the call is being made to the amf.php file according to Apache with a response code of 200. However in Flex it says:
"ReferenceError: Error #1069: Property init not found on mx.rpc.remoting.mxml.Operation and there is no default value."
Can anyone tell me why this is happening? There is a similar post on the Zend forums posted in Feb 2009 but it's had loads of views and no replies!
Thanks in advance.

Richard Bates of flexandair.com figured it out. In my php.ini file, I had the memory limit set at 8M. After, changing it to 32M, it worked. Thank you, Richard!
-Laxmidi

Similar Messages

  • Zend AMF Data Service Return Problem

    Hi Folks,
    I am working with FB4 and Zend AMF/PHP and MySQL.  I began integrating the PHP stuff using the great article by Mihai Corlan called 'Working in Flash Builder 4 with Flex and PHP.  I followed all the steps exactly, aside from creating my own app-specific PHP classes and functions, etc...  I 'hooked up' the Zend stuff just like the article, created a text datagrid, just like the article, and viola!, it worked.  I then tweaked it a bit and interwove it into my 'real' component.  So far, so good.
    Then I created a second PHP class with a different 'get data' type of function.  It queries a different table in MySQL, but is essentially the 'same' as the query/function in the initial PHP class.
    In FB, in the Data Services window, I choose the 'Connect to Data/Services' function, just like the first time.  I then find/select my PHP class file and FB 'interrogates it' enough to show me the function that exists in the class.  I 'finish' the operation and it adds a new 'service' to the list of services in that window.  Again, so far, so good.
    The problem comes when I try to 'test' the service or 'configure return types' (which basically requires a 'test' operation anyway).  I can enter the 'input' params just fine, but when I try to execute the call, I get the following error:
    InvocationTargetException:There was an error while invoking the operation. Check your operation inputs or server code and try invoking the operation again.
    Reason: An error occured while reading response sent by server. Try encoding the response suitably before sending it. e.g. If a database column contains UTF-8 characters then use utf8_encode() to encode its value before returning it from the operation.
    I don't know where to go after this.  Again - the 2nd PHP class is essentially identical to the 1st.  The function in it is essentially identical, differing only by the input params, the name of the function and the actual SQL it sends to MySQL.  There is no special text, no special characters, no image stuff, nothing.  I do not 'encode' the results of the function in the first class - in fact the code in the second class is practically identical to the first.  I do not know what the error is talking about.  My guess is that it's more of a generic message.
    I can debug the PHP code just fine from within a seperate instance of Eclipse.  The function runs/returns just fine - an array of PHP-defined objects (simple strings).
    Any insights or advice would be welcomed.   Thank you,
    -David Baron

    Thank Jorge, but that was not the issue, though, it may be related.
    I checked the mySQL my.ini file, and there was already an entry for:
    [mysql]
    default-character-set=utf8
    I added the 'default-collation=utf8_unicode_ci', like you suggested, but that didn't do anything.
    I checked the Apache httpd.conf file, and added the following line 'under' the "DefaultType text/plain" line:
    AddDefaultCharset UTF-8    but that did not do anything.
    I checked my mySQL database, all the tables involved.  They were already at UTF-8 (default).  However, some of the 'varchar' columns were defined as 'latin 1-default collation'.   I changed them all to utf-8 (default table collation), but that did not help either.
    Finally, I found the problem, though I don't really know if it is "my" problem, or ZendAMF's problem, or Adobe's problem.
    It turned out that 'some' of my data had a 'bad' character in it.  Specifically, I had 'copied and pasted' some data from MS Word into mySQL Workbench.  Some of the data included the 'elipsis' character - you know, when you type "..." (dot dot dot) in MS Word, it replaces the three periods with a single elipsis character.  Although PHP could easily query and assemble this data into a nice object array, I noticed that that character showed up (in PHP's debugger) as a 'box' character, meaning "bad character".  Thus, I guess, Zend AMF and/or FlashBuilder could not 'bring over' and/or deal with this type of character.  As soon as I replace the few instances of that character with three periods, everything began to work perfectly.
    So... what to do about this?  I thought I was through with silly encoding/decoding of data when I left JavaScript and HTML behind in moving to FlashBuilder technology.  Am I really going to have to worry about this kind of thing?  Or might this be a bug/deficiency somewhere in the stack?
    Thanks for your help,
    -David

  • Flex and Zend amf deployment resolved with proper solution

    Hi All,
    Although, I personally do not like using Zend for these issues itself. However, I faced this issue first time with flex 4.0 version when everyone used to run into
    channel disconnected error. you can find the link for that post here:
    http://forums.adobe.com/message/3366991.
    Now, with flash builder 4.6, things have changed slightly and so the deployment process. So, here are the right set of steps to be followed :
    1. after developing your flash project, export the release build(I assume if you are a flex user, you should know these steps already)
    2. Now, check your release folder, you must have got some files with amfconfig.ini and gateway.php and just one folder named history.
    3. copy all these files into a new folder say "My Release Build".
    4. Now, step 1 is get Zend framework in place, to achieve that:
    there are different ways. some will say : "make sure zend must already installed on your production server." that is an alternative but most likely,  the easier way to do this is : search your www(root folder on localhost),you will find a folder with name ZendFramework. Copy this folder to "My Release Build"
    5. Now, the services that you have used in your flex project, go to debug folder of your project which should be in your www(root folder on localhost) with name "yourprojectname-debug". copy services folder from this debug folder to "My Release Build"
    6. Now, open your amfconfig.ini from "My Release Build" and edit and make it look like following:
    [zend]
    webroot = http://www.yourwebsite.com
    ;you can edit above webroot to match the root folder of your website or use . to make it point to root.
    zend_path = ./ZendFramework/library
    [zendamf]
    amf.production = true
    amf.directories[]= services
    thats it. your amf config is fine.
    7. edit gateway.php:
    Now, remove everything from gateway.php and copy this as it is there:
    <?php
    ini_set("display_errors", 1);
    $dir = '.';
    $webroot = $_SERVER['DOCUMENT_ROOT'];
    $configfile = "amf_config.ini";
    //default zend install directory
    $zenddir = $webroot. '/ZendFramework/library';
    //Load ini file and locate zend directory
    if(file_exists($configfile)) {
        $arr=parse_ini_file($configfile,true);
        if(isset($arr['zend']['webroot'])){
            $webroot = $arr['zend']['webroot'];
            $zenddir = $webroot. '/ZendFramework/library';
        if(isset($arr['zend']['zend_path'])){
            $zenddir = $arr['zend']['zend_path'];
    // Setup include path
        //add zend directory to include path
    set_include_path(get_include_path().PATH_SEPARATOR.$zenddir);
    // Initialize Zend Framework loader
    require_once 'Zend/Loader/Autoloader.php';
    Zend_Loader_Autoloader::getInstance();
    // Load configuration
    $default_config = new Zend_Config(array("production" => false), true);
    $default_config->merge(new Zend_Config_Ini($configfile, 'zendamf'));
    $default_config->setReadOnly();
    $amf = $default_config->amf;
    // Store configuration in the registry
    Zend_Registry::set("amf-config", $amf);
    // Initialize AMF Server
    $server = new Zend_Amf_Server();
    $server->setProduction($amf->production);
    if(isset($amf->directories)) {
        $dirs = $amf->directories->toArray();
        foreach($dirs as $dir) {
            // get the first character of the path.
            // If it does not start with slash then it implies that the path is relative to webroot. Else it will be treated as absolute path
            $length = strlen($dir);
            $firstChar = $dir;
            if($length >= 1)
                $firstChar = $dir[0];
            if($firstChar != "/"){
                // if the directory is ./ path then we add the webroot only.
                if($dir == "./"){               
                    $server->addDirectory($webroot);
                }else{
                    $tempPath = $webroot . "/" . $dir;
                    $server->addDirectory($tempPath);
            }else{
                   $server->addDirectory($dir);           
    // Initialize introspector for non-production
    if(!$amf->production) {
        $server->setClass('Zend_Amf_Adobe_Introspector', '', array("config" => $default_config, "server" => $server));
        $server->setClass('Zend_Amf_Adobe_DbInspector', '', array("config" => $default_config, "server" => $server));
    // Handle request
    echo $server->handle();
    Now, upload your "My Release Build folder to your production server webroot"
    case 1: if you get "channel disconnected error, you have made some mistake and your path for zend or services folder is not right."
    In above case, "ZendFramework folder and services folder with all of other release files". To find out what is wrong, open this url :
    http://www.yourwebsite.com/gateway.php. if you see this lovely string there : "Zend Amf Endpoint". consider your are through with zend settings on server
    otherwse you will see relative errors.
    2. After fixing this step, try run your website, you will land into this error :
    Class “yourcorrectclassname” does not exist: Plugin by name ‘Classname’ was not found in the registry; used paths:
    : /home1/messoftc/public_html/oc/services/
    #0 /home1/messoftc/public_html/ZendFramework/library/Zend/Amf/Server.php(553): Zend_Amf_Server->_dispatch(‘fxnname’, Array, ‘classname’)
    #1 /home1/messoftc/public_html/ZendFramework/library/Zend/Amf/Server.php(629): Zend_Amf_Server->_handle(Object(Zend_Amf_Request_Http))
    #2 /home1/messoftc/public_html/oc/gateway.php(69): Zend_Amf_Server->handle()
    #3 {main}
    Now, this is a zend framework bug, it does not automatically detect the php classes in your services folder,those who have run into this, must have googled hard to find the solution and this bug is also logged officially on zend server jira log.
    so, what is the solution? simple and effective. open your gateway.php file from "My Release Build"
    Add this little line :
    $server->addDirectory(dirname(__FILE__) . '/services/');
    after this line :
    $server->setProduction($amf->production);
    reupload this file to your production, you should see your Flex, Zend, php & Mysql in action.
    Here is a sample link I have created :
    http://www.eiws.co.in/testzend.html
    you may also visit the endpoint file:
    http://eiws.co.in/gateway.php
    If anyone still faces this issue, can contact me at [email protected].
    Credits: "To all developers who share their knowledge with everyone and google and thousands of blogs who provide a medium to share this knowledge"

    Richard Bates of flexandair.com figured it out. In my php.ini file, I had the memory limit set at 8M. After, changing it to 32M, it worked. Thank you, Richard!
    -Laxmidi

  • Zend AMF extremely slow first request

    Hi all,
    I'm having a weird problem with Zend AMF and was wondering if anyone else has seen this before.
    I've got a very simple PHP/MySQL backend that returns multidimensional arrays to Flex via Zend AMF.
    Now this all worked fine up to the point that I started testing my app with a remote server instead of my local test server.
    With the remote server I noticed that sometimes, but always the first time, some PHP function is called it takes forever to call the callback function with a result. I'm talking about around 1 to 2 minutes!
    Now, when I call that same php function via a normal url every time it returns the right results in a couple of milliseconds.
    When the function has been called once it seems to be ok and next time it's called it returns results within milliseconds.
    I've had a look with a network sniffer to see if the transfer of data takes long, but that's all fine...
    So it looks to me as if it just takes forever before the RemoteObject calls it's callback function.
    I'll be testing with some stripped down code later tonight and will also set it up on a different server, but I was hoping someone else has seen this and knows a workaround...
    Thanks
    Skip

    Hmm, i just did some more tests, but the results do update so it doesn't look like it's a cached result.
    I'm not entirely sure but it looks like when multiple AMF methods are called too close to each other they are combined into one HTTP POST request to the AMF gateway. When this happens the response is extremely slow, whereas when I have make the second call after the first one has finished completely the response is ok (around 200 milliseconds).
    You wouldn't happen to know how RemoteObject handles multiple calls to an AMF backend, right?

  • Zend AMF and Flex 4

    Hello,
    I am currently working on a windowed app that uses the Zend AMF to connect to the database. I have been trying move the framework from my local testing server to my web server.
    First I ftped the framework files, my gateway.php, and amf_config.ini to the server. Inside the amf_config, changed the webroot to be the location of the ZendFramework and I also pointed the _super_class generated by the dataservice to my webserver. My php.ini is also configured to include that path to the ZendFramework.
    Did I miss a step at some point / was there something I was supposed to do when I created the data service? Is it even possible for an desktop AIR app to work with the ZendFramework when it is on a web server?
    My host is Bluehost

    Hello there.
    Here's the ServiceLocator and delegates I am using....
    // LoginDelegate.as
    package com.myproj.products.business {
         import com.myproj.products.vo.LoginVO;
         import mx.rpc.IResponder;
         import com.adobe.cairngorm.business.ServiceLocator;
         public class LoginDelegate {
              // anything that implements the IResponder interface can act as a responder
              private var responder:IResponder;
              private var service:Object;
              public function LoginDelegate(responder:IResponder) {
                   this.responder = responder;
                   this.service = ServiceLocator.getInstance().getRemoteObject("loginService");
              public function login(loginAttempt:LoginVO):void {
                   // Call the method of service that resides on server
                   var call:Object = service.login(loginAttempt);
                   // Send the response to responder
                   call.addResponder(responder);
    // com/myproj/products/business/Services.mxml
    <?xml version="1.0" encoding="utf-8"?>
    <cairngorm:ServiceLocator
         xmlns:mx="http://www.adobe.com/2006/mxml"
            xmlns:cairngorm="com.adobe.cairngorm.business.*">
         <!-- Login Service -->
         <mx:RemoteObject
              id="loginService"
              destination="zend"
              source="LoginService"
              showBusyCursor="true">
              <mx:method name="doLogin" />
         </mx:RemoteObject>
    </cairngorm:ServiceLocator>
    With kind regards
    ShiVik

  • Connecting To Zend AMF Backend Via HTTPS

    Environment:
    - Flash Builder 4
    - Flex 4 Beta 2
    - Zend AMF (the one that gets automatically downloaded in Flash Builder 4)
    Issue:
    Using Flash Builder's "Connect To PHP" wizard, I can connect to my Zend AMF backend via HTTP but not HTTPS (and yes, my domain does have a valid SSL certificate from a trusted CA - it is not self signed).  Upon selecting the PHP class (using a SFTP mount to my web host) via the wizard, Flash Builder dies when "introspecting the service" and it throws this error:
    Make sure that Zend Framework is installed correctly and  the parameter "amf.production" is not set to true in the amf_config.ini file  located in the project output folder.
    Warning:  require_once(Zend/Loader/Autoloader.php) [function.require-once]: failed to open stream:  No such file or directory in /home <blah>
    If I change my PHP backend's URL from https://<domain> to http://<domain> then it works but I obviously need to use SSL for this application.

    I upgraded to Zend Framework 1.10, which didn't help.  I also just installed Flash Builder 4 Premium (which was just released today) and that didn't help my situation either although I believe the problem is how I'm attempting to get my Flex client to communicate to my hosted web server.
    All the examples I've seen demonstrate how to connect a flex client and PHP backend (via Zend AMF) to LOCALHOST.  I need to develop my Flex client on my laptop and hook into my PHP backend running on a hosted web server (not localhost).
    Here are my server properties:
    - Application server type = PHP
    - Server location:
         - web root = Y:  (this maps to my Y: drive on windows which is a SFTP mount to my web host)
         - root URL = https://cl21.<web_host>.com/~<username>
    - Output folder = Y:\<app>-debug
    I can get this to work if I use my dedicated domain name www.<my_domain>.com but I haven't yet purchased a dedicated IP and SSL certificate so I'm attempting to use my web host's shared SSL certificate (which is valid).  The problem seems to be related to the setting "root URL".  Can you not point the flex client to anything other than a root URL?  Most server-side development happens on a shared dev server (e.g. sandbox.company_name.com/developer1, sandbox.company_name.com/developer2, etc.)

  • Flashbuilder 4 and ZEND AMF

    Hello,
    i have the following setup:
    This is my ValueObject:
    <?php
    class PurchasedSongVO
         public $txn_id;
         public $article_id;
         public $song_id;
         public $songName;
         public $artistName1;
         public $songIcon;
         public $songPreviewFileName;
         public $fullSongFileName;
    ?>
    This is my zend_amf index.php (striped it down to the non working service, the others are working fine!):
    <?php
    require_once('Zend/Amf/Server.php');
    $server = new Zend_Amf_Server();
    require_once('/orders/OrdersService.php');
    $server->setClass("OrdersService");
    $server->setClassMap( "PurchasedSongVO"                        , "PurchasedSongVO"   );
    echo($server -> handle());
    ?>
    In my OrdersService.php I have the following function:
    public function getAllPurchasedSongs_BY_userID( $user_id )
         $stmt = mysqli_prepare( $this->connection,
         "SELECT orderdetails.txn_id,`article_id`,`song_id`, `songName`, `artistName1`, `songIcon`, `songPreviewFileName`, `fullSongFileName`
                        FROM `orderdetails`,`songs`,`orders`
                        WHERE orders.user_id=?
                        AND orderdetails.txn_id=orders.txn_id
                        AND orderdetails.article_id = songs.song_id" );         
         $this->throwExceptionOnError();
         mysqli_stmt_bind_param ($stmt, 'i', $user_id );         
         $this->throwExceptionOnError();
         mysqli_stmt_execute($stmt);
         $this->throwExceptionOnError();
         $rows = array(); //result array
         $row = new PurchasedSongVO();
         while( mysqli_stmt_fetch($stmt) )
             $row = new PurchasedSongVO();//stdClass();
             mysqli_stmt_bind_result(     $stmt,
                             $row->txn_id,
                             $row->article_id,
                             $row->song_id,
                             $row->songName,
                             $row->artistName1,
                             $row->songIcon,
                             $row->songPreviewFileName,
                             $row->fullSongFileName);
                    $rows[] = $row;
         mysqli_stmt_free_result($stmt);
         mysqli_close($this->connection);
       return $rows;
    When I call this Service by 'hand' and print_r it I get for example the following:
    Array
        [0] => PurchasedSongVO Object
                [txn_id] => 44L66197L05199028
                [article_id] => 6
                [song_id] => 6
                [songName] => Let's Go A!
                [artistName1] => Ansolas & Lightrocker
                [songIcon] => defaultSongIcon_38x38.png
                [songPreviewFileName] =>
                [fullSongFileName] =>
        [1] and so on ...
    Here is how I access the service within Flex:
    os.destination ='zend';
    os.source='OrdersService';
    os.showBusyCursor=true;
    os.addEventListener( FaultEvent.FAULT, faultListener);
    os.getAllPurchasedSongs_BY_userID.addEventListener( ResultEvent.RESULT, getAllPurchasedSongs_BY_userID_result );
    public function _getAllPurchasedSongs_BY_userID( user_id:int ):void
         os.getAllPurchasedSongs_BY_userID( user_id );
         private function getAllPurchasedSongs_BY_userID_result( event:ResultEvent ):void
              var resultArray:Array = new Array();
              resultArray = event.result as Array;
              this._purchasedSongsCollection.source = resultArray;
              trace('orders:'+event.result);
    Here is my AS3 Value Object:
    package view.user.valueObjects
         [RemoteClass(alias="PurchasedSongVO")]
         [Bindable]
         public class PurchasedSongVO
              public var txn_id;//:String;
              public var article_id;
              public var song_id;
              public var songName;
              public var artistName1;
              public var songIcon;
              public var songPreviewFileName;
              public var fullSongFileName;
    Now when I call ther service the returned type of objects in the Array is just Object and not PurchasedSongVO, here the trace from above:
    orders:[object Object],[object Object],[object Object],[object Object]
    If done it this way for all other services but they all return the right type and not just object.
    Any idea what could be wrong ?

    Ok,
    the following simple fix is doing the job but the funny think is that its working on my other functions without casting:
    private function getAllPurchasedSongs_BY_userID_result( event:ResultEvent ):void
         var resultArray:Array = new Array();
             resultArray = event.result as Array;
         if(resultArray != null)
              var sourceArray:Array = new Array();
              for( var i:int=0; i<resultArray.length; i++ )
               sourceArray[i] = resultArray[i] as PurchasedSongVO;
              this._purchasedSongsCollection.source = sourceArray;
    probably that helps someone with a similar issue

  • Zend AMF Authentication & Authorization

    How do I secure my PHP services created with 'Connect To PHP' wizard?
    The web is full of tutorials on connecting to PHP but I found nothing on securing the services.
    The 'Connect to PHP' wizard generates a gateway.php which doesn't do authorization.
    Do I have to replace this endpoint with my own? Why doesn't Adobe have tutorials on this?
    maybe PHP apps are not meant to be safe?

    I've been struggling with it, and figured it all out - so, perhaps it could help others.
    The authentication is called on the server only if credentials supplied from the client (via the remote procedure call headers). This snippet illustrates the setup of custom auth (these are the last 6 lines of gateway.php script):
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    // Handle request
    $auth = new My_Amf_Auth(); // authentication
    $server->setAuth($auth);
    $acl = new Zend_Acl(); // authorization
    $server->setAcl($acl);
    echo $server->handle();
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Now, your custom auth should extend Zend_Amf_Auth_Abstract. Since I want to authenticate users from a database, I bring the Zend_Auth_Adapter_DbTable to play. But since I cannot extend both Zend_Amf_Auth_Abstract and Zend_Auth_Adapter_DbTable, I use a composition:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    <?php
    require_once ('Zend/Amf/Auth/Abstract.php');
    * AMF auth class by Danko Kozar, dankokozar.com
    * @author dkozar
    class My_Amf_Auth extends Zend_Amf_Auth_Abstract {
        function __construct() {
        public function authenticate() {
            $adapter = My_Db_Adapter::getInstance();            
            $adapter->setIdentity($this->_username);
            $adapter->setCredential($this->_password);
            // the adapter call
            // you can wrap it into try.. catch and process DB connection errors
            $result = Zend_Auth::getInstance()->authenticate($adapter);
            return $result;
    ?>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Here's the adapter class:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    <?php
    * DB table adapter auth class for AMF by Danko Kozar, dankokozar.com
    * @author dkozar
    * Singleton
    class My_Db_Adapter extends Zend_Auth_Adapter_DbTable {
        protected static $_instance = null;
         * private!
         * @param My_Db_Adapter $adapter
        public function __construct(Zend_Db_Adapter_Abstract $adapter = null) {
            if (!$adapter)
                $adapter = new Zend_Db_Adapter_Mysqli(
                    array(
                        'dbname' => 'test',
                        'username' => 'root',
                        'password' => '')
            parent::__construct($adapter);
            $this
                ->setTableName('users')
                ->setIdentityColumn('username')
                ->setCredentialColumn('password')
            // just for testing
    //        $this
    //            ->setIdentity('username')
    //            ->setCredential('password')
         * @return  My_Db_Adapter
        public static function getInstance()
            if (null === self::$_instance) {
                self::$_instance = new self();
            return self::$_instance;
        public function authenticate() {
            $_authResult = parent::authenticate();
            // NOTE: The point is that $result->_identity is an OBJECT (of type stdClass), NOT string
            // with Zend_Auth_Adapter_DbTable it is internally accomplished by calling its getResultRowObject() method
            // It constructs the stdClass with properties named after table attributes
    //        $user = new stdClass();
    //        $user->role = "administrator";
    //        $user->username = $_authResult->getIdentity();
            $identity = $this->getResultRowObject();
            $result = new Zend_Auth_Result($_authResult->getCode(), $identity);
            return $result;
    ?>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    On the Flex side I have an auto-generated class (MyService) which extends another auto-generated class (_Super_MyService).
    The point is that the outer one is auto-generated only once (initially), and you can modify it, without worrying to be overwritten on service regeneration.
    There's a protected property _serviceControl (which is of type RemoteObject) which could be tweaked if needed.
    I'm tweaking it by of setting the endpoint (with string read from a client side config in preInitializeService() method). Plus, I'm adding 2 more methods, which expose setCredentials and setRemoteCredentials methods of _serviceControl, so I can acces it from my code.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    package services.myservice
        public class MyService extends _Super_MyService
             * Override super.init() to provide any initialization customization if needed.
            protected override function preInitializeService():void
                super.preInitializeService();
                // Initialization customization goes here
                _serviceControl.endpoint = "http://localhost/myapp/gateway.php";
            public function setCredentials(username:String, password:String, charset:String=null):void
                _serviceControl.setCredentials(username, password, charset);
            public function setRemoteCredentials(username:String, password:String, charset:String=null):void
                _serviceControl.setRemoteCredentials(username, password, charset);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    So, before calling MyService methods, I'm setting the credentials with setCredentials() method and this runs the authentication on the PHP side:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    private var service:MyService;
    service = new MyService(); // ServiceLocator.getInstance().getHTTPService("presetLoader");
    service.setCredentials("user1", "pass1");
    var token:AsyncToken = service.getData();
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    The authentication via Zend_Amf_Server is, by the way, OPTIONAL! Meaning, with no credentials supplied, Zend_Amf_Server will NOT RUN IT. Thus you should rely on Zend_Acl (e.g. roles) to so your permissions and security! 
    Finally, here's the MySQL DB table I've been using for authentication: 
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    -- Table structure for table `users`
    CREATE TABLE IF NOT EXISTS `users` (
      `id` int(11) NOT NULL AUTO_INCREMENT,
      `username` varchar(50) NOT NULL,
      `password` varchar(32) DEFAULT NULL,
      `role` varchar(45) DEFAULT NULL,
      `firstname` varchar(50) DEFAULT NULL,
      `lastname` varchar(50) DEFAULT NULL,
      `email` varchar(255) DEFAULT NULL,
      PRIMARY KEY (`id`),
      UNIQUE KEY `username` (`username`),
      UNIQUE KEY `id_UNIQUE` (`id`)
    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; 
    -- Dumping data for table `users`
    INSERT INTO `users` (`id`, `username`, `password`, `role`, `firstname`, `lastname`, `email`) VALUES
    (1, 'user1', 'pass1', 'administrator', 'Danko', 'Kozar', NULL); 
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Cheers!
    Danko

  • Zend AMF Slow Response

    I am getting slow response times when using Zend AMF in Flash Builder 4.  It is taking between 1.5s to 2s to return the results, which is much slower than when I am returning XML.  However its about the same no matter if no records are returned or if 1000 records are returned. It seems like it is taking a while to make the connection to the gateway.php file. Anyone else noticing issues like this?  All the examples I have seen online use Apache instead of IIS, could that be part of my problem?
    Thanks,
    Justin

    I experienced the same with Zend and switched to coldfuion as a result. Its better matched
    to Flex, and you can go as far as Life Cycle Data services with it if you want. It is also a superior
    design to php but works pretty much the same way.
    The communications with Flashbuilder have several gotchas which are not explained but are covered here now.
    The old php 4 AmfPhp was really impressive performer on speed. But it just took a dive when it went
    to zend and 5.
    Dan Pride

  • Zend AMF and Flash Builder Tutorial

    As part of the good ole new years resolution, I decided to sit down and take a shot at learning Flash. As a PHP developer by profession, I was curious about Zend AMF, part of the Zend PHP Framework. After finding it difficult to get a barebones working example, I decided to write a tutorial from the beginner's perspective (except the PHP part). The result is on the blog post located here:
    http://flearn.wordpress.com/2011/03/01/zend-amf-basics/
    I put it on a wordpress blog as it has nice code highlighting features and saves drafts for me. My hope is that it provides a basic guide on getting Zend AMF up and running with a basic barebones app, and would like feedback on any of the content.

    Thaaaaaank you maaaaan!
    Seriously - I was about to put a brick through my screen.

  • Flex4 Zend AMF error - NetConnection.Call.Failed: HTTP

    Hi,
    I'm working with FLEX 4 (developing in flash builder 4 plugins for eclipse) and PHP Zend Framework v 1.9.
    When I run the application from the flash builder the AMF comunication work fine, but when I try to run directly from URL in a browser I got the following error: 
    Send failed
    Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Failed: url: 'http://localhost/Project-debug/gateway.php'
    I think that I get this error since I have update my flash builder plugin.... previos version of my .swf project didn't give my this issue.
    Somebody can help me? I don't realy have any idea how to solve this problem.
    P.S.
    I don't have services-config.xml file in my project cause the amf zend samples that I followed don't say to create it, somebody knows why flex 4 doesn't need it?
    Thanks

    The MessageBroker servlet is not installed properly. The context-root of the two Tomcat LC DS installs must be different. Test hitting the context-root Flex_App on both machines (http://hostIP:8080/Flex_App). If the context-root is valid you will hit the index.html page of the valid context-root which looks like this...
    Welcome to Adobe LiveCycle Data Services ES2 Version  3!
    This is an empty LiveCycle Data Services ES application that serves as a  template for creating your custom application.
    Visit the product page for documentation and further information.
    Steve

  • Zend AMF issue

    I've got an application that uses Zend Framework to make PHP calls to access a db.  Everything works fine on my development server.  After a few issues, I made the necessary changes to amf_config.ini for the production server.  I checked that the endpoint is fine by just loading the gateway.php directly. Works fine there, and the application is functional, but I have a bizarre performance issue.
    Loading up the gateway.php on its own, or performing any remote call takes an extremely long time - nearly a minute.  This happens when just loading the gateway.php file so it seems a ZendAMF thing, not Flex itself.  I've also removed all php files (except Zend Framework and the gateway.php), and it's still slow, so it's not not from the addDirectory part of the gateway.php.  Any ideas what might be causing this extreme slowdown?  I've temporarily gone to getting rid of Zend and just using PHP and XML, but this is not ideal.
    gateway.php contents
    <?php
    ini_set("display_errors", 1);
    $dir = dirname(__FILE__);
    $webroot = $_SERVER['DOCUMENT_ROOT'];
    $configfile = "$dir/amf_config.ini";
    //default zend install directory
    $zenddir = $webroot. '/ZendFramework/library';
    //Load ini file and locate zend directory
    if(file_exists($configfile)) {
    $arr=parse_ini_file($configfile,true);
    if(isset($arr['zend']['webroot'])){
    $webroot = $arr['zend']['webroot'];
    $zenddir = $webroot. '/ZendFramework/library';
    if(isset($arr['zend']['zend_path'])){
    $zenddir = $arr['zend']['zend_path'];
    // Setup include path
    //add zend directory to include path
    set_include_path(get_include_path().PATH_SEPARATOR.$zenddir);
    // Initialize Zend Framework loader
    require_once 'Zend/Loader/Autoloader.php';
    Zend_Loader_Autoloader::getInstance();
    // Load configuration
    $default_config = new Zend_Config(array("production" => false), true);
    $default_config->merge(new Zend_Config_Ini($configfile, 'zendamf'));
    $default_config->setReadOnly();
    $amf = $default_config->amf;
    // Store configuration in the registry
    Zend_Registry::set("amf-config", $amf);
    // Initialize AMF Server
    $server = new Zend_Amf_Server();
    $server->setProduction($amf->production);
    if(isset($amf->directories)) {
    $dirs = $amf->directories->toArray();
    foreach($dirs as $dir) {
        // get the first character of the path.
        // If it does not start with slash then it implies that the path is relative to webroot. Else it will be treated as absolute path
        $length = strlen($dir);
        $firstChar = $dir;
        if($length >= 1)
        $firstChar = $dir[0];
        if($firstChar != "/"){
        // if the directory is ./ path then we add the webroot only.
        if($dir == "./"){    
        $server->addDirectory($webroot);
        }else{
        $tempPath = $webroot . "/" . $dir;
    $server->addDirectory($tempPath);
    }else{
       $server->addDirectory($dir);    
    // Initialize introspector for non-production
    if(!$amf->production) {
    $server->setClass('Zend_Amf_Adobe_Introspector', '', array("config" => $default_config, "server" => $server));
    $server->setClass('Zend_Amf_Adobe_DbInspector', '', array("config" => $default_config, "server" => $server));
    // Handle request
    echo $server->handle();
    Thanks for any help!

    Geez, nevermind! I had the code above the check for the "send".
    I wish there was a way to delete our own posts in these forums. Moderator?!?

  • Deploying Air Application with Zend AMF Dataservices to remote server?

    I cannot find anything to guide me through getting this set up.. it's frustrating because I feel this is probably the whole point of Air!
    I have an Air project in Flash Builder which is set up with the Data/Services panel, using a custom php model file.
    It's working fine on localhost, but I do not know what is necessary to have it work while the app is running locally but connecting to a remote server (can get it working as a flex app in browser hosted remotely, though)
    I uploaded the Zend framework and my custom php files to the net
    I changed the amf_config.ini file .. the webroot and the zend_path, I assume, should be different depending whether it's localhost or on a server, so I changed the one online to be match where the files are.
    I found in the _super_Database.as it was referencing the Zend gateway.php locally, so I changed that to be an absolute link to where I put gateway.php on the server.
    But I'm not sure what to do next... I assume I only need the Zend framework and the php files I'm using online, but then there is no link to my Database.php anywhere other than as a symbolic link from services/Database.php to the bin-debug folder.. but I don't know how exactly to put that on the server and then compile my app... and I can't find any explanations anywhere.
    Anyone know how to go about this?

    Hello everyone,
    Exact the same problem here. I've build an Air app with PHP in the backend. On my localhost it works fine...  but, when i am tranfer it to the remote server it just won't work.
    I have changed settings in amf_config.ini and in gateway.php, and I have changed the settings in super class of my flash file, so it knows where to find the new gateway.php.
    Can someone please help a hand... (mmm it is almost Christmas .... )
    Thanks., Erik

  • Zend AMF Error on Server

    Hi,
    I am new to Zend Framework, i have created an application in Flex and PHP with Zend Framework.
    When i uploaded it on the server, following error is displayed:
    Send failed
    Channel.Connect.Failed error NetConnection.Call.BadVersion: : url: 'http://www.mydomain.com/app/gateway.php'
    How can i find more details about this error, so that i can sovle the issue?
    Best Regards,
    Alok Jain

    I have resolved previous error, path to zend Framework was incorrect
    Now i am facing a new error:
    "Channel disconnected before an acknowledgement was received"
    Any Help Please.
    Best Regards,
    Alok Jain

  • Zend Amf & Flex 3, problem when many records returned

    I have a project with a start dateField (calendar) and an end dateField (calendar). The user chooses a start date and an end date and the database pulls latitude and longitude coordinates for events that occurred between those dates. If the user chooses dates that produce fewer than roughly 11,200 records, it works perfectly.  If the user chooses dates that produce more than that, it produces the following error message:
    faultCode:Client.Error.DeliveryInDoubt
    faultString:'Channel disconnected'
    faultDetail:'Channel disconnected before an acknowledgement was received'
    The server is my local machine (localhost). I'm running:
    MAMP   (which has  Apache 2.0.59)
    Flex 3
    I tried editing the my.cnf (mySQL options file) and increased the max_allowed_packet to 32M, but that didn't work.
    It's a strange problem as the same code works when a relatively small amount of data is returned, but doesn't work when more data is pulled. Could it be some sort of memory or packet limit or a time-out that is called?
    If anyone has any suggestions, please let me know. 
    -Laxmidi

    Richard Bates of flexandair.com figured it out. In my php.ini file, I had the memory limit set at 8M. After, changing it to 32M, it worked. Thank you, Richard!
    -Laxmidi

Maybe you are looking for

  • ERROR: No valid domain present

    While installing OATS in custom mode. getting the below error in deploy.log. kindly suggest as to what can be done. ERROR: No valid domain present And also Observed this in the "config_ds.log" file . Initializing WebLogic Scripting Tool (WLST) ... We

  • How do I copy an image from one Keynote presentation to another one?

    I have a previously saved presentation on Keynote in iCloud. I created it from my desktop at work. Some of the images I used for the presentation I want to use again in another presentation, onlh this time I am working off my laptop and don't have th

  • App's will not go from itunes to ipod!

    This is really frustrating me, and I hope someone can help. I recently got a new computer, and I decided that I wanted to put apps onto my itouch. So to do so i restored my ipod and synced my ipod to the new itunes. I downloaded apps from the store a

  • Direct Connectivity to systems source

    Please i have a question: Should the OWB Client (Design component) have direct connection to the system sources, to import metadata, or the import will be executed from server_Repository(design), in this case only the server_side must be connected to

  • How to configure Internet/

    Hi i have installed Solaris 10 u5 now and I also have the LAN connection. So my query is How should I configre the LAN? like IP Address, DNS..