Perhaps your special characters trailing the document are whitespace
(tabs, new lines, etc)?
 
There are known issues with constructing an XML instance (the basis for
E4X) from Strings containing whitespace between processing instructions
and the start of the root element (or trailing whitespace after the root
element) and with XML.ignoreWhitespace set to false.
 
Have you by any chance set XML.ignoreWhitespace to false?
 
If so, for your particular scenario of trailing special characters you
could keep HTTPService's resultFormat as "text" to get it as a raw
String, then use mx.utils.StringUtil.trim() on the String, and then
construct a new XML instance from your String new XML(result).
 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of klumikaze
Sent: Monday, March 05, 2007 2:40 PM
To: [email protected]
Subject: [flexcoders] Special characters after end tag of XML document
(HTTPService issue)



I've got an E4X HTTPService in Flex that is calling a servlet which
returns an XML 
document. Approximately 80% of the time, the servlet works fine and the
HTTPService 
result is a valid XML doc -- the rest of the time, the HTTPService is
giving me a fault:

[RPC Fault faultString="Error #1088: The markup in the document
following the root 
element must be well-formed." faultCode="Client.CouldNotDecode"
faultDetail="null"]

After taking a look at the servlet directly in the browser (removing
Flex from the equation), 
I have not noticed any issue with the XML returned and we have run it
through several 
online validation tools. The servlet code that generated the XML is fine
as well, we have 
checked that numerous times.

I thought that the problem might be the resultFormat of the HTTPService
(currently E4X), 
so I changed it to 'text' so I could see if there was any special
characters or issues with the 
XML after Flex called the servlet. I discovered that there are seemingly
random special 
characters being appended to the end of the document (after the end
tag). The string of 
random special characters ranges from 2-10 in length.

Note: I have since put the resultFormat of the HTTPService back to e4x.

Does anybody have any idea why this might be happening? We have observed
this on 
Windows, OS X and Ubuntu Linux platforms, in IE7, Safari, Firefox (Mac)
and Firefox 
(Ubuntu).

Thanks for your help,

Brian



 

Reply via email to