18 Replies Latest reply on Aug 4, 2011 7:18 AM by daslicht

    Flex Builder 4 Data Service integration (PHP)

    daslicht Level 2

      Hi,

      preface:

      created a dataservice form a existing MySQL Database (Bioographies of Artists)

       

      When I call the functions from within the Flash 4 Builders 'Data/Services' Tab they work flawless. (add, delete, update)

       

      Lets assume that the following value object has been created:

      'Artists_biography'

       

       

      I try now to call the service via Actionscript like the following:

       

      var updateObject:Artists_biography = new Artists_biography();
            updateObject.biography_de = contentToSave;
            updateObject.biography_id = biography_id;
            updateObject.artists_id = artist_id;
      updateArtists_biographyResult.token = artistsbiographyService.updateArtists_biography(updateObject);
      

       

       

      I get this:

      Error: Unable to find data service for value: valueObjects::Artists_biography

       

      I also tried to use the mxml valueObject like this:

      <valueObjects:Artists_biography id='updateObject' />

       

      Even the autocreated forms produce this error

      Any hint why this happens ?

      Help *please*

        • 1. Re: Flex Builder 4 Data Service integration (PHP)
          daslicht Level 2

          Hi,

          I worked out a 100% reproducaeable example so that we can narrow this issue down:

           

          1)
          create new database with the name updateTest

           

          2)

          create the following table:

           

          CREATE TABLE `updateTest`.`updateTest` (
          `id` INT( 255 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
          `content` TEXT NULL
          ) ENGINE = MYISAM ;

           

          3)
          drag a datagrid into DesignView

           

          4)

          connect to Dataservice via PHP and generate sample classes from the created database

           

          5)

          drag 'getAllUpdateTest()' on the datagrid

           

          6)

          generate Form from 'createUpdateTest(item:UpdateTest)'
          Edit Property Mapping and disable id from inputs (the id will be auto incremented)

           

          Ok now we can add new entries.

           

          7)

          Now generate a Form, from 'updateUpdateTest(item:UpdateTest)

           

          When you now try to update one existing entry we get:

           

          Error: Unable to find data service for value: valueObjects::UpdateTest {
            content = "cool"
            id = 1
          }
              at mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::getDataServiceForValue()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\DataStore.as:3000]
              at mx.data::MessageBatch/http://www.adobe.com/2006/flex/mx/internal::getMessageIdsForItems()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\MessageBatch.as:735]
              at mx.data::MessageBatch/http://www.adobe.com/2006/flex/mx/internal::extractMessages()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\MessageBatch.as:625]
              at mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::doCommit()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\DataStore.as:2417]
              at mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::internalCommit()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\DataStore.as:1222]
              at mx.data::DataStore/commit()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\DataStore.as:868]
              at mx.data::ConcreteDataService/updateItem()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\ConcreteDataService.as:1109]
              at mx.data::DataManager/updateItem()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\DataManager.as:2139]
              at Function/http://adobe.com/AS3/2006/builtin::apply()
              at mx.data::ManagedOperation/updateItemProxy()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\ManagedOperation.as:495]
              at mx.rpc.remoting::Operation/send()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\remoting\Operation.as:212]
              at _Super_UpdateTestService/updateUpdateTest()[/Applications/MAMP/htdocs/MusicShopWorkspace/UpdateTest/src/services/updatetestservice/_Super_UpdateTestService.as:259]
              at UpdateTestApp/button2_clickHandler()[/Applications/MAMP/htdocs/MusicShopWorkspace/UpdateTest/src/UpdateTestApp.mxml:32]
              at UpdateTestApp/__button2_click()[/Applications/MAMP/htdocs/MusicShopWorkspace/UpdateTest/src/UpdateTestApp.mxml:69]

           

           

           

          Thats my MXML code

           

          <?xml version="1.0" encoding="utf-8"?>
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                            xmlns:s="library://ns.adobe.com/flex/spark" 
                            xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768" xmlns:dynamictextservice="services.dynamictextservice.*" xmlns:valueObjects="valueObjects.*" xmlns:mx2="library://ns.adobe.com/flex/mx" xmlns:updatetestservice="services.updatetestservice.*">
               <fx:Script>
                    <![CDATA[
                         import mx.events.FlexEvent;
                         import mx.controls.Alert;
                         
                         protected function dataGrid_creationCompleteHandler(event:FlexEvent):void
                         {
                              getAllUpdateTestResult.token = updateTestService.getAllUpdateTest();
                         }
                         
                         
                         protected function button_clickHandler(event:MouseEvent):void
                         {
                              var updateTest:UpdateTest = new UpdateTest();
                              updateTest.content = contentTextInput.text;
                              
                              createUpdateTestResult.token = updateTestService.createUpdateTest(updateTest);
                         }
                         
                         
                         protected function button2_clickHandler(event:MouseEvent):void
                         {
                              // Please uncomment the below line if Data Management is enabled for UpdateTest and updateUpdateTest is used as the create function.
                              // var updateTest2:UpdateTest = new UpdateTest();
                              updateTest2.id = parseInt(idTextInput.text);
                              updateTest2.content = contentTextInput2.text;
                              
                              updateUpdateTestResult.token = updateTestService.updateUpdateTest(updateTest2);
                         }
                         
                    ]]>
               </fx:Script>
               <fx:Declarations>
                    <s:CallResponder id="getAllUpdateTestResult"/>
                    <updatetestservice:UpdateTestService id="updateTestService" fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)" showBusyCursor="true"/>
                    <valueObjects:UpdateTest id="updateTest"/>
                    <s:CallResponder id="createUpdateTestResult"/>
                    <valueObjects:UpdateTest id="updateTest2"/>
                    <s:CallResponder id="updateUpdateTestResult"/>
               </fx:Declarations>
               <mx2:DataGrid x="14" y="12" id="dataGrid" creationComplete="dataGrid_creationCompleteHandler(event)" dataProvider="{getAllUpdateTestResult.lastResult}">
                    <mx2:columns>
                         <mx2:DataGridColumn headerText="id" dataField="id"/>
                         <mx2:DataGridColumn headerText="content" dataField="content"/>
                    </mx2:columns>
               </mx2:DataGrid>
               <mx2:Form defaultButton="{button}" x="14" y="166">
                    <mx2:FormItem label="Content">
                         <s:TextInput id="contentTextInput" text="{updateTest.content}"/>
                    </mx2:FormItem>
                    <s:Button label="CreateUpdateTest" id="button" click="button_clickHandler(event)"/>
               </mx2:Form>
               <mx2:Form x="13" y="259">
                    <mx2:FormItem label="CreateUpdateTest">
                         <s:TextInput id="createUpdateTestTextInput" text="{createUpdateTestResult.lastResult as int}"/>
                    </mx2:FormItem>
               </mx2:Form>
               <mx2:Form defaultButton="{button2}" x="14" y="325">
                    <mx2:FormItem label="Id">
                         <s:TextInput id="idTextInput" text="{updateTest2.id}"/>
                    </mx2:FormItem>
                    <mx2:FormItem label="Content">
                         <s:TextInput id="contentTextInput2" text="{updateTest2.content}"/>
                    </mx2:FormItem>
                    <s:Button label="UpdateUpdateTest" id="button2" click="button2_clickHandler(event)"/>
               </mx2:Form>
          
          </s:Application>
          


          If we call the service with help of the 'TestOperation' Tab, it is working flawless !

           

          Any help is much appreciated, *please* help

          Best Regards

          Marc

          • 2. Re: Flex Builder 4 Data Service integration (PHP)
            daslicht Level 2

            anyone from adobe, please?

            • 4. Re: Flex Builder 4 Data Service integration (PHP)
              dvine_cgn

              ... same Problem here... please help

              • 5. Re: Flex Builder 4 Data Service integration (PHP)
                daslicht Level 2

                Thank you for confirming this issue.

                I posted a bug report at:

                https://bugs.adobe.com/jira/browse/FB-26384

                 

                Please fix

                • 7. Re: Flex Builder 4 Data Service integration (PHP)
                  Radhakrishna Bhat Level 3

                  Hello,

                   

                  By default when PHP sample is generated from the database, Data Management is enabled on that service's entity (In your case, it is Artists_biography).

                  So update method of 'Artists_biography' accepts only server managed valueObjects.

                   

                  There are 2 options if you want to use updateArtists_biography in FormGen

                   

                  1. Remove update method in Data Management wizard. Context click on entity and click 'Enable Data Management' and remove the 'update' method.

                   

                  or

                   

                  2. Use getItemById operation's result. Cast it to a valueObject, edit and pass as argument to updateArtists_biography .

                   

                   

                  -Radhakrishna

                   

                   

                   

                  • 8. Re: Flex Builder 4 Data Service integration (PHP)
                    daslicht Level 2

                    Hello and Thank You Very Much for your answer!

                     

                    Removing the update Method from 'Data/Services'/'Map data Management Operations' is fixing that issue!

                     

                     

                    >So update method of 'Artists_biography' accepts only server managed valueObjects.

                    What is the differnet between the update and create method ? beside that the create method accepts valueObjects and do not have top be removed ?

                    I just want to understand how all this stuff works, down to the ground 8^)

                     

                     

                    Kindest Regards

                    Marc

                    • 9. Re: Flex Builder 4 Data Service integration (PHP)
                      daslicht-fXuEm8

                      Now I have the same Issue with a simple getAllNews call.

                      Any Idea how to fix this now ? please, when i call the function via the TestPalete its working.

                       

                      ArgumentError: Can't find ManagedQuery or ManagedOperation named: getAllNews
                           at mx.data::RPCDataServiceAdapter/executeQuery()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\RPCDataServiceAdapter.as:325]
                           at mx.data::RPCDataServiceAdapter/processDataMessage()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\RPCDataServiceAdapter.as:920]
                           at RPCDataServiceRequest/invoke()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\RPCDataServiceAdapter.as:1668]
                           at mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::invoke()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\DataStore.as:3343]
                           at <anonymous>()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\DataStore.as:1579]
                           at mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::fill()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\DataStore.as:1597]
                           at mx.data::ConcreteDataService/internalFill()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\ConcreteDataService.as:6936]
                           at <anonymous>()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\ConcreteDataService.as:1221]
                           at mx.data::ConcreteDataService/fill()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\ConcreteDataService.as:1240]
                           at mx.data::ConcreteDataService/executeQuery()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\ConcreteDataService.as:1254]
                           at mx.data::DataManager/executeQuery()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\DataManager.as:1355]
                           at Function/http://adobe.com/AS3/2006/builtin::apply()
                           at mx.data::ManagedOperation/queryProxy()[C:\depot\DataServices\branches\lcds_modeler101\frameworks\projects\data\src\mx\data\ManagedOperation.as:524]
                           at mx.rpc.remoting::Operation/send()[E:\dev\4.0.0\frameworks\projects\rpc\src\mx\rpc\remoting\Operation.as:212]
                           at _Super_NewsService/getAllNews()[C:\wamp\www\MusicShopWorkspace\SimpleA\src\services\newsservice\_Super_NewsService.as:202]
                           at main_news_component/dataGrid_creationCompleteHandler()[C:\wamp\www\MusicShopWorkspace\SimpleA\src\main_news_component.mxml:107]
                           at main_news_component/__news_DataGrid_creationComplete()[C:\wamp\www\MusicShopWorkspace\SimpleA\src\main_news_component.mxml:239]
                           at flash.events::EventDispatcher/dispatchEventFunction()
                           at flash.events::EventDispatcher/dispatchEvent()
                           at mx.core::UIComponent/dispatchEvent()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:12266]
                           at mx.core::UIComponent/set initialized()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:1577]
                           at mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:759]
                           at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\managers\LayoutManager.as:1072]
                      
                      • 10. Re: Flex Builder 4 Data Service integration (PHP)
                        Mogge 3000 Level 1

                        Me to, most of my services are not working any more. Exact same issue.

                         

                        Main Thread (Suspended: ArgumentError: Can't find ManagedQuery or ManagedOperation named: getAllShipping_rate_types)

                        mx.data::RPCDataServiceAdapter/executeQuery

                        mx.data::RPCDataServiceAdapter/processDataMessage

                        RPCDataServiceRequest/invoke

                        mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::invoke

                        <anonymous>

                        mx.data::DataStore/http://www.adobe.com/2006/flex/mx/internal::fill

                        mx.data::ConcreteDataService/internalFill

                        <anonymous>

                        mx.data::ConcreteDataService/fill

                        mx.data::ConcreteDataService/executeQuery

                        mx.data::DataManager/executeQuery

                        Function/http://adobe.com/AS3/2006/builtin::apply [no source]

                        mx.data::ManagedOperation/queryProxy

                        mx.rpc.remoting::Operation/send

                        _Super_ShippingratetypesService/getAllShipping_rate_types

                        model.presentation::ShippingRateTypesPM/getAll

                        pages::ShippingRateTypesPage/__list_creationComplete

                        flash.events::EventDispatcher/dispatchEventFunction [no source]

                        flash.events::EventDispatcher/dispatchEvent [no source]

                        mx.core::UIComponent/dispatchEvent

                        mx.core::UIComponent/set initialized

                        mx.managers::LayoutManager/validateClient

                        mx.core::UIComponent/validateNow

                        mx.managers::PopUpManagerImpl/centerPopUp

                        mx.managers::PopUpManager$/centerPopUp

                        wawe_calculator/focusPage

                        wawe_calculator/openPage

                        wawe_calculator/handleNavigation

                        wawe_calculator/___wawe_calculator_MainNavigation1_customers

                        flash.events::EventDispatcher/dispatchEventFunction [no source]

                        flash.events::EventDispatcher/dispatchEvent [no source]

                        mx.core::UIComponent/dispatchEvent

                        navigation.components::MainNavigation/handleClick

                        navigation.components::MainNavigation/___MainNavigation_Button1_click

                        • 11. Re: Flex Builder 4 Data Service integration (PHP)
                          Interactive Developer Level 1

                          Hi

                           

                          I was facing the same problem.

                           

                          As it was due to 'Data Management' property of DataService as per my understanding.

                           

                          So i have created another method in the php file with the same functionality ( just change the name of the method ) and refresh the service in FB 4 and use that method to update the data in the mysql table.

                           

                          Actually (as per my understanding ) the difference i found is only that the token returned by the original update method is an ItemReference type where as in custom method it returns a AsynToken.

                           

                          ItemReference is Strongly Typecast to the same value object which is associated with that service and if any property is missing in the returned object then it generates an error. As update method is not returned any object and it will reference to the original Referenced valueobject which is used to get the record using the getItemById(itemID).

                           

                          Where as AsynToken return a JSON object and untill we are not using any property of that returned object. DataService will not generate any error.

                           

                          Sorry if i am wrong with the above idea.

                           

                          So for now, it resolves my problem. But the actual problem is still there and finding its reason and conclusion why this problem is happening?

                           

                          Thanks

                          • 12. Re: Flex Builder 4 Data Service integration (PHP)
                            ugo gioia

                            Same problem calling the same function from different actionscript component on the same application. The dataservice is not managed and is not paged.

                             

                            :-(

                            • 13. Re: Flex Builder 4 Data Service integration (PHP)
                              daslicht Level 2

                              I have meanwhile learned how to use ZendAMF without the wizard

                               

                              It's much more FLEXible

                               

                               

                              But you can just create the code automatically and delete the service from the Services,

                              so that you dont have to write the PHP Code manually 

                              • 14. Re: Flex Builder 4 Data Service integration (PHP)
                                ugo gioia Level 1

                                Hi daslicht,

                                 

                                what do you mean exactly about using ZendAMF without the wizard?

                                 

                                Thanks,

                                 

                                 

                                 

                                Il giorno 03/ago/2011, alle ore 19.18, daslicht ha scritto:

                                 

                                I have meanwhile learned how to use ZendAMF without the wizard

                                 

                                It's much more FLEXible

                                 

                                 

                                But you can just create the code automatically and delete the service from the Services,

                                so that you dont have to write the PHP Code manually 

                                >

                                • 15. Re: Flex Builder 4 Data Service integration (PHP)
                                  daslicht Level 2

                                  OK I try to clear it:)

                                  By DataService Wizard I men the following:

                                  http://flashrealtime.com/wp-content/uploads/newfxphp/vyber-technologie-php.png

                                   

                                  When you automatically create PHP Services, the communication between Flex and PHP is solved by using the Zend Framework with help of the AMF Protocoll.

                                   

                                  Beside the integrated Zend Feature you can use it even manually which gives you more control

                                   

                                  e.g: http://corlan.org/2008/11/13/flex-and-php-remoting-with-zend-amf/

                                   

                                   

                                  Be welcome if you have any further questions.

                                  • 17. Re: Flex Builder 4 Data Service integration (PHP)
                                    ugo gioia Level 1

                                    Thanks a lot.

                                     

                                    But using corlan way you lost the Data Service View features of the new Ide and  the data management features like paginating and transactions....

                                     

                                    is It right?

                                     

                                     

                                    Il giorno 04/ago/2011, alle ore 11.24, daslicht ha scritto:

                                     

                                    OK I try to clear it:)

                                    By DataService Wizard I men the following:

                                    http://flashrealtime.com/wp-content/uploads/newfxphp/vyber-technologie-php.png

                                     

                                    When you automatically create PHP Services, the communication between Flex and PHP is solved by using the Zend Framework with help of the AMF Protocoll.

                                     

                                    Beside the integrated Zend Feature you can use it even manually which gives you more control

                                     

                                    e.g: http://corlan.org/2008/11/13/flex-and-php-remoting-with-zend-amf/

                                     

                                     

                                    Be welcome if you have any further questions.

                                    >

                                    • 18. Re: Flex Builder 4 Data Service integration (PHP)
                                      daslicht Level 2

                                      you lost the Data Service View features of the new Ide and  the data management features like paginating and transactions....

                                       

                                      is It right?

                                       

                                      Yeh you loose the DataService View thats the downside of the freedom you get.

                                      Paging should still work, I dont know transactions.

                                       

                                      Cheers

                                      Marc