Jamie,

The RemoteObject (client side) found in my example is the same code
used for Cairngorm or non-Cairngorm applications.  

Flex 2.0 and AMF3 (not sure where the requirement comes from, probably
AMF3) requires that you have a destination defined.  

For Java adapters you can not use the "source" attribute and must
explicitly set it in the configuration file.  By default FDS is setup
to have the main config file be services-config.xml which includes
other files, here is an example.
    <services>
        <service-include file-path="remoting-config.xml" />
        <service-include file-path="proxy-config.xml" />
        <service-include file-path="messaging-config.xml" />
        <service-include file-path="data-management-config.xml" />
    </services>

The default ColdFusion Adapter which is setup by ColdFusion MX 7.0.2
defines a destination named ColdFusion and with a source="*" which
allows the developer to set the source attribute on the RemoteObject.
 The defualt endpoint is also setup to:

    <channels>
        <channel-definition id="my-cfamf"
class="mx.messaging.channels.AMFChannel">
            <endpoint
uri="http://{server.name}:{server.port}/flex2gateway/";
class="flex.messaging.endpoints.AMFEndpoint"/>
            <properties>
                <polling-enabled>false</polling-enabled>
                <serialization>
                    <instantiate-types>false</instantiate-types>
                </serialization>
            </properties>
        </channel-definition>
    </channels>

For other technologies supporting AMF3 it depends on how they are
implemented.  But since they are custom adapters they are pretty much
open and do not have any restrictions and following ColdFusion's
config setup works for SabreAMF, WebORB for PHP, and AMFPHP 1.9.

You can find examples of all three on my blog.  But the particular
AMFPHP 1.9 example shows that the config file doesn't even need to be
called services-config.xml.  I setup the Flex project and point the
-services compiler argument to amfphp19-services-config.xml file.  In
side this file I setup a basic destination and the most import part
setup the endpoint.

<?xml version="1.0" encoding="UTF-8"?>
<services-config>
    <services>
        <service id="sabreamf-flashremoting-service"
                 class="flex.messaging.services.RemotingService"
                 messageTypes="flex.messaging.messages.RemotingMessage">
            <destination id="AMFPHP1_9">
                <channels>
                    <channel ref="my-amfphp19"/>
                </channels>
                <properties>
                    <source>*</source>
                </properties>
            </destination>
        </service>
    </services>

    <channels>
        <channel-definition id="my-amfphp19"
class="mx.messaging.channels.AMFChannel">
            <endpoint
uri="http://{server.name}:{server.port}/amfphp1_9/gateway.php";
class="flex.messaging.endpoints.AMFEndpoint"/>
        </channel-definition>
    </channels>
</services-config>

Now you have to have the destination but the endpoint is optional.  So
you with the above configuration file link into the compiler through
-services argument you can have RemoteObject code like:

        <mx:RemoteObject 
                        id="roTestService" 
                        destination="AMFPHP1_9"
                        source="MyTestService"
                        result="Alert.show( event.result + '', 'Result' )"
                        fault="Alert.show( event.fault.faultString , 'Error' )">
           <mx:method name="testMethod" />
        </mx:RemoteObject> 


Note: for FDS default setup you will want to add the services
destination and channel configuration code to the remoting-config.xml.

I just updated my CairngormStore Multiple Backend example and have put
it live on my blog.  You can find the live running example at:
http://api.renaun.com/flex2/posts/CairngormStoreMultipleBackend/

It demonstrates how to connect to different backends, ColdFusion,
AMFPHP (AMF0 using my RemoteObjectAMF0), AMFPHP 1.9 (AMF3), and
WebServices.  You can get the source at:
http://api.renaun.com/flex2/posts/CairngormStoreMultipleBackend/CairngormStoreMultipleBackend.zip

Hope that helps,

Renaun

PS: I just noticed your other post I'll post directly to you code in bit.

--- In flexcoders@yahoogroups.com, "Jamie O" <[EMAIL PROTECTED]> wrote:
>
> Hello,
> 
> I am able to do a stand-alone .mxml project using the samples you have
> provided and connect well to my php methods / backend database. The
> issue I have is when trying to deploy this as part of a Flex Data
> Services / Cairngorm app I can't get the remote object to allow
> compile or usage without error.
> 
> Anyone have a cairngorm / FDS scope example for using AMFPHP 1.9?
> 
> If I do the closest equivelent of adding the relevant contents of your
> services-config.mxml to the already created one for FDS I get a
> "Destination 'AMFPHPDestination' must specify at least one adapter"
> error message when starting the server (Tomcat 5.5)
> 
> If I do a purely-client side entry of the endpoint in the
> services.mxml instantiation I get other errors - and this is also not
> a way I want to go as the endpoint URL would be exposed.
> 
> Renaud's examples don't seem to include cairngorm-ified versions as
> was the case in the past and I haven't managed to crack this nut.
> 
> Thx,
> Jamie
> 
> --- In flexcoders@yahoogroups.com, Patrick Mineault
> <patrick.mineault@> wrote:
> >
> > Hi all,
> > 
> > I've finally gotten around to add AMF3 support to amfphp, so you can 
> > finally use Flex 2's RemoteObject with it. To test the new features, 
> > I've created a new Service Browser in Flex 2 which allows you to 
> > introspect services and test methods on the fly. I need people to
test 
> > out the new AMF3 support.
> > 
> > New/changed features:
> > 
> > - $this->methodTable is DEAD. All methods in /services are now 
> > considered remotely accessible, unless you set them to protected or 
> > private (PHP5) or start the method name with an (_), in which case it 
> > will throw an error. If you want to get a description of a method and 
> > it's arguments without looking at the class itself, add JavaDoc to
the 
> > method and you should see it in the new Service Browser.
> > - _authenticate is dead, as a side-effect of the removal of the 
> > methodTable. You can secure methods by creating a special function 
> > called "beforeFilter($methodName)" in your class and return false to 
> > stop a method from being executed. (the _ and the beforeFilter are
the 
> > conventions used by CakePHP, so I figured I'd use those instead of 
> > rolling my own).
> > - Circular references in AMF0 and AMF3 should now work. Class mapping 
> > code has been ported to the AMF3 code also. To use remote class
> mapping, 
> > use registerClassAlias or the [RemoteClass] metadata tag, then
read the 
> > instructions in advancedsettings.php
> > - Returning a mysql_query will now return either an Array or an 
> > ArrayCollection depending on the setting in gateway.php. Other
database 
> > types are currently unsupported in AMF3 mode (they will be
supported as 
> > soon as I am sure the AMF3 code is perfect).
> > - You can send ByteArray, ArrayCollection and ObjectProxy
instances as 
> > arguments to remote methods. You will receive the result as a
> string, as 
> > the inner array and as the inner object, respectively. Currently
there 
> > is no way to send back these types to Flash, but there will be in the 
> > next version.
> > - /browser now brings up the brand spanking new Flex 2-based service 
> > browser. You can test methods directly through it. If the method
> returns 
> > an array or arraycollection, the browser will attempt to show it in a 
> > datagrid (sweet). Please feel free to modify servicebrowser.mxml
(it's 
> > very spaghetti-code-ish, but it works). You will need the Adobe
corelib 
> > to compile (google for the link)
> > 
> > Limitations/things to keep in mind:
> > 
> > - MySql works but not other databases
> > - You can use a JSON string for arguments in the service browser. 
> > However you must wrap object keys in quotes (a limitation of Adobe
> corelib).
> > - Paged recordsets don't work anymore
> > - Only tested in PHP5. PHP4 might show issues with circular
references.
> > - Calling two methods on a remoteObject one after the other
(during the 
> > same frame) might not work.
> > - Charles and ServiceCapture have some issues with AMF3 handling. You 
> > might see strings which seem out of place in your output while it
works 
> > fine in Flash. I will notify the people involved. You might want
to set 
> > PRODUCTION_SERVER to true in gateway.php if this is a recurrent
> problem, 
> > in the meantime.
> > - If you need to send to Flash a class and want it to be mapped to a 
> > class in a package, you need to add a key to the class called 
> > _explicitType with a value of "com.mypackage.TheClass" and use 
> > registerClassAlias or [RemoteClass] as usual ( a limitation of php
not 
> > supporting packages)
> > 
> > All that being said, I need testers. Please download it here:
> > 
> > http://5etdemi.com/uploads/amfphp-1.9.alpha.zip
> > 
> > (although it states it is amfphp 1.9, there will be no amfphp 1.9. 
> > amfphp 2.0 will be amfphp 1.9 + JSON and possibly XML-RPC)
> > 
> > If you run into any issues, please either:
> > 
> > - Create a minimal test case which shows the reproducible bug, then
> send 
> > it to me.
> > - In gateway.php, uncomment $gateway->logIncomingMessages and 
> > logOutgoingMessages, create an in and an out folder and run it again. 
> > Then send the log files (*.amf) to me.
> > 
> > Please send the feedback to pm AT 5etdemi DOT com. I am confident it 
> > should be pretty stable, as most of the new code is lifted from 
> > Fluorine, but you never know. Once I am 100% sure the amf 3 code is 
> > bulletproof I will release another version with some publicity on the 
> > blog and the homepage (currently keeping the new code low-profile).
> > 
> > Thanks,
> > 
> > Patrick
> >
>


Reply via email to