|
From: Stephen D. <st...@pl...> - 2007-07-09 05:11:01
|
Yeah dumping out evt.result was one of the first things I tried, it =20 is still giving me just plain old Object and not a TestObj. I just installed Charles. Here are the results from testing this test =20= Flex project, I'm not sure what it means but I can see TestObj class =20 being targeted (you can see that my object is actually in the =20 com.visionarium.timesheet package, a bit different from the example =20 previously posted): HTTP/1.1 200 OK Date: Mon, 09 Jul 2007 05:03:45 GMT Server: Apache/2.2.3 (Unix) mod_ssl/2.2.3 OpenSSL/0.9.7l DAV/2 PHP/5.1.6 X-Powered-By: PHP/5.1.6 Expires: Sun, 8 Jul 2007 22:03:45 GMT Cache-Control: no-store Pragma: no-store Content-length: 357 Keep-Alive: timeout=3D5, max=3D100 Connection: Keep-Alive Content-Type: application/x-amf =00=00=00=01=00=12AppendToGatewayUrl=00=00=00=00.=02=00+?=20 PHPSESSID=3Deb93ffe9a67a0a6c2880e84728bbd803=00=01=00=0B= /1/onResult=00=04null=00=00=01=01=11 =0B= Uflex.messaging.messages.AcknowledgeMessage=13messageId=06I30E0393D-24F1-2= 3=20 08-F39E-00007D2D6B44=11clientId=06I390767D6-4BFE-9109-=20 CB80-00003D24CE2A=17destination=01 =20 body=01=15timeToLive=04=00=13timestamp=05A=DF=FF=FF=FF=C0=00=00=0Fheaders =0B=01=01=1BcorrelationId=06I2C4D9EDB-2C01-2848-EBC6-A95C9CBB2D3B=01HTTP/1= .1 200 OK Date: Mon, 09 Jul 2007 05:03:45 GMT Server: Apache/2.2.3 (Unix) mod_ssl/2.2.3 OpenSSL/0.9.7l DAV/2 PHP/5.1.6 X-Powered-By: PHP/5.1.6 Expires: Sun, 8 Jul 2007 22:03:45 GMT Cache-Control: no-store Pragma: no-store Content-length: 417 Keep-Alive: timeout=3D5, max=3D99 Connection: Keep-Alive Content-Type: application/x-amf =00=00=00=01=00=12AppendToGatewayUrl=00=00=00=00.=02=00+?=20 PHPSESSID=3Deb93ffe9a67a0a6c2880e84728bbd803=00=01=00=0B= /2/onResult=00=04null=00=00=01=3D=11 =0BUflex.messaging.messages.AcknowledgeMessage=13messageId=06I402E5BBE-=20= BAD0-4CA9-F34E-00003F54AB5A=11clientId=06I5788ADD0-6D89-B829-=20 F24F-00003711EDA1=17destination=01 body =0BCcom.visionarium.timesheet.TestObj=11testProp=06=1BTest prop =20 set=01=15timeToLive=04=00=13timestamp=05A=DF=FF=FF=FF=C0=00=00=0Fheaders =0B=01=01=1BcorrelationId=06I233188A8-981C-4A65-A35E-A95C9C9F3 Thanks very much for the reply Patrick. Amfphp 1.9/2 is really =20 impressive and helping greatly on my project. Steve On 2007-07-08, at 8:40 PM, Patrick Mineault wrote: > Hey old mate, > > Your code looks good to me, the _explicitType, the RemoteClass, all > that is fine. I'm thinking it probably has to do with this piece here: > > _testObjAC =3D new ArrayCollection( ArrayUtil.toArray(evt.result) ); > > Have you tried simply tracing evt.result is TestObj? > > The thing that might help you is looking at it in Charles. Normally it > should be able to tell you if php has sent back a typed object or a > dummy object. If it sends back a typed object, then the error is on > the Flash side, somewhere along the line Flash is not using the > RemoteClass info for some bizarre reason. Let me know. > > Patrick > > 2007/7/8, Stephen Downs <st...@pl...>: >> I'm having a very difficult time understanding why my custom class =20= >> objects >> returned from amfphp are being cast as generic Object instances =20 >> instead of >> instances of their class. >> >> I am using Flex Builder 2, AMFPHP 1.9, and using RemoteObject, =20 >> which follows >> Alessandro's terrific example ( >> http://www.sephiroth.it/tutorials/flashPHP/flex_remoteobject/ >> ). >> >> I set up a project exactly as in Alessandro's example, and the =20 >> resulting >> ArrayCollection is properly populated with Person class instances. =20= >> All well >> and good. >> >> >> Now I try to create an example from scratch, but it doesn't work. =20 >> Here's how >> I set it up (apologies in advance for sending all this code, but I've >> literally wasted a day and a half trying to fix this): >> >> On my server, I have amfphp installed in the amfphp2 directory. My =20= >> services >> and php classes are set up as follows: >> >> amfphp2/services/com/mycompany/timesheet/TestObjService.php >> (my service) >> amfphp2/services/com/mycompany/timesheet/TestObj.php (my >> custom class) >> >> -------------------------------------------------------------------- >> TestObjService.php: >> >> >> <?php >> >> require_once "./TestObj.php"; >> >> class TestObjService { >> >> function getTestObj() { >> $tObj =3D new TestObj(); >> $tObj->testProp =3D "Test prop set"; >> return $tObj; >> } >> } >> >> >> -------------------------------------------------------------------- >> TestObj.php: >> >> >> <?php >> >> class TestObj { >> var $testProp; >> >> // explicit actionscript package >> var $_explicitType =3D "com.mycompany.timesheet.TestObj"; >> } >> >> ?> >> >> -------------------------------------------------------------------- >> -------------------------------------------------------------------- >> My Flex Builder project is set up as: >> >> Test3/Test3.mxml (Application mxml) >> Test3/services-config.xml >> Test3/com/mycompany/timesheet/TestObj.as (AS custom class) >> >> -------------------------------------------------------------------- >> Test3.mxml: >> >> >> <?xml version=3D"1.0" encoding=3D"utf-8"?> >> <mx:Application xmlns:mx=3D"http://www.adobe.com/2006/mxml" =20 >> layout=3D"absolute" >> creationComplete=3D"initApp()"> >> >> <mx:RemoteObject id=3D"myService" >> source=3D"com.mycompany.timesheet.TestObjService" >> destination=3D"amfphp" showBusyCursor=3D"true" > >> <mx:method name=3D"getTestObj" >> result=3D"getTestObjHandler(event)" /> >> </mx:RemoteObject> >> >> >> <mx:Script> >> <![CDATA[ >> >> >> import com.mycompany.timesheet.TestObj; >> import mx.collections.*; >> import mx.rpc.events.ResultEvent; >> import mx.utils.ArrayUtil; >> >> >> [Bindable] >> private var _testObjAC:ArrayCollection; >> >> >> public function initApp():void { >> myService.getTestObj(); >> } >> >> >> private function getTestObjHandler(evt:ResultEvent):void >> { >> _testObjAC =3D new ArrayCollection( ArrayUtil.toArray(evt.result) = ); >> // Returns Object instead of TestObj instance! >> trace(_testObjAC.getItemAt(0)); >> } >> >> >> ]]> >> </mx:Script> >> >> >> </mx:Application> >> >> -------------------------------------------------------------------- >> TestObj.as class: >> >> >> package com.mycompany.timesheet { >> >> >> [RemoteClass(alias=3D"com.mycompany.timesheet.TestObj")] >> [Bindable] >> public class TestObj { >> public var testProp:String; >> } >> >> >> } >> >> >> -------------------------------------------------------------------- >> services-config.xml (this same file works using Alessandro's =20 >> example): >> >> >> <?xml version=3D"1.0" encoding=3D"UTF-8"?> >> <services-config> >> <services> >> <service id=3D"amfphp-flashremoting-service" >> class=3D"flex.messaging.services.RemotingService" >> messageTypes=3D"flex.messaging.messages.RemotingMessage"> >> <destination id=3D"amfphp"> >> <channels> >> <channel ref=3D"my-amfphp"/> >> </channels> >> <properties> >> <source>*</source> >> </properties> >> </destination> >> </service> >> </services> >> <channels> >> <channel-definition id=3D"my-amfphp" >> class=3D"mx.messaging.channels.AMFChannel"> >> <endpoint uri=3D"http://localhost/amfphp2/gateway.php" >> class=3D"flex.messaging.endpoints.AMFEndpoint"/> >> </channel-definition> >> </channels> >> </services-config> >> >> >> -------------------------------------------------------------------- >> -------------------------------------------------------------------- >> Additional notes: >> >> The compiler arguments for Test3.mxml are set to: >> -locale en_US -services "services-config.xml" >> >> >> For now I'll have to parse through the resulting array and cast =20 >> each item to >> my custom class in AS. Not an ideal option. >> >> Thanks for any input. >> Steve >> >> >> ---------------------------------------------------------------------=20= >> ---- >> This SF.net email is sponsored by DB2 Express >> Download DB2 Express C - the FREE version of DB2 express and take >> control of your XML. No limits. Just data. Click to get it now. >> http://sourceforge.net/powerbar/db2/ >> _______________________________________________ >> amfphp-general mailing list >> amf...@li... >> https://lists.sourceforge.net/lists/listinfo/amfphp-general >> >> > > ----------------------------------------------------------------------=20= > --- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > amfphp-general mailing list > amf...@li... > https://lists.sourceforge.net/lists/listinfo/amfphp-general |