|
-
Hey, Guys --
I'm trying to send an XML file back to the server from a Flash 5 movie, using the XML object (not XMLSocket) and I'm not having a lot of success. Perhaps someone could shed some light on this for me????
Here's what's happening:
I've got a simple 1 frame Main timeline I'm using to test code that is successfully loading an XML file, with XML.load, and successfully extracting info from the nodes and formatting the content into a textfield. That stuff all works.
But... when I try to send the original XML object I loaded my file into back to the server, no joy. XML.sendAndLoad appears to only be sending the http header, and XML.send doesn't seem to send *anything*...
Can anyone describe the POST format that Flash sends? It's hard to tell for sure that the server isn't receiving the data without knowing what it's supposed to receive...
Here's the code I'm using - I'm sure some of you will recognize its origins. ;-)
urlXML = new XML();
urlXML.contentType="text/xml";
urlXML.onLoad = sendXML;
urlXML.load("http://jeastman-2k:7001/rs/testtransform");
function sendXML(){
if(this.loaded){
newXML = new XML();
urlXML.sendAndLoad("http://dallison2:7001/timm/ModifyForm",newXML);
}
}
Also, any clue why XML.send doesn't seem to work at all? The two methods should both work in the same scenarios, right?
I have searched the archives as far back as January for the answer to this question, and so none of the other posts that seems to be asking a similar question have ever been answered.... is this because the question is so basic, or because no one knows the answer?
I sure hope someone out there can help... I'm getting pretty frustrated. This was supposed to be the *easy* part of this project!
Thanks in advance!
Melanie
-
You need to run it in a web browser. Don't do the "Test Movie" that doesn't have the correct mechanism to send the information back to the server.
Try the "Publish Preview"
Steve Nelson
-
2 big issues with XML.sendAndLoad
One: the stand alone player and authoring environment can't do POST, so they send the data but in a different way, not worth bothering with for the most part.
Two: it sends the data as the POST content, but not assigned to a variable.
when you POST a form from a web browser the data is in variable=data pairs and most CGI/ServerProccessors are designed to work easily with this type of data.
There is no reason you can't just grab the raw data, It should be possible in any environment, but it's not the "usual" thing to do.
as an quick way to get the data you can use the normal variable=data parser provided and just convert the name of the first variable returned into a string and there is the XML data.
-
Hey, thanks for the responses!
It turns out you're both right... and that just like the whitespace problem with XML, having the latest version of the player is important, too! That seems to be the only way to set the XML.contentType, which seems to make a difference when I play the movie from a browser.
The way Flash 5 handles XML is really quirky... I've hit a lot of snags, as well. I've included descriptions with some links to posts that helped me out:
I had the whitespace problem, which I figured out pretty quickly, but here's someone else's excellent thread (http://board.flashkit.com/board/showthread.php?threadid=131881) talking about the issue.
Then I had this XML.send and XML.sendAndLoad issue... I still don't know why XML.send doesn't work...
And then I ran into the problem with unpredictable variable scope when loading and handling an XML file in a child MC. Fortunately, I found this post (http://board.flashkit.com/board/showthread.php?threadid=135509) while trying to solve the other problems, before I ran into it...
Finally, I encountered a weird problem when I created a new XML object and cloned the nodes of the XML object I loaded from a URL. I was able to perform all of the actions on the new object that had been working on the old object (finding nodes, removing nodes, appending nodes), and it seemed to be working perfectly... until I tried to do a sendAndLoad.
As far as I can tell, the two objects should be identical, but only the original object that I created with XML.load works with XML.sendAndLoad. I worked around this, by modifying my original XML object and sending it back to the server. Fortunately, can get away with that in this project, but it sure seems like Flash does something funky when it clones nodes that causes this one method to break.... go figure. If anyone knows what's up with this, I'd kind of like to know for future reference....
Thanks again, guys...
Melanie
-
And while we are listing all the oddities that cause headaches, how about flash does not escape the XML document, unlike a HTML form which does escape the data.
So if your server side program un escapes the data it can get messy.
-
Hi,
I would like to know if it is actually impossible to use sendAndLoad from a projector
what do you mean hal when you say
=================================================
the stand alone player and authoring environment can't do POST, so they send the data but in a different way, not worth bothering with for the most part. '
=================================================
I have to find out a way to exchange XML data between a servlet and a projector...
any suggestion will be very welcome 
thanks
fabio
-
I have been using loadvariables to send my data and xml.load() to receive my xml data. you can use method=post with loadvariables and it works fine. SendAndLoad just didn't work right for me.
Steve
-
loadvariables will use GET when run in the stand alone player or projector, even if you tell it to use POST.
This is fine for sending data smaller than 2K.
I have seen that sendAndLoad does send the data, even from the Projector, probably in a GET format, but since this data is not URI escaped it's a non-standard situation.
You can almost certainly make it work if you are writing your own back end scripts (in PERL, PHP, JAVA, or C) but maybe not with systems like ASP or Cold Fusion where you do not have compleat control. I decided it was not worth while to build a script to handle this unique situation.
I would agree with Steve just use loadvariables with GET in this case.
-
I don't think any of the Flash functions will send post in the standalone projector.
loadvariables can do post when run through a browser.
Steve
-
cgi::XMLForm
I am trying to do something similar. I want to create an HTML based form on a website that will write to an XML file. I am pulling the data in that XML file into a stand alone projector flash movie. I can't seem to get the script to work correctly though. If anyone figures this out. drop me an email or post back. [email protected]
http://html.about.com/compute/html/g...2FXMLForm.html
-
Thanks a lot guys,
a great help came from you 
Now it is clear to me I can't use sendAndLoad in my app, even if I was writing the back end script, because I have to send a large amount of data
I think I try to put my swf movie in a VisualBasic app (or similar) and let it send data to my servlet...
Thank you again 
Fabio
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|