Flex RemoteObject remoting over SSL
Filed under Flex
This problem has caused me so much pain from hitting my head into a wall... After many-a-moons trying to figure this little problem out I have finally figured out the answer. The following blog posts provided so much useful information and should be looked at if you want further explanation:
CrankyBit - http://blog.crankybit.com/flex-remoting-over-ssl/
BarneyBlog - http://barneyb.com/barneyblog/2007/09/01/flex2-and-3-remoteobjects-over-ssl-with-coldfusion/
Ok, so I was given the task of creating a flex 3 dashboard on our external server that clients would access from outside our network. Not so fast cause calling ColdFusion .cfc's over SSL with the default setting does not work (Who the heck knows why?!?!). Here is the step by step of how to get this working.
Navigate and open the following files, remoting-config.xml and services-config.xml. They are normally located in the following default directory: "C:\ColdFusion8\wwwroot\WEB-INF\flex". With the remoting-config open you need to add a secure my-cfamf-secure channel. Make sure to add it to both the default channels and destination ColFusion and put it before the my-cfamf so that the secure channel will get called prior to the normal one.
| <?xml version="1.0" encoding="UTF-8"?> <service id="remoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage"> <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-secure"/> <channel ref="my-cfamf"/> </default-channels> <destination id="ColdFusion"> <channels> <channel ref="my-cfamf-secure"/> <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> </service> |
Once you have added those lines you can close the remoting-config.xml file and open the services-config.xml. In the services-config.xml you need to add the following lines (no-cache-headers) so that Internet Explorer will work:
| <!-- CF Based Endpoints --> <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> <add-no-cache-headers>false</add-no-cache-headers> </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> <serialization> <instantiate-types>false</instantiate-types> </serialization> <add-no-cache-headers>false</add-no-cache-headers> </properties> </channel-definition>
|
Both of those complete files can be downloaded right here (zipped): Download Files
IMPORTANT: If you download those files make sure to back up your current files just in case you want to roll back (I know this is common sense).
After downloading and extracting to C:\ColdFusion8\wwwroot\WEB-INF\flex, the next step is very important. If you are compiling your project on your local host you must restart your IIS. (Windows XP directions are below)
Start -» Settings -» Control Panel -» Administrative Tools -» Internet Information Services

IIS

Once the IIS is open you need to stop and start.
Hit STOP:

Hit Start:

Once the IIS is restarted it is time to compile your release build in flex. Before you hit release build it is important to clean the project to ensure everything is in proper order with the new changes made. This can be done in Flex Builder by selecting Project -» Clean.

After you are done cleaning the project export release build where ever you want. If you plan on exporting it locally and then moving it to your production server it is important that server has the same remoting-config.xml and services-config.xml files. Make sure that you restart the IIS on your server as well once you have uploaded them to the proper default location: "C:\ColdFusion8\wwwroot\WEB-INF\flex".
Ok so everything should be working correctly but if not make sure that you restarted IIS and cleaned your project. If it still does not work make sure that your project is pointing to the correct services-config.xml. This can be done in Flex Builder by hitting Proeject -» Properties -» Flex Compiler and then verifying that the additional compiler arguments is directed to the right path.


Ok, so now it is working!! Here is one last little thing that I found somewhere. To get rid of the annoying little Internet Explorer "Security Information" popup you need to open up the history.js file in your released flex project. It is located in the history folder of your release build. Once it is open in your text editor navigate to line 429 and you will notice adobe has commented out the line. If you uncomment the line(//iframe.src = historyFrameSourcePrefix;) the "Security Information" popup goes away! (And don't ask me how or why) ;) Search for the _initialize = function if it is not on line 429.

OK that is all I have.. Let me know if I have missed anything and for more information check out the blog posts I listed at the top. Hope this helps someone out there who has been banging their head on wall like me. ;)
| View count: 1845Jan14








