rss
twitter
    Twitter feed not available

Flex Builder 2/Mystic and Multiple URLs on one server

As I discussed here, getting Fex Builder 2 to 'talk' with a CF server on a differnet machine required a tweak to the {CF Root\WEB-INF\flex\flex-enterprise-services.xml file.

I have several sites running on my development and production servers.  Obviously, I am not goign to want to put the CFCs for one site into another just so I can use Flex.  There has to be a way to tell Flex which site, or URL rather, to use.  I think I figured out how.



WARNING: This is what I did to get Felx Builder 2 to 'talk' through differnt URLs.  Follow these instructions at your own risk.  I am not, nor do I claim to be, a Flex expert, I do not, nor have I ever, played one on TV, and I did NOT stay at a Holiday Inn Express last night.  That being said, have at it.

1. Stop the CF instance you want to configure.
2. Open {CF Root}\WEB-INF\flex\flex-enterprise-services.xml.
3. Look for a block of code that looks like this:

<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>false</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><span class="tags">

4. The chunk of code we are most concernered with is:
<channels>
 <channel ref="my-cfamf"/>
</channels>

5. Add a new <channel>, give it any ref you desire.
6. Now look for a block of code that looks like this:
<channel-definition id="my-cfamf" class="mx.messaging.channels.AMFChannel">
 <endpoint uri="http://localhost:8500{context.root}/flex2gateway/" class="flex.messaging.endpoints.AMFEndpoint"/>
 <properties>
  <polling-enabled>false</polling-enabled>
  <serialization>
   <custom-deserializer type="typed-object" class="coldfusion.flash.messaging.io.amf.serializers.TypedObjectDeserializer" />
  </serialization>
 </properties>
</channel-definition>
(The URL and port number may be differnt if you have modified this file before)
7. Copy this block of code and paste it directly underneath itself.
8. In the new block of code, change the id of the <channel-definition> to match the new channel you created in step 5.
9. Update the URL to point to the new domain and appropriate port number.
10. Save the file.
11. Restart CF
12. Make sure Flex Builder 2 is pointing to this file for compiling.
13. Recompile your Flex app.
14. Test.

Hopefully someone from Adobe will see this and point out anything that can be done easier or is flat out wrong.  Either way, this helped me get this working.

9 comments

(Comment Moderation is enabled. Your comment will not appear until approved.)
Simeon said...
Hey Scott,

Nice work sorting this out. The only thing I would also like to point out is that in addition to changing this file and adding additional channels you can also copy this file local to your Flex Builder project and use the local file in your compiler directive. That way if you have several projects that connect to different servers or ports you can work with their settings locally. Or if you find you need to change settings you only affect those changes locally so you dont run into conflicts in the cfserver version of the file.
Scott Stroz said...
Sim - Good point, I am goign to have to give that a try.
Scott Stroz said...
I just tried this and it worked like a dream. I think this will be my preferred method of development, at least if nothing changes in the final release.
Jorge Tejada said...
Hi, maybe this helps somebody, I had CF MX 7.01. installed with JDK 1.4.2_04 and run the 7.0.2 Updater over it. Then everything worked OK, but Remoting didn't work from Flex Builder 2. I was really annoyed about it, because I had to fix my CF reports too. Is interesting to point that I was receiving:

Error: faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 405

from the CF, when I called a CFC

Then I saw an error in cfusion-err.log, it said that I had to install JDK 1.4.2_06 or above, well, I installed JDK 1.5 and change java.home in jvm.config to it, but it didn't work either. Then I installed JDK 1.4.2_12. And Remote Objects from ColdFusion started to work like a charm.
Bruce said...
I'm posting a solution I had to a problem getting Flex 2.0 and Coldfusion to work together.

I updated CF to CF 7.0.2. However, I could not get Flex 2.0 and CF to work together. I received netconnection failed messages whenever a Flex app tried to call a CFC function. The same app worked fine on my other development machine.

After reading the above post, I checked the CF java settings on the machine with the problem. The Java VM Version was 1.4.2_05.

I downloaded and installed JDK 1.4.2_10 and then changed the Java and JVM setting in the coldfusion admin to point to c:\j2sdk1.4.2_10\jre for the Java Virtual Machine path.

I then restarted my computer and checked the settings in CF admin for the Java VM Version and it was now 1.4.2_10-b03.

I re compiled my Flex app and ran it and it worked fine.

So it appears for the Flex2Gateway to work correctly in CF the Java VM (virtual machine) must be higher then 1.4.2_05.

Bruce
boatloan said...
After reading the above post, I checked the CF java settings on the machine with the problem. The Java VM Version was 1.4.2_05.

I downloaded and installed JDK 1.4.2_10 and then changed the Java and JVM setting in the coldfusion admin to point to c:\j2sdk1.4.2_10\jre for the Java Virtual Machine path.

I then restarted my computer and checked the settings in CF admin for the Java VM Version and it was now 1.4.2_10-b03.

I re compiled my Flex app and ran it and it worked fine.
santshos said...
I too not so for a long time was set by the given question. Searched in the Internet and corresponding literature. And recently on this theme there was an active discussion in my guest book: http://www.freewebs.com/cars-auto/guestbook.htm . Many interesting opinions and reasons have been stated. There were even references on corresponding the Internet-resources. The theme till now remains actual and discussed, therefore at desire can leave the opinion.
Garment Manufacturer said...
Good point, I am goign to have to give that a try.
chris ellem said...
faultCode:Client.Error.MessageSend faultString:'Send failed' faultDetail:'Channel.Connect.Failed error NetConnection.Call.Failed: HTTP: Status 405: url: 'http://mphr401:80/flex2gateway/''

doh...doesnt work if the cf server is 6.1

I am not even going to say who the client is but they just posted an annual profit of 1 billion. I think they could afford to update their cf servers...