0

When I try to call this simple function in a CFC, with the proper remote setting, I get an error that says

"Destination 'ColdFusion' either does not exist or the destination has no channels defined and the application does not define any default channels."

This is the CFC, although I am 99% certain the problem does not exist with it, very simple.

<cfcomponent output="false">

    <!--- Get Server Time --->
    <cffunction name="getServerTime" access="remote" returnType="string">
       <cfreturn now() />
    </cffunction>

    <cffunction name="getString" access="remote" returnType="string">
        <cfreturn "hello......" />
    </cffunction>

</cfcomponent>

This is the main.mxml file which includes the remote call

<?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" viewSourceURL="srcview/index.html" applicationComplete="init()">

<mx:Script>
    <![CDATA[
        import mx.rpc.events.ResultEvent;
        import mx.controls.Alert;

        public function init():void{
          Alert.show(conn.getString());
        }

        public function eventResultHandler(event:ResultEvent):void{
            lblStringResult.text = event.result as String;                 
        }

    ]]>
</mx:Script>

<mx:RemoteObject id="conn" destination="ColdFusion" source="DemoCFC"
    result="eventResultHandler(event)" showBusyCursor="true" >
</mx:RemoteObject>


<mx:Label id="lblStringResult" y="10" horizontalCenter="0"/> 

<mx:Button label="Server Time?.." click="conn.getServerTime();" y="36" horizontalCenter="0" />

</mx:Application>

This is the services-services.xml file in the root of WEB-INF\flex folder. I apologize for this long and tedious file, but I think the problem could be in it.

<services>
    <service-include file-path="remoting-config.xml" />
    <service-include file-path="proxy-config.xml" />
    <service-include file-path="messaging-config.xml" />
</services>

<security>
    <login-command class="flex.messaging.security.JRunLoginCommand" server="JRun"/>

</security>

<channels>

    <!--  CF Based Endpoints -->
    <!-- {server.name}:{server.port}{context.root} -->
    <channel-definition id="my-cfamf" class="mx.messaging.channels.AMFChannel">
        <endpoint uri="http://{server.name}:{server.port}{context.root}/flex2gateway/" class="coldfusion.flash.messaging.CFAMFEndPoint"/>
        <properties>
            <polling-enabled>false</polling-enabled>
            <serialization>
                <enable-small-messages>false</enable-small-messages>
            </serialization>
            <coldfusion>
                <!-- define the resolution rules and access level of the cfc being invoked -->
                <access>
                    <!-- Use the ColdFusion mappings to find CFCs-->
                    <use-mappings>true</use-mappings>
                    <!-- allow "public and remote" or just "remote" methods to be invoked -->
                    <method-access-level>remote</method-access-level>
                </access>

                <use-accessors>true</use-accessors>

                <use-structs>false</use-structs>

                <serialize-array-to-arraycollection>false
                </serialize-array-to-arraycollection>

                <proxy-load-method>loadProxy</proxy-load-method>

                <property-case>
                    <!-- cfc property names -->
                    <force-cfc-lowercase>false</force-cfc-lowercase>
                    <!-- Query column names -->
                    <force-query-lowercase>false</force-query-lowercase>
                    <!-- struct keys -->
                    <force-struct-lowercase>false</force-struct-lowercase>
                </property-case>
            </coldfusion>
        </properties>
    </channel-definition>

    <channel-definition id="cf-polling-amf" class="mx.messaging.channels.AMFChannel">
        <endpoint uri="http://{server.name}:{server.port}{context.root}/flex2gateway/cfamfpolling" class="coldfusion.flash.messaging.CFAMFEndPoint"/>
        <properties>
            <polling-enabled>true</polling-enabled>
            <polling-interval-seconds>8</polling-interval-seconds>
            <serialization>
                <enable-small-messages>false</enable-small-messages>
            </serialization>
            <coldfusion>
                <!-- define the resolution rules and access level of the cfc being invoked -->
                <access>
                    <!-- Use the ColdFusion mappings to find CFCs-->
                    <use-mappings>true</use-mappings>
                    <!-- allow "public and remote" or just "remote" methods to be invoked -->
                    <method-access-level>remote</method-access-level>
                </access>

                <use-accessors>true</use-accessors>

                <use-structs>false</use-structs>

                <serialize-array-to-arraycollection>false
                </serialize-array-to-arraycollection>

                <proxy-load-method>loadProxy</proxy-load-method>

                <property-case>
                    <!-- cfc property names -->
                    <force-cfc-lowercase>false</force-cfc-lowercase>
                    <!-- Query column names -->
                    <force-query-lowercase>false</force-query-lowercase>
                    <!-- struct keys -->
                    <force-struct-lowercase>false</force-struct-lowercase>
                </property-case>
            </coldfusion>
        </properties>
    </channel-definition>

    <channel-definition id="my-cfamf-secure" class="mx.messaging.channels.SecureAMFChannel">
        <endpoint uri="https://{server.name}:{server.port}{context.root}/flex2gateway/cfamfsecure" class="coldfusion.flash.messaging.SecureCFAMFEndPoint"/>
        <properties>
            <polling-enabled>false</polling-enabled>
            <add-no-cache-headers>false</add-no-cache-headers>
            <serialization>
                <enable-small-messages>false</enable-small-messages>
            </serialization>
            <coldfusion>
                <!-- define the resolution rules and access level of the cfc being invoked -->
                <access>
                    <!-- Use the ColdFusion mappings to find CFCs-->
                    <use-mappings>true</use-mappings>
                    <!-- allow "public and remote" or just "remote" methods to be invoked -->
                    <method-access-level>remote</method-access-level>
                </access>

                <use-accessors>true</use-accessors>
                <use-structs>false</use-structs>

                <serialize-array-to-arraycollection>false
                </serialize-array-to-arraycollection>

                <proxy-load-method>loadProxy</proxy-load-method>

                <property-case>
                    <!-- cfc property names -->
                    <force-cfc-lowercase>false</force-cfc-lowercase>
                    <!-- Query column names -->
                    <force-query-lowercase>false</force-query-lowercase>
                    <!-- struct keys -->
                    <force-struct-lowercase>false</force-struct-lowercase>
                </property-case>
            </coldfusion>
        </properties>
    </channel-definition>

    <!--  Java Based Endpoints -->
    <channel-definition id="java-amf" class="mx.messaging.channels.AMFChannel">
        <endpoint uri="http://{server.name}:{server.port}{context.root}/flex2gateway/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
    </channel-definition>

    <channel-definition id="java-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
        <endpoint uri="https://{server.name}:{server.port}{context.root}/flex2gateway/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
    </channel-definition>

    <channel-definition id="java-polling-amf" class="mx.messaging.channels.AMFChannel">
        <endpoint uri="http://{server.name}:{server.port}{context.root}/flex2gateway/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
        <properties>
            <polling-enabled>true</polling-enabled>
            <polling-interval-seconds>8</polling-interval-seconds>
        </properties>
    </channel-definition>

</channels>

<logging>
    <target class="flex.messaging.log.ConsoleTarget" level="Error">
        <properties>
            <prefix>[BlazeDS] </prefix>
            <includeDate>false</includeDate>
            <includeTime>false</includeTime>
            <includeLevel>false</includeLevel>
            <includeCategory>false</includeCategory>
        </properties>
        <filters>
            <pattern>Endpoint.*</pattern>
            <pattern>Service.*</pattern>
            <pattern>Configuration</pattern>
            <pattern>Message.*</pattern>
        </filters>
    </target>
</logging>

<system>
    <manageable>false</manageable>
</system>

This is the remoting-config.xml file.

<?xml version="1.0" encoding="UTF-8"?>

<adapters>
    <adapter-definition id="cf-object" class="coldfusion.flash.messaging.ColdFusionAdapter" default="true"/>
    <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter"/>
</adapters>

<default-channels>
    <channel ref="my-cfamf"/>
</default-channels>

<destination id="ColdFusion">
    <channels>
        <channel ref="my-cfamf"/>
    </channels>
    <properties>
        <source>*</source>
    </properties>
</destination>

When the main.mxml file compiles and runs, the call to the init() method, which is using the remote object connection to call the getString() method, returns and displays

"[object AsyncToken]" in the Alert box.

If I click on the button, I'm calling the method getServerTime() and trying to display the server time in the mxml label, but only get the

If I browse to , I get a white page. That is supposedly is a good thing according to some threads I came across, trying to resolve this problem.

The main.mxml file and the cfc are in the same folder in the project. So I know the Remote call is finding the cfc.

I am pretty sure the problem is in the configuration of ColdFusion, since this is such a simple request.

Leigh
  • 28,765
  • 10
  • 55
  • 103
jamesTheProgrammer
  • 1,747
  • 4
  • 22
  • 34

1 Answers1

0

The XML file you have above is the services-config.xml but you set your destination in the remoting-config.xml file ... see below:

<service id="remoting-service" class="flex.messaging.services.RemotingService">
<adapters>
    <adapter-definition id="cf-object" class="railo.runtime.net.flex.RailoAdapter" default="true"/>
    <adapter-definition id="java-object" class="flex.messaging.services.remoting.adapters.JavaAdapter"/>
</adapters> 
<default-channels>
    <channel ref="my-cfamf"/>
    <channel ref="classic-cfamf"/>
</default-channels>

<destination id="ColdFusion">
    <channels>
        <channel ref="my-cfamf"/>
    </channels>
    <properties>
        <source>*</source>
        <!-- define the resolution rules and access level of the cfc being invoked -->
        <access>
            <!-- Use the ColdFusion mappings to find CFCs, by default only CFC files under your webroot can be found. -->
            <use-mappings>true</use-mappings>
            <!-- allow "public and remote" or just "remote" methods to be invoked -->
            <method-access-level>remote</method-access-level>
        </access>
        <property-case>
            <!-- cfc property names -->
            <force-cfc-lowercase>false</force-cfc-lowercase>
            <!-- Query column names -->
            <force-query-lowercase>false</force-query-lowercase>
            <!-- struct keys -->
            <force-struct-lowercase>false</force-struct-lowercase>
        </property-case>
    </properties>
</destination>
</service>

Check through this file in your WEB-INF/flex folder and ensure that you have a ColdFusion destination set and that it sets the appropriate channel to be used from your services-config.xml file that you have above.

And sorry for the long response, but thought I'd post my service-config.xml file so you can see how they work together:

<services-config>

<services>
    <service-include file-path="remoting-config.xml" />
    <service-include file-path="proxy-config.xml" />
    <service-include file-path="messaging-config.xml" />        
</services>

<security>
    <login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/>
</security>

<channels>

    <!-- CF -->
    <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>
            <polling-enabled>false</polling-enabled>
            <serialization>
                <instantiate-types>false</instantiate-types>
            </serialization>
        </properties>
    </channel-definition>

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

    <channel-definition id="cf-polling-amf" class="mx.messaging.channels.AMFChannel">
        <endpoint uri="http://{server.name}:{server.port}{context.root}/flex2gateway/cfamfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
        <properties>
            <polling-enabled>true</polling-enabled>
            <polling-interval-seconds>8</polling-interval-seconds>
            <serialization>
                <instantiate-types>false</instantiate-types>
            </serialization>
        </properties>
    </channel-definition>

    <channel-definition id="my-cfamf-secure" class="mx.messaging.channels.SecureAMFChannel">
        <endpoint uri="https://{server.name}:{server.port}{context.root}/flex2gateway/cfamfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
        <properties>
            <polling-enabled>false</polling-enabled>
            <add-no-cache-headers>false</add-no-cache-headers>
            <serialization>
                <instantiate-types>false</instantiate-types>
            </serialization>
        </properties>
    </channel-definition>

    <!-- Java -->
    <channel-definition id="my-amf" class="mx.messaging.channels.AMFChannel">
        <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amf" class="flex.messaging.endpoints.AMFEndpoint"/>
    </channel-definition>

    <channel-definition id="my-secure-amf" class="mx.messaging.channels.SecureAMFChannel">
        <endpoint url="https://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
        <properties>
            <add-no-cache-headers>false</add-no-cache-headers>
        </properties>
    </channel-definition>

    <channel-definition id="my-polling-amf" class="mx.messaging.channels.AMFChannel">
        <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfpolling" class="flex.messaging.endpoints.AMFEndpoint"/>
        <properties>
            <polling-enabled>true</polling-enabled>
            <polling-interval-seconds>4</polling-interval-seconds>
        </properties>
    </channel-definition>

    <channel-definition id="my-streaming-amf" class="mx.messaging.channels.StreamingAMFChannel">
      <endpoint url="http://{server.name}:{server.port}/{context.root}/messagebroker/amfsecure/streamingamf" class="flex.messaging.endpoints.StreamingAMFEndpoint" /> 
      <properties>
        <idle-timeout-minutes>0</idle-timeout-minutes> 
        <max-streaming-clients>100</max-streaming-clients> 
        <server-to-client-heartbeat-millis>5000</server-to-client-heartbeat-millis> 
        <user-agent-settings>
          <user-agent match-on="MSIE" kickstart-bytes="2048" max-streaming-connections-per-session="5" /> 
          <user-agent match-on="Firefox" kickstart-bytes="2048" max-streaming-connections-per-session="5" /> 
          <user-agent match-on="Safari" kickstart-bytes="2048" max-streaming-connections-per-session="5" />
          <user-agent match-on="Opera" kickstart-bytes="2048" max-streaming-connections-per-session="5" />  
        </user-agent-settings>
      </properties>
    </channel-definition>

    <channel-definition id="java-http" class="mx.messaging.channels.HTTPChannel">
        <endpoint uri="http://{server.name}:{server.port}{context.root}/flex2gateway/http" class="flex.messaging.endpoints.HTTPEndpoint"/>
    </channel-definition>

    <channel-definition id="java-secure-http" class="mx.messaging.channels.SecureHTTPChannel">
        <endpoint uri="https://{server.name}:{server.port}{context.root}/flex2gateway/httpsecure" class="flex.messaging.endpoints.SecureHTTPEndpoint"/>
    </channel-definition>
</channels>

<logging>
    <target class="flex.messaging.log.ConsoleTarget" level="Error">
        <properties>
            <prefix>[BlazeDS] </prefix>
            <includeDate>false</includeDate>
            <includeTime>false</includeTime>
            <includeLevel>false</includeLevel>
            <includeCategory>false</includeCategory>
        </properties>
        <filters>
            <pattern>Endpoint.*</pattern>
            <pattern>Service.*</pattern>
            <pattern>Configuration</pattern>
        </filters>
    </target>
</logging>

<system>
    <redeploy>
        <enabled>false</enabled>
    </redeploy>
</system>

</services-config>
craig.kaminsky
  • 5,588
  • 28
  • 31
  • craig - thanks for input, that was the services-config.xml file. Ive added my current remote-services.xml file. As you can see, there is a channel definition id in the services.config.xml file (channel-definition id="my-cfamf") and a matching channel id in the remote-config.xml file (). – jamesTheProgrammer Jun 26 '12 at 17:54
  • James - I'm an idiot (most of the time :). Can you navigate to: http://{server.name}:{server.port}{context.root}/flex2gateway/ (you should see a blank white page)? – craig.kaminsky Jun 26 '12 at 18:40
  • NP, I am an idiot sometimes too. I can navigate to localhost:8500/flex2gatway, and get a white screen, as I should. I'm not clear on what the {context.root} is. If that's the webroot, then I fail with a 404 error when browsing to localhost:8500/wwwroot/flex2gatway – jamesTheProgrammer Jun 26 '12 at 19:25
  • LOL! I hear you! If localhost:8500/etc gets you the white screen, then you are good there. One other thing to check: in Flex/Flash Builder, have you told the compiler where the services-config.xml file is? (i.e., -services /Some/path/to/wwwroot/WEB-INF/flex/services-config.xml). Additionally, make sure that DemoCFC is in the same folder as your Flex App or you'll need to change the RemoteObject tag in main.mxml to reflect the path to the CFC (my.path.to.cfcs.DemoCFC) ... and bear in mind it's case-sensitive in Flash! – craig.kaminsky Jun 26 '12 at 20:14
  • Craig, I finally discovered my problem was a value that I had placed in the project properties - flex server - context root. I had put the name of the project folder in at some point while I was trying to solve the problem. I ended up creating a small simpler project that I got to work, then compared its project properties with the one that was not connecting. Thanks for you efforts on my behalf. – jamesTheProgrammer Jun 27 '12 at 17:16