15 Replies Latest reply on Sep 1, 2006 7:37 AM by peterent

    CFC Pathing with RemoteObject

    Jighead2
      Hello,
      What is the corrrect way to path a cfc using RemoteObject? I am so frickin frustrated I dont have any hair left.
      From looking at post in this forum I believ I'm not the only one. However no one from Adobe can post a simple answer.
      No matter how I path my cfc relative fully qualified I get the standard erro message that it cant find the component.

      I'm using the the latest pacage available on the Adobe site FB2 standalone and CF 7.02. My working flex directory is the default.

      Can anyone please explain in plain simple english the correct way to path a cfc with FB2 and <mx:RemoteObject />

      aaaaarrrrrggggggg!!!!

      Thank you
        • 1. Re: CFC Pathing with RemoteObject
          peterent Level 2
          Suppose you have a directory structure like this:

          c:\cfusionmx7\wwwroot\employeeapp\getemployee.cfc

          Then your RemoteObject looks like this:

          <mx:RemoteObject destination="ColdFusion" source="employeeapp.getemployee" ... >

          To verify it, in a browser enter: http://localhost:8500/employeeapp/getemployee.cfc where localhost:8500 is the host and port for your CF installation.
          • 2. Re: CFC Pathing with RemoteObject
            KomputerMan.com Level 1
            Hey Jig...
            I too have pulled out most of my hair... or maybe it was just nature...

            Anyway the point I was going to make is I was getting weird "can not connect errors" when I tried to connect to my CFC's. At first I tried to call the CFC from inside one of my CF applications but it turned out that my Application.cfc kept getting in the way. What I finally did was create a directory inside of my application called WebServices. In there I created all of my Flex only WebServices and a new Application.cfc that only contained one line (that aliased my datasource name to Request.dsn). This prevented my CFC from calling my main Application.cfc (and all the security stuff inside of it) and allowed my Flex application to use the CFC without any problems.

            Don't know if this helps or not but it worked for me!

            Here is the code I am using to connect to my CFC and two of its methods using the reomte object call...

            <mx:RemoteObject id="getAllSecStuff" destination="ColdFusion" source="ISIF.WebServices.SecRoles">
            <mx:method name="getSecRoles" result="getSecRolesHandler(event)"/>
            <mx:method name="getCFTemplates" result="getCFTemplatesHandler(event)"/>
            </mx:RemoteObject>


            Have an Ordinary Day...
            KomputerMan ~|:-)
            • 3. Re: CFC Pathing with RemoteObject
              Jighead2 Level 1
              Okay, i believe I'm getting to the source of the problem by doing some more digging.

              I am not using the cf standalone server on my local box I'm using IIS
              so my root is c:\web http://localhost:80/
              and not
              c:\cfusionmx7\wwwroot\ http://localhost:8500/

              Do i need to copy the /WEB-INF/service-congif.xml directory/file under my root?
              Are there any other files I need to copy to my root?

              Thanks
              • 4. Re: CFC Pathing with RemoteObject
                Jighead2 Level 1
                Komputer Man,

                Thanks although that isn't the issue in my case I dont think, it is definately information that I"ll but in my bank for latter. I'm sure I'll probably run into the same situation sooner later.
                Thanks for your help ;)

                Jighead
                • 5. Re: CFC Pathing with RemoteObject
                  peterent Level 2
                  RemoteObject wants to talk directly to the Flash Remoting gateway in ColdFusion - not through your web server. So from your CF installation, what is the path to the CFC beginning with CF's webroot? Put that, as dots and not slashes, as the source. Your ColdFusion destination in the services-config.xml file points to CF, not the web server.

                  The services-config.xml file belongs with CF under its wwwroot/WEB-INF/flex - do not move it. You do need a copy on your machine to compile your Flex app (unless you have the server's disk mounted on your machine).
                  • 6. CFC Pathing with RemoteObject
                    Jighead2 Level 1
                    Peter,

                    Okay so by default my cfc's must reside under c:\cfusionmx7\wwwroot\. I've noticed that in a few of the starter examples
                    ("Moving data from ColdFusion CFCs to Flex 2 applications" for one) the source files to run the examples are placed under the cf root. However as you know this is really not a real world example. My sites live under c:\web\ and my complied files will need to be deployed there. So what is the correct way to set up the Flex projects pathing to make this happen. Heres a hypothetical example.

                    My working flex directory is the default by install ....
                    C:\Documnets and settings\user\My Documents\Flex Builder 2
                    My webserver webroot is ...
                    C:\web and I want my compiled files and CFC's to live in this directory.....
                    C:\web\flexttest\

                    What do i need to do to configure Flex to setup the proper pathing. Can you show real world examples of how to setup this scenario? This is what most of us using IIS do. We dont set up under c:\fusionMX7\wwwroot it's usually c:\inetpub\wwwroot.

                    Can you post example of all the pathing variables you would setup to accomplish this. I'm sure it would not just benefit a flex noob like me but many others flex noobs as well.

                    Thanks








                    Jighead
                    • 7. CFC Pathing with RemoteObject
                      Iceborer Level 1
                      So, I have the following setup on my box:
                      CF is located in c:\CFusionMX7
                      My webroot is c:\inetpub\wwwroot

                      I have the following (full) directory path to my cfc:
                      c:\inetpub\wwwroot\myWeb\common\components\assets\formFacade.cfc

                      Here is my RemoteObject definition:

                      <mx:RemoteObject id="smService" destination="ColdFusion" source="myWeb.common.components.assets.formFacade"
                      fault="Alert.show (event.fault.faultDetail, 'Remote Error');">
                      <mx:method name="getEngineers" result="setProductionEngineers (event);" />
                      <mx:method name="getInspectors" result="setInspectors (event);" />
                      <mx:method name="getProblemLocations" result="setProblemLocations (event);" />
                      <mx:method name="getFaults" result="setFaults (event);" />
                      <mx:method name="getDiscrepancy" result="formRetrieved (event);" />
                      <mx:method name="persistDiscrepancy" result="formSaved (event);" />
                      </mx:RemoteObject>

                      I hope that helps a little bit.

                      Adam
                      • 8. Re: CFC Pathing with RemoteObject
                        peterent Level 2
                        Your remote object looks good. Now what about the services-config.xml file? There should be one in

                        c:\inetpub\wwwroot\WEB-INF\flex

                        Look at the the destination for ColdFusion. Perhaps it looks like this:
                        <destination id="ColdFusion">
                        <channels>
                        <channel ref="my-cfamf"/>
                        </channels>

                        Then look below for the <channels> and the definition of my-cfamf. It might look like this:
                        <channel-definition id="my-cfamf" class="mx.messaging.channels.AMFChannel">
                        <endpoint uri=" http://{server.name}:{server.port}{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
                        <properties>

                        Check the end-point. If it is like above, you'll need to change it. The best thing to do is copy the services-config.xml to a directory on your machine so you can make the changes. Then change the Flex Builder 2 compiler option to read the new location.

                        Change the {server.name} to the machine running CF, change the port to its port number (if you are using a web server, try using port 80) and the context.root is most likely just slash.

                        Maybe:
                        <endpoint uri=" http://localhost:80/flex2gateway/"

                        If you enter that URL into a browser you should get a blank page not a 404 or 500 or any error. If you get an error, change the port number to the one CF is listening to (eg, 8500).
                        • 9. Re: CFC Pathing with RemoteObject
                          peterent Level 2
                          Jighead, check my response to Iceborer's post and see if that helps.
                          • 10. Re: CFC Pathing with RemoteObject
                            Iceborer Level 1
                            *This is the guy who is trying to help out and who's Flex is working fine* :)

                            Just for info, my services-config.xml file is in my CFroot (C:\CFusionMX7\wwwroot\WEB-INF\flex), not in my webroot (C:\inetpub\wwwroot\WEB-INF\flex).
                            • 11. Re: CFC Pathing with RemoteObject
                              Jighead2 Level 1
                              Adam,

                              I've been doing what you are doing in your example all along. However flex does not want to play nicely when i do this. I get the typical compnent not found error even when I use the full path to the CFC. That's why I started this topic.

                              Peter,
                              I will try your sugesstion and also may try setting mappings to "true" in the config file and use cfadmin to set up a CFC mapping.

                              Thanks guys.
                              • 12. Re: CFC Pathing with RemoteObject
                                peterent Level 2
                                When you get this working would you mind dropping me a note, explaining your environment and the solution? I will make sure that it gets to our documentation staff.

                                We are very concerned about making Flex easier to use.
                                • 13. Re: CFC Pathing with RemoteObject
                                  Jighead2 Level 1
                                  Peter,

                                  Will do. It may be a while. I will try things as I have time.
                                  • 14. CFC Pathing with RemoteObject
                                    Jighead2 Level 1
                                    Peter,

                                    The 2 things you posted above need to be set to get this working for a typical webserver install.

                                    1.) Open the servics-config.xml file in C:\CFusionMX7\wwwroot\WEB-INF\flex\
                                    and find and edit the value for

                                    <endpoint uri=" http://{server.name}:{server.port}{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
                                    to
                                    <endpoint uri=" http://localhost/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
                                    Port number is optional, 80 is default as usual.

                                    2.) In FlexB right click your project folder and click properties > flex complier
                                    and paste in this line in the addtional args field.

                                    -services "C:\CFusionMX7\wwwroot\WEB-INF\flex\services-config.xml" -locale en_US.

                                    That's it!

                                    However I believe there are bugs in FB2 to watch for. When you change the properties and click apply. The flex build path likes to reset the output folder to
                                    c:\cfusionmx7\wwwroot\bin which then results in your page not loading and you get a 404 error in the browser. You will need to make sure you reset the path to your projects output folder again.

                                    These issues with remoting are the reasons why all the FLEX examples show you how do do it in the cfroot rather than in your webroot.

                                    Thanks for your help Peter. Cheers!
                                    • 15. Re: CFC Pathing with RemoteObject
                                      peterent Level 2
                                      Thank you for posting this. I wish this forum had a feature to mark an answer as something important so it could easily be found. In a couple of weeks, or less, someone else is going to ask this same question because this entry will have been pushed way down.

                                      I'll take your answer and post it on my blog (with proper credit, of course) and pass it along with Adobe. May be we can make our documentation better.