ERROR ON LINE 1: CONTENT IS NOT ALLOWED IN PROLOG.

I am working on a small flex application that sends XML to the server using <mx:httpservice />. The server then responds with a bit of XML for my manipulation. I keep getting an error form the server stating the XML is not well formed. If I trace the XML before I send it, it shows up fine in the debug window. No spaces, carriage returns or anything before the XML declaration (which from what I have read,is usually the cause of the error "Content is not allowed in prolog".

As you can see in the image, the XML declaration does not appear to have anything preceding it...

Has anyone run into this in the past? Have any suggestions? I'd greatly appreciate it!

Related Blog Entries

Comments
Mike Givens's Gravatar Yes, this one about drove me crazy a week ago... I bet you're running CFMX with an "old" DevNet Serial Number). If that's the case, I saw evidence of a watermark: <META NAME="ColdFusionMXEdition" CONTENT="ColdFusion DevNet Edition - Not for Production Use.">
"If the generated content is, say, XML delivered via CFCONTENT then the XML will have the unclosed META tag as a watermark which breaks the well-formedness of the XML document."

More info at: http://www.talkingtree.com/blog/index.cfm/2005/6/1....

Hope this helps you save some sanity. :-)
# Posted By Mike Givens | 3/24/07 8:53 AM
Mike Givens's Gravatar By the way, I found this by using Kevin Langdon's Service Capture, a very useful product:

http://kevinlangdon.com/serviceCapture/
# Posted By Mike Givens | 3/24/07 9:02 AM
Critter's Gravatar Actually, I am not even hitting a CF server with it. I am not sure what the exact cause is, but the service capture program will definitely come in handy. Thanks
# Posted By Critter | 3/24/07 10:24 AM
Michael Ramirez's Gravatar View your XML file using a HEX editor and you will see that your XML file is preceded with some junk characters. This is because the editor you are using to save the XML document is using the wrong character encoding. I believe you need to use 8-Bit encoding.
# Posted By Michael Ramirez | 3/24/07 2:21 PM
anon's Gravatar "ERROR ON LINE 1: CONTENT IS NOT ALLOWED IN PROLOG."

Well there's your problem, you accidentally ran a Prolog interpreter instead of the MXML compiler.
# Posted By anon | 3/24/07 6:29 PM
Critter's Gravatar UltraEdit shows nothing in the file before the beginning of the XML.

The Prolog error is coming from another server that is processing the submitted xml... it has nothing to do with mxml.. I'm running the stuff straight outta flex builder.. outta the box.. so hopefully I haven't muffed anything up on my end.. *shrug*
# Posted By Critter | 3/24/07 9:37 PM
judah's Gravatar It sounds like you are getting two errors. The prolog error and the xml is not well formed. The prolog error is because something is coming before your xml declaration. The server is returning something other than the xml declaration first. See this post: http://www.judahfrangipane.com/blog/?p=53

The xml is not well formed can be caused by the xml not being well formed obviously or not getting any data whatsoever. See this post: http://www.judahfrangipane.com/blog/?p=95

In the httpservice call change the resultType to text instead of xml or e4x and trace out the value. Also, using Service Capture like another poster stated can help save hours.
# Posted By judah | 3/25/07 2:25 AM
Critter's Gravatar I put examples of the calls and which ones (outside of Flex) work..

http://codeshare.ulatu.com/mara01b4
# Posted By Critter | 3/25/07 7:27 AM
Mike Givens's Gravatar I'm confused... The codeshare "code" shows a cfhttp call, so that implies a ColdFusion server IS in the mix somewhere. If that server is adding content before the start of your XML, then that's cauing the prolog error. It doesn't matter if you not running ColdFusion on your server (e.g. if your HTTPService call is hitting an external ColdFusion Server that's adding the watermark, then bad prolog will occur).
# Posted By Mike Givens | 3/25/07 8:13 AM
Critter's Gravatar The original example I was given worked in VBSCript. I was able to get it working in CFML (the cfhttp call), but now am attempting to get the same XML posted to the same 3rd party server using Flex2. The server that is receiving the XML is /not/ a CFML server.
# Posted By Critter | 3/25/07 8:19 AM
Critter's Gravatar Finally!!!!

Mind you, I was /not/ able to do it using <mx:httpservice />

I was able to do it using the following:
http://codeshare.ulatu.com/mar47ca4

Thanks for all the help!
# Posted By Critter | 3/25/07 8:33 AM
judah's Gravatar Glad you got it! The underlying classes are the same so I would not say httpservice cannot return the value. I think I see the problem.

In your original code change this:
# < mx:request xmlns="">
# {str}
# < /mx:request>

to this:
# < mx:request>{str}</ mx:request>

note: i added the spaces so the markup would show up
flex takes child node contents that are strings literally. it does nothing with the data so it is sending exactly what you want it to.
# Posted By judah | 3/25/07 10:47 AM
judah's Gravatar forgot to mention, join the flex channel at irc://efnet/#flex. look for flexo and give him massive points. ;)
# Posted By judah | 3/25/07 10:50 AM
Alan Jack's Gravatar This worked for me:

public function requestItems():void {
   var xmlStr:String = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><doc><first>testing</first></doc>";
   var xml:XML = new XML(xmlStr);
   var itemXML:HTTPService = new HTTPService();
   itemXML.contentType = "application/xml";
   itemXML.method = "POST";
   itemXML.addEventListener(ResultEvent.RESULT, handleResults);
   itemXML.addEventListener(FaultEvent.FAULT, handleError);
   itemXML.url = "http://localhost:8080/tomcat_app/";;
   itemXML.send(xmlStr);
}
# Posted By Alan Jack | 4/27/07 3:36 PM
Alan Jack's Gravatar My mistake, the last line should be:

itemXML.send(xml);

In the send method, it needs to be an XML object, not a String object.
# Posted By Alan Jack | 4/27/07 3:48 PM
Tigee's Gravatar [url=http://www.toy-match.com]RC Bearing[/url]
[url=http://www.toy-match.com]Toy stores for RC Tank,RC Bearing,Radio Control[/url]
[url=http://www.toy-match.com/rctanks.html" target="_blank">http://www.toy-match.com/rctanks.html]RC Tank[/url]
[url=http://www.toy-match.com/tomy+tomica.html]Tomica[/url]
[url=http://www.toy-match.com/choroq.html]Choro-Q[/url]
[url=http://www.toy-match.com/futaba.html]Futaba[/url]
[url=http://www.toy-match.com/tamiya.html]Tamiya[/url]
[url=http://www.toy-match.com/ebbro.html" target="_blank">http://www.toy-match.com/ebbro.html]Ebbro[/url]
[url=http://www.toy-match.com/tank.html" target="_blank">http://www.toy-match.com/tank.html]Tiger I[/url]
[url=http://www.toy-match.com/tomy+tomica.html]Tomy[/url]
[url=http://www.toy-match.com/miniz.html]Mini-Z[/url]
[url=http://www.toy-match.com/futaba.html]Radio Control[/url]
[url=http://www.toy-match.com/rc_bearing.html" target="_blank">http://www.toy-match.com/rc_bearing.html]RC Bearing[/url]
[url=http://www.toy-match.com/minichamps.html]Minichamps[/url]
[url=http://www.toy-match.com/silverlit.html]Silverlit[/url]
[url=http://www.toy-match.com/kyosho.html" target="_blank">http://www.toy-match.com/kyosho.html]Kyosho[/url]
[url=http://www.toy-match.com/ixo.html]IXO[/url]
# Posted By Tigee | 9/11/07 2:34 AM
sophie's Gravatar thanks for sharing your code.
I use your code for my web: http://www.chinayujie.com
# Posted By sophie | 9/26/07 7:22 PM
mark's Gravatar see your XML file using a HEX editor .I think you should use 8-Bit encoding.
# Posted By mark | 10/8/07 8:59 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.001. Contact Blog Owner