Flex 3 introduces some important new controls to Flex. Some of these, like the Advanced Data Grid, will be of real interest to us ColdFusion developers. But, if you run the project wizard in Flex Builder 3 Beta 3, and select ColdFusion as the server technology and check the option to use Flash Remoting, you may find that Flex 3 controls are not available to you. Why? Because when the wizard sets up the project, it may point to an older version of the SDK, the one that ColdFusion is aware of.
The solution? Either of these two options should work:
- Run the wizard, select ColdFusion as the server technology, but don't check the option to use remote object access service. Then, open the project properties dialog, go to the Flex Compiler page, and add compiler flag: -services "C:\ColdFusion8\wwwroot\WEB-INF\flex\services-config.xml" (obviously changing the path as appropriate). This flag is what gets set by the wizard when you opt to use Flash Remoting.
- Run the wizard as you usually do. Then, open the project properties dialog, go to the Flex Compiler page, and change the Flex SDK version to use the Flex 3 SDK. (Although, I think the prior option is the safer one).
Andrew, yep, it is in the flex folder under ColdFusion's WEB-INF folder.
--- Ben
I emailed you earlier about the Flex servies-onfig.xml file and how to configure it to use with CF. Here's my services-config.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<service-include file-path="remoting-config.xml" />
<service-include file-path="proxy-config.xml" />
<service-include file-path="messaging-config.xml" />
<service-include file-path="data-management-config.xml" />
</services>
<security>
<login-command class="flex.messaging.security.JRunLoginCommand" server="JRun"/>
<!-- Uncomment the correct app server
<login-command class="flex.messaging.security.TomcatLoginCommand" server="Tomcat"/>
<login-command class="flex.messaging.security.WeblogicLoginCommand" server="Weblogic"/>
<login-command class="flex.messaging.security.WebSphereLoginCommand" server="WebSphere"/>
-->
<!--
<security-constraint id="basic-read-access">
<auth-method>Basic</auth-method>
<roles>
<role>guests</role>
<role>accountants</role>
<role>employees</role>
<role>managers</role>
</roles>
</security-constraint>
-->
</security>
<destination id="ColdFusion">
<channels>
<channel ref="my-cfamf" />
</channels>
<properties>
<source>*</source>
<access>
<use-mappings>false</use-mappings>
<method-access-level>remote</method-access-level>
</access>
<property-case>
<force-cfc-lowercase>false</force-cfc-lowercase>
<force-query-lowercase>false</force-query-lowercase>
<force-struct-lowercase>false</force-struct-lowercase>
</property-case>
</properties>
</destination>
<channels>
<!-- 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>
</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>
<serialization>
<instantiate-types>false</instantiate-types>
</serialization>
</properties>
</channel-definition>
<!-- ColdFusion specific RTMP channel -->
<!--
<channel-definition id="cf-rtmp" class="mx.messaging.channels.RTMPChannel">
<endpoint uri="rtmp://{server.name}:2048" class="flex.messaging.endpoints.RTMPEndpoint"/>
<properties>
<idle-timeout-minutes>20</idle-timeout-minutes>
<serialization>
<instantiate-types>false</instantiate-types>
</serialization>
</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>
<channel-definition id="java-rtmp" class="mx.messaging.channels.RTMPChannel">
<endpoint uri="rtmp://{server.name}:2036" class="flex.messaging.endpoints.RTMPEndpoint"/>
<properties>
<idle-timeout-minutes>20</idle-timeout-minutes>
</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>[Flex] </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>
<!--
<redeploy>
<enabled>true</enabled>
<watch-interval>20</watch-interval>
<watch-file>{context.root}/WEB-INF/flex/services-config.xml</watch-file>
<watch-file>{context.root}/WEB-INF/flex/proxy-config.xml</watch-file>
<watch-file>{context.root}/WEB-INF/flex/remoting-config.xml</watch-file>
<watch-file>{context.root}/WEB-INF/flex/messaging-config.xml</watch-file>
<watch-file>{context.root}/WEB-INF/flex/data-management-config.xml</watch-file>
<touch-file>{context.root}/WEB-INF/web.xml</touch-file>
</redeploy>
-->
</system>
</services-config>
When I try to use this, I get the following error in Flex Builder:
Unexpected child element 'destination' found in 'services-config' from file: services-config.xml.
Have you ever seen this before?
{server.name}:{server.port}{context.root}
to the exact path. Or try leaving off {context.root} if needed.
Earlier this morning I changed the {server.name}:{port}{contextroot} to the exact path for my CF server and now I can access my data.
{server.name}:{server.port}{context.root}
to the exact path isn't really a good solution. What if you're deploying to multiple servers? Does anyone know where these variables come from?
My Flex services-config.xml file looks like the one Andrew posted earlier in the post. Under the "Flex Server" preference, I have the following two entries (that validate properly):
Root folder: C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\cfdocs
Root URL: http://localhost/cfdocs
The start of the <mx:RemoteObject> is:
<mx:RemoteObject id="myRemoteObject" destination="ColdFusion" source="RealStore.src.remoteService" showBusyCursor="true">
I have stored the remoteService.cfc file in the C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\cfdocs\RealStore\src folder.
I get an error that says "Ensure that the name is correct and the component or interface exists."
I tried changing the path of the endpoint URI in the services-config.xml file from http://{server.name}:{server.port}{context.root}/flex2gateway/ to http://localhost/cfdocs." target="_blank">http://localhost/cfdocs. That did not help.
The error message wording leads me to believe that the correct faulthandler method is being invoked.
I am clearly missing something simple. Any thoughts/pointers?
Thanks in advance,
Aneesh Shrikhande
(860) 713-1603
Any suggestions on how to 'map' to that file's path?
I am trying to save a image to my coldfusion server of a chart that is displaying in my flex application.
1. coldfusion is installed using JRUN
2. IIS
3. my component is installed wwwroot/com/
4. services-config.xml are the same as the one displayed
When i run the flex application and click on the export button i always get a error.
Error:
headers = (Object)#2
messageId = "A408C832-AB35-9F2F-8942-2135EB342B38"
rootCause = (mx.messaging.events::ChannelFaultEvent)#3
bubbles = false
cancelable = false
channel = (mx.messaging.channels::AMFChannel)#4
authenticated = false
channelSets = (Array)#5
[0] (mx.messaging::ChannelSet)#6
authenticated = false
channelIds = (Array)#7
[0] (null)
channels = (Array)#8
[0] (mx.messaging.channels::AMFChannel)#4
clustered = false
connected = false
currentChannel = (mx.messaging.channels::AMFChannel)#4
initialDestinationId = (null)
messageAgents = (Array)#9
[0] (mx.rpc::AsyncRequest)#10
authenticated = false
autoConnect = true
channelSet = (mx.messaging::ChannelSet)#6
clientId = (null)
connected = false
defaultHeaders = (null)
destination = "ColdFusion"
id = "670D230D-F8DC-D7FA-3B5E-21358B531BA7"
reconnectAttempts = 0
reconnectInterval = 0
requestTimeout = -1
subtopic = ""
connected = false
connectTimeout = -1
enableSmallMessages = true
endpoint = "http://localhost:8300/flex2gateway/"
failoverURIs = (Array)#11
id = (null)
mpiEnabled = false
netConnection = (flash.net::NetConnection)#12
client = (mx.messaging.channels::AMFChannel)#4
connected = false
objectEncoding = 3
proxyType = "none"
uri = "http://localhost:8300/flex2gateway/"
piggybackingEnabled = false
polling = false
pollingEnabled = true
pollingInterval = 3000
protocol = "http"
reconnecting = false
recordMessageSizes = false
recordMessageTimes = false
requestTimeout = -1
uri = "/flex2gateway/"
url = "/flex2gateway/"
useSmallMessages = false
channelId = (null)
connected = false
currentTarget = (mx.messaging.channels::AMFChannel)#4
eventPhase = 2
faultCode = "Channel.Connect.Failed"
faultDetail = "NetConnection.Call.Failed: HTTP: Failed: url: 'http://localhost:8300/flex2gateway/'"
faultString = "error"
reconnecting = false
rejected = false
rootCause = (Object)#13
code = "NetConnection.Call.Failed"
This is the code i am using:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
creationComplete="prcXMLFeed.send()" backgroundGradientAlphas="[1.0, 1.0]"
backgroundGradientColors="[#FFFFFF, #F6F7FF]" width="920" height="620">
<mx:Style>
.topSeries {
fontSize:9;
fontWeight:bold;
labelPosition:inside;
labelAlign:top;
}
.middleSeries {
fontSize:9;
fontWeight:bold;
labelPosition:inside;
labelAlign:middle;
}
</mx:Style>
<mx:Script>
<![CDATA[
import mx.graphics.ImageSnapshot;
import mx.graphics.codec.JPEGEncoder;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
[Bindable]
private var buttonsEnabled:Boolean = true;
private const jpgEnc:JPEGEncoder = new JPEGEncoder(75);
private function takeSnapshot(source:IBitmapDrawable):ByteArray {
var imageSnap:ImageSnapshot = ImageSnapshot.captureImage(source,150,jpgEnc);
var imageByteArray:ByteArray = imageSnap.data as ByteArray;
return imageByteArray;
}
private function exportImageToJPG():void{
buttonsEnabled = false;
var data:ByteArray = takeSnapshot(graphicChart);
ro.saveAsImage(data);
}
private function onResult(message:String):void
{
Alert.show(message);
buttonsEnabled = true;
}
private function onFault(event:FaultEvent):void
{
Alert.show("Server Fault: " + event.message);
buttonsEnabled = true;
}
]]>
</mx:Script>
<mx:RemoteObject id="ro" showBusyCursor="true" endpoint="/flex2gateway/"
destination="ColdFusion" source="com.ScreenExports">
<mx:method name="saveAsImage" result="onResult('Charts saved as JPG.')" fault="onFault(event)" />
</mx:RemoteObject>
<mx:HTTPService id="prcXMLFeed" method="POST" resultFormat="e4x" url="http://localhost/xml/prcXml01.cfm">
<mx:request xmlns="">
<todaysDate>{todaysdate.text}</todaysDate>
<wmy>{wmy.selectedItem.data}</wmy>
</mx:request>
</mx:HTTPService>
<mx:Form>
<mx:HBox>
<mx:FormItem label="Date:">
<mx:DateField id="todaysdate"/>
</mx:FormItem>
<mx:FormItem label="View:">
<mx:ComboBox id="wmy">
<mx:ArrayCollection>
<mx:Object label="Week" data="1" />
<mx:Object label="Month" data="2" />
<mx:Object label="Year" data="3" />
</mx:ArrayCollection>
</mx:ComboBox>
</mx:FormItem>
<mx:Button label="Update" id="btnSubmit" click="prcXMLFeed.send()"/>
<mx:Button label="Export Image" click="exportImageToJPG()" enabled="{buttonsEnabled}"/>
</mx:HBox>
</mx:Form>
<mx:SeriesSlide id="slideIn" duration="1000" direction="up"/>
<mx:SeriesSlide id="slideOut" duration="1000" direction="down"/>
<mx:Canvas x="0" y="62" width="920" height="558" id="graphicChart">
<mx:ColumnChart dataProvider="{prcXMLFeed.lastResult.result}"
x="10" y="46" id="tktWeekly"
width="880" height="453" showDataTips="true" type="stacked">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="ddate"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries styleName="middleSeries" showDataEffect="{slideIn}" hideDataEffect="{slideOut}" displayName="New Site Build Tickets Closed" yField="nsbc"/>
<mx:ColumnSeries styleName="middleSeries" showDataEffect="{slideIn}" hideDataEffect="{slideOut}" displayName="Update Request Tickets Closed" yField="urtc"/>
<mx:ColumnSeries styleName="middleSeries" showDataEffect="{slideIn}" hideDataEffect="{slideOut}" displayName="Need More Info Tickets" yField="nmit"/>
<mx:ColumnSeries styleName="middleSeries" showDataEffect="{slideIn}" hideDataEffect="{slideOut}" displayName="Delayed Tickets" yField="dts"/>
<mx:ColumnSeries styleName="middleSeries" showDataEffect="{slideIn}" hideDataEffect="{slideOut}" displayName="Pending Approval Tickets" yField="pat"/>
</mx:series>
</mx:ColumnChart>
<mx:Legend direction="horizontal" dataProvider="{tktWeekly}" x="5" y="510"/>
<mx:Label x="10" y="10" text="Daily Numbers 3" fontSize="18"/>
</mx:Canvas>
</mx:Application>