[flexcoders] Re: Special characters after end tag of XML document (HTTPService issue)
Peter, I have resolved the issue. It turns out that when I was adding a character set to our application (so users could enter French/Latin characters), I used the old System.useCodePage trick from my days as a Flash developer... when that property is set to true, the extra characters get appended to the end of the HTTPService results I suspect due to the servlets being UTF-8 (not Unicode) -- I could be wrong about the specifics. Thank you very much for your help though. Brian --- In flexcoders@yahoogroups.com, Peter Farland [EMAIL PROTECTED] wrote: I don't believe there is a maximum length (or at least the length you describe is surely not a problem in itself), however if you are using chunked encoding then the length of the document will change the way the data is sent (i.e. chunked or not). On reading that you were dealing with chunked data, it reminded me of a known issue (Bug 191814) with the Flash Player in MSIE. The issue occurs when a Cache-Control: no-cache header is sent but with chunked encoding and gzip'ed content. I believe a work around is to append must-revalidate to the Cache-Control no-cache header: Cache-Control: no-cache, must-revalidate This Microsoft KB article http://support.microsoft.com/kb/871205 mentions the issue occurs with HTTPS, but we've seen reports with HTTP too. Pete From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of klumikaze Sent: Tuesday, March 06, 2007 12:21 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Special characters after end tag of XML document (HTTPService issue) Peter, We've installed TamperData for Firefox and we've done some extensive testing with it to see if the special characters exist in the HTTP responses. We have been unable to reproduce the problem there. We have tried setting the content length header accurately based on the data the servlet spits out. We have also checked the other items you suggested and they appear to be fine... we are actually just generating a string of XML manually, there is no XML document in the equation. At this point we are wondering what the possibility is that the HTTPService (or URLLoader) has problems handling chunked data? Is there a maximum length that the HTTPService/ URLLoader can handle for an XML document? Our average document is sitting at around 500 lines of XML. Thanks again for your assistance with this issue, Brian
[flexcoders] Re: Special characters after end tag of XML document (HTTPService issue)
Thanks Peter I have implemented the URLLoader method as suggested, and unfortunately I am still experiencing the same issues. I'm really starting to think this could be on the Java end of things -- anybody have any insight there? We have set the character encoding of the servlet to UTF-8 explicitly, and we have the content type set to text/xml. Thoughts? Thanks, Brian --- In flexcoders@yahoogroups.com, Peter Farland [EMAIL PROTECTED] wrote: If you're not using the proxy, then HTTPService is ultimately using flash.net.URLLoader to load and receive the data. You could try to take Flex out of the equation for a second and try the raw URLLoader API to see if it still occurs there. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Brian Dunphy Sent: Monday, March 05, 2007 3:29 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Special characters after end tag of XML document (HTTPService issue) Peter, I have not made any changes to the XML.ignoreWhitespace property. I have implemented the trim as suggested, and I have also put a check to see if the last character of the string is a (a quick way to see if there's trailing junk characters). What I'm experiencing now is the same issue as before, however now I can see the trailing characters traced in my flashlog. Just as a sample, `á!àê!àî!`á! ï! appears at the end of one of them. I have noted that we are experiencing this with more than one servlet at this point, it appears that all of the servlets in our application might be affected. Any other thoughts/suggestions? Thanks again, Brian On 3/5/07, Peter Farland [EMAIL PROTECTED] mailto:pfarland%40adobe.com wrote: 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: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of klumikaze Sent: Monday, March 05, 2007 2:40 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 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 -- Brian Dunphy
RE: [flexcoders] Re: Special characters after end tag of XML document (HTTPService issue)
You could use an HTTP sniffer to prove that the content is coming from your servlet. As for a cause, I would look at the code writing to the response stream, whether you're flushing the buffer when you're finished, whether you're writing to the stream using a different encoding, whether you're swallowing any unexpected exceptions, whether the content length reported is accurate, etc. Also I'm guessing that you're converting your XML Document to a String before serializing it in the response... I'd check this output before it returns too. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of klumikaze Sent: Tuesday, March 06, 2007 9:56 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Special characters after end tag of XML document (HTTPService issue) Thanks Peter I have implemented the URLLoader method as suggested, and unfortunately I am still experiencing the same issues. I'm really starting to think this could be on the Java end of things -- anybody have any insight there? We have set the character encoding of the servlet to UTF-8 explicitly, and we have the content type set to text/xml. Thoughts? Thanks, Brian --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Peter Farland [EMAIL PROTECTED] wrote: If you're not using the proxy, then HTTPService is ultimately using flash.net.URLLoader to load and receive the data. You could try to take Flex out of the equation for a second and try the raw URLLoader API to see if it still occurs there. From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Brian Dunphy Sent: Monday, March 05, 2007 3:29 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: Re: [flexcoders] Special characters after end tag of XML document (HTTPService issue) Peter, I have not made any changes to the XML.ignoreWhitespace property. I have implemented the trim as suggested, and I have also put a check to see if the last character of the string is a (a quick way to see if there's trailing junk characters). What I'm experiencing now is the same issue as before, however now I can see the trailing characters traced in my flashlog. Just as a sample, `á!àê!àî!`á! ï! appears at the end of one of them. I have noted that we are experiencing this with more than one servlet at this point, it appears that all of the servlets in our application might be affected. Any other thoughts/suggestions? Thanks again, Brian On 3/5/07, Peter Farland [EMAIL PROTECTED] mailto:pfarland%40adobe.com wrote: 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: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of klumikaze Sent: Monday, March 05, 2007 2:40 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com 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
[flexcoders] Re: Special characters after end tag of XML document (HTTPService issue)
Peter, We've installed TamperData for Firefox and we've done some extensive testing with it to see if the special characters exist in the HTTP responses. We have been unable to reproduce the problem there. We have tried setting the content length header accurately based on the data the servlet spits out. We have also checked the other items you suggested and they appear to be fine... we are actually just generating a string of XML manually, there is no XML document in the equation. At this point we are wondering what the possibility is that the HTTPService (or URLLoader) has problems handling chunked data? Is there a maximum length that the HTTPService/ URLLoader can handle for an XML document? Our average document is sitting at around 500 lines of XML. Thanks again for your assistance with this issue, Brian --- In flexcoders@yahoogroups.com, Peter Farland [EMAIL PROTECTED] wrote: You could use an HTTP sniffer to prove that the content is coming from your servlet. As for a cause, I would look at the code writing to the response stream, whether you're flushing the buffer when you're finished, whether you're writing to the stream using a different encoding, whether you're swallowing any unexpected exceptions, whether the content length reported is accurate, etc. Also I'm guessing that you're converting your XML Document to a String before serializing it in the response... I'd check this output before it returns too. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of klumikaze Sent: Tuesday, March 06, 2007 9:56 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Special characters after end tag of XML document (HTTPService issue) Thanks Peter I have implemented the URLLoader method as suggested, and unfortunately I am still experiencing the same issues. I'm really starting to think this could be on the Java end of things -- anybody have any insight there? We have set the character encoding of the servlet to UTF-8 explicitly, and we have the content type set to text/xml. Thoughts? Thanks, Brian --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Peter Farland pfarland@ wrote: If you're not using the proxy, then HTTPService is ultimately using flash.net.URLLoader to load and receive the data. You could try to take Flex out of the equation for a second and try the raw URLLoader API to see if it still occurs there. From: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of Brian Dunphy Sent: Monday, March 05, 2007 3:29 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: Re: [flexcoders] Special characters after end tag of XML document (HTTPService issue) Peter, I have not made any changes to the XML.ignoreWhitespace property. I have implemented the trim as suggested, and I have also put a check to see if the last character of the string is a (a quick way to see if there's trailing junk characters). What I'm experiencing now is the same issue as before, however now I can see the trailing characters traced in my flashlog. Just as a sample, `á!àê!àî!`á! ï! appears at the end of one of them. I have noted that we are experiencing this with more than one servlet at this point, it appears that all of the servlets in our application might be affected. Any other thoughts/suggestions? Thanks again, Brian On 3/5/07, Peter Farland pfarland@ mailto:pfarland%40adobe.com wrote: 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: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of klumikaze Sent: Monday, March 05, 2007 2:40 PM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com mailto:flexcoders%40yahoogroups.com Subject: [flexcoders] Special characters
RE: [flexcoders] Re: Special characters after end tag of XML document (HTTPService issue)
I don't believe there is a maximum length (or at least the length you describe is surely not a problem in itself), however if you are using chunked encoding then the length of the document will change the way the data is sent (i.e. chunked or not). On reading that you were dealing with chunked data, it reminded me of a known issue (Bug 191814) with the Flash Player in MSIE. The issue occurs when a Cache-Control: no-cache header is sent but with chunked encoding and gzip'ed content. I believe a work around is to append must-revalidate to the Cache-Control no-cache header: Cache-Control: no-cache, must-revalidate This Microsoft KB article http://support.microsoft.com/kb/871205 mentions the issue occurs with HTTPS, but we've seen reports with HTTP too. Pete From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of klumikaze Sent: Tuesday, March 06, 2007 12:21 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Special characters after end tag of XML document (HTTPService issue) Peter, We've installed TamperData for Firefox and we've done some extensive testing with it to see if the special characters exist in the HTTP responses. We have been unable to reproduce the problem there. We have tried setting the content length header accurately based on the data the servlet spits out. We have also checked the other items you suggested and they appear to be fine... we are actually just generating a string of XML manually, there is no XML document in the equation. At this point we are wondering what the possibility is that the HTTPService (or URLLoader) has problems handling chunked data? Is there a maximum length that the HTTPService/ URLLoader can handle for an XML document? Our average document is sitting at around 500 lines of XML. Thanks again for your assistance with this issue, Brian