ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old November 10th, 2003, 02:19 PM
jyu1 jyu1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Tucson
Posts: 44 jyu1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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.

Reply With Quote
  #2  
Old November 11th, 2003, 09:57 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,611 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 10 m 21 sec
Reputation Power: 53
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>

Reply With Quote
  #3  
Old November 11th, 2003, 11:44 AM
jyu1 jyu1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Tucson
Posts: 44 jyu1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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>

Reply With Quote
  #4  
Old November 11th, 2003, 04:50 PM
jyu1 jyu1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Tucson
Posts: 44 jyu1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
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.

Reply With Quote
  #5  
Old November 12th, 2003, 11:24 PM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,611 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 10 m 21 sec
Reputation Power: 53
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?

Reply With Quote
  #6  
Old November 14th, 2003, 01:03 AM
jyu1 jyu1 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Tucson
Posts: 44 jyu1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Wink I have solved the problem

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 --->

Reply With Quote
  #7  
Old October 13th, 2004, 10:31 PM
mattyho mattyho is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 1 mattyho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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:
Originally Posted by jyu1
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 --->

Reply With Quote
  #8  
Old October 14th, 2004, 10:33 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,611 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 10 m 21 sec
Reputation Power: 53
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > sending xml from Flash MX to cold Fusion MX


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway