5 Replies Latest reply on Aug 14, 2006 6:44 PM by Renaun_Erickson

    Flex 2 CFC w/ Coldfusion 7.0.1?

    I3 Level 1
      Hi there all,

      My shared host (HostMySite) is currently in the process of upgrading their servers to 7.0.2, but of course I cannot wait for the update to be applied as I have some things to get launched in beta for a client.

      My question is this: Is there any way to connect to a CFC on a CF 7.0.1 server from Flex 2?

        • 1. Re: Flex 2 CFC w/ Coldfusion 7.0.1?
          peterent Level 2
          Yes, you can use the original Flash Remoting gateway built into CF:

          In your RemoteObject set the endpoint to the location of the Flash gateway in ColdFusions:
          endpoint=" http://host:port/flashservices/gateway"

          Then set the source parameter of RemoteObject to the path of the CFC without the .cfc extension.
          • 2. Re: Flex 2 CFC w/ Coldfusion 7.0.1?
            I3 Level 1

            Thank you but I am currently facing another error with that suggestion. When I call the CFC, I now receive the following Error:

            TypeError: Error #1034: Type Coercion failed: cannot convert Object@48022a1 to mx.messaging.messages.ErrorMessage.

            The supporting code which makes the call is below:

            import mx.rpc.remoting.mxml.RemoteObject;

            var lro:RemoteObject = new RemoteObject("ColdFusion");
            lro.endpoint = ' http://www.desktopae.com/flashservices/gateway';
            lro.source = "cfc.Security";
            lro.addEventListener("fault", loginFault);
            lro.checkLoginCredentials.addEventListener("result", loginResult);
            lro.checkLoginCredentials(username, password);

            Thanks for any assistance you can offer.
            • 3. Re: Flex 2 CFC w/ Coldfusion 7.0.1?
              peterent Level 2
              It turns out there is more to the story. Without 7.0.2, CF must receive objects encoded for ActionScript 2.0. By default, Flex 2 sends the objects using ActionScript 3.0. This is known as ObjectEncoding.AMF0 and ObjectEncoding.AMF3, respectively.

              To use Flex 2 with AMF0, you need to revert back to the way Flash does it by using a NetConnection and not a RemoteObject. When you use the NetConnection you can specify the ObjectEncoding to be AMF0. It isn't too complex, but read up on NetConnection and ObjectEncoding classes.

              Alternatively, you should be able to call your CFC using WebServices and naming the CFC as the wsdl. There should be samples of that in the documentation.
              • 4. Re: Flex 2 CFC w/ Coldfusion 7.0.1?
                I3 Level 1
                I am now researching the NetConnection objects. I appreciate all your help.

                I thought of using WebServices originally because the conversion to RemoteObjects wouldn't be that heavy when my host finally upgrades and all is well

                The problem is though, that although I can connect to a WebService, any methods I attempt to call are returned with the error message: There is no method [myMethod] on service.

                Not sure why that keeps happening, but if you do, that would be great.

                If not, thank you so much! I will certainly look into both of those deeper.
                • 5. Re: Flex 2 CFC w/ Coldfusion 7.0.1?
                  Renaun_Erickson Level 1
                  What is your WebService code?

                  useProxy = false;