|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
sending xml from Flash MX to cold Fusion MX
I am trying to send xml data from flash mx to coldfusion mx, but I got following error message:
Document root element is missing. The Error Occurred in C:\CFusionMX\wwwroot\jiao\XML\flashBuiltXMLObject\digest.cfm: line 2 1 : 2 : <cfset xml = XmlParse( GetHttpRequestData().content )> 3 : 4 : Here is my flash actionscript: // Declare the necessary variables var studio = new XML(); var root = null; var product = null; // Create the root node (entity) // Add an attribute for additional thoroughness root = studio.createElement( "studio" ); root.attributes.edition = "Studio MX"; // Create a single node for each Studio MX product // Give it a value through an attribute // Append the new product node to the root node product = studio.createElement( "product" ); product.attributes.name = "Dreamweaver MX"; root.appendChild( product ); product = studio.createElement( "product" ); product.attributes.name = "Flash MX"; root.appendChild( product ); product = studio.createElement( "product" ); product.attributes.name = "Fireworks MX"; root.appendChild( product ); product = studio.createElement( "product" ); product.attributes.name = "FreeHand MX"; root.appendChild( product ); product = studio.createElement( "product" ); product.attributes.name = "ColdFusion MX"; root.appendChild( product ); // Append the XML data to an XML object studio.appendChild( root ); // Send the XML data to ColdFusion // The server is listening at port 8500 // A page called digest.cfm is on the server // We will create a new browser for the response studio.send( "http://localhost:8500/jiao/XML/flashBuiltXMLObject/digest.cfm", "_blank" ); Here is my coldfusion code: <cfset xml = XmlParse( GetHttpRequestData().content )> <cfdump var="#xml#"> Can someone tell me what might be wrong? T.I.A. |
|
#2
|
|||
|
|||
|
Dump the data and confirm that it is valid XML. The error you are seeing relates to CF not seeing the data as XML. Can you try something like this:
<cfdump var="#GetHttpRequestData().content#"> <cfabort> <cfset xml = XmlParse( GetHttpRequestData().content )> Because you're calling it from flash you may need to write the dump to a file in order to see it. Something like <cfsavecontent variable="flashdata"> <cfdump var="#GetHttpRequestData().content#"> </cfsavecontent> <cffile action="write" file="path to file" output="#flashdata#"> <cfabort> |
|
#3
|
|||
|
|||
|
First, thanks so much for the direction given.
Here is what get from the dumped file, any ideas? Why my xml file looks so strange?(See the bottom part) <style> table.cfdump_wddx, table.cfdump_xml, table.cfdump_struct, table.cfdump_array, table.cfdump_query, table.cfdump_cfc, table.cfdump_object, table.cfdump_binary, table.cfdump_udf, table.cfdump_udfbody, table.cfdump_udfarguments { font-size: xx-small; font-family: verdana, arial, helvetica, sans-serif; cell-spacing: 2; } table.cfdump_wddx th, table.cfdump_xml th, table.cfdump_struct th, table.cfdump_array th, table.cfdump_query th, table.cfdump_cfc th, table.cfdump_object th, table.cfdump_binary th, table.cfdump_udf th, table.cfdump_udfbody th, table.cfdump_udfarguments th { text-align: left; color: white; padding: 5; } table.cfdump_wddx td, table.cfdump_xml td, table.cfdump_struct td, table.cfdump_array td, table.cfdump_query td, table.cfdump_cfc td, table.cfdump_object td, table.cfdump_binary td, table.cfdump_udf td, table.cfdump_udfbody td, table.cfdump_udfarguments td { padding: 3; background-color: ffffff; vertical-align : top; } table.cfdump_wddx { background-color: 000000; } table.cfdump_wddx th.wddx { background-color: 444444; } table.cfdump_xml { background-color: 888888; } table.cfdump_xml th.xml { background-color: aaaaaa; } table.cfdump_xml td.xml { background-color: dddddd; } table.cfdump_struct { background-color: 0000cc ; } table.cfdump_struct th.struct { background-color: 4444cc ; } table.cfdump_struct td.struct { background-color: ccddff; } table.cfdump_array { background-color: 006600 ; } table.cfdump_array th.array { background-color: 009900 ; } table.cfdump_array td.array { background-color: ccffcc ; } table.cfdump_query { background-color: 884488 ; } table.cfdump_query th.query { background-color: aa66aa ; } table.cfdump_query td.query { background-color: ffddff ; } table.cfdump_cfc { background-color: ff0000; } table.cfdump_cfc th.cfc{ background-color: ff4444; } table.cfdump_cfc td.cfc { background-color: ffcccc; } table.cfdump_object { background-color : ff0000; } table.cfdump_object th.object{ background-color: ff4444; } table.cfdump_binary { background-color : eebb00; } table.cfdump_binary th.binary { background-color: ffcc44; } table.cfdump_binary td { font-size: x-small; } table.cfdump_udf { background-color: aa4400; } table.cfdump_udf th.udf { background-color: cc6600; } table.cfdump_udfarguments { background-color: dddddd; cell-spacing: 3; } table.cfdump_udfarguments th { background-color: eeeeee; color: 000000; } </style> <?xml version="1.0" ?><inventory Dealer="Smalls Auto Dealer"><automobile><car quantity="2"><make>Acura</make><model>Integra</model><color>Red</color></car></automobile></inventory> |
|
#4
|
|||
|
|||
|
when I do the search to solve this problem,
I found that someone mention the bug in coldfusion MX which renders an empty string when you send xml from Flash MX to Coldfusion MX. Anyone knows the solutions or any workarounds? Thanks a lot. |
|
#5
|
|||
|
|||
|
It doesn't look like CF is getting an empty string...after all the style sheet stuff for the CFDUMP tag, I see XML. If you modify what you are saving to the file to something like:
<cffile action="write" file="path to file" output="#GetHttpRequestData().content#"> Can you post what comes out in the file? And if what you get looks like valid XML, can you manually feed that XML into the xmlParse() function and confirm that it still fails? |
|
#6
|
|||
|
|||
|
Thanks for your help, kiteless
Finally, I solved this problem. I found one thing. When talking to the server side, xml.send never works, it only sends a empty string to the server side, but xml.sendAndLoad() always works, this is my actionscript after modification. productString="<?xml version=\"1.0\" ?><inventory Dealer=\"Smalls Auto Dealer\"><automobile>"; productString=productString+"<car quantity=\"2\"><make>Acura</make><model>Integra</model><color>Red</color></car>"; productString=productString+"</automobile></inventory>"; studio = new XML(productString); receiver=new XML( ); receiver.onLoad = function(cool)//here,no matter what variable name you will use //the variable is always set to a boolean value { if(cool){ //this toString() gives you the contents of the xml file in string format //trace(this.toString()); componentItem = this.firstChild.childNodes;//our xml file is pretty simple //with only one child,but this child has three children with attributes capturing //the component data we want //componentItem is an array which contains these three children trace(componentItem.length+" is the lengths for model arrays"); trace("the root element's attribute is "+this.firstChild.attributes.Dealer); }//end of if }//end of onload function() studio.sendAndLoad("http://localhost:8500/jiao/XML/flashBuiltXMLObject/digest.cfm", receiver); Here is my cold fusion code: <cfset xmlText =GetHttpRequestData().content> <cfset xmlResult=XmlParse(xmlText)> <cfset XmlNode=xmlResult.XmlRoot> <cfset vInventoryDealer=XmlNode.XmlAttributes.Dealer> <!--- <cfset xmlString=ToString(xmlResult)> ---> <cfset xmlString='<?xml version="1.0" ?><inventory Dealer="' & #vInventoryDealer# &'"><automobile><car quantity="2"><make>Acura</make><model>Integra</model><color>Red</color></car></automobile></inventory>'> <!---convert the xml document object to string ---> <!---<cfset XMLText=ToString(xmlResult)> ---> <!--- send the string to requesting program or browser(client)---> <!---here cfcontent set the content type to text/plain insteand of text/html---> <!--- and reset set to yes to remove all the whitespaces ---> |
|
#7
|
|||
|
|||
|
Same problem
I still getting the " Document root element is missing." problem when I send the xml from flash to coldfusion.
Please help me?????? Quote:
|
|
#8
|
|||
|
|||
|
You're not generating valid XML. If you take what you are trying to feed into Flash and output it to the screen instead to see what's wrong with the XML.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > sending xml from Flash MX to cold Fusion MX |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|