I see something very strange in the Flex application that I support.
I looked through this, removing all calls to trace () and replacing them with calls in the logging framework (using the built-in mx.logging material). After that, some XML syntax code suddenly broke, and I can’t understand for life why.
here is the code:
private var loader:URLLoader; // created elsewhere private function handleComplete(event:Event):void { default xml namespace = com; xml = XML(loader.data); var response:XML = new XML(xml..raniResponse); //now handles a null response object if(xml && response.children().length() > 0) { LOG.debug("Got response."); var cityXML:XML = new XML(xml..city); var stateXML:XML = new XML(xml..stateProv); /* Some extra processing is done here */ } }
With code like this, with a call to LOG.debug (), I get the following error in the cityXML line:
TypeError: Error
If I comment on the call to LOG.debug (), it works fine.
I thought there might be some kind of weirdness with the target target log I created, so I deleted it. Currently, the only target is inline tracing.
Does anyone know what is going on? Why does a log call interrupt XML parsing? I can’t think of anything that could do this, it would break him.
EDIT:
I did some more tests and it just got weirder.
I changed the code based on David's comment to use xml..city [0] instead of the new XML (xml..city) for both purposes. This caused the exception to happen a bit later (in some code, which is not shown above, where it refers to cityXML). So I tried to go through the debugger and noticed something strange.
CityXML was set to null, and stateXML was getting the correct value. Looking at the xml object in the debugger, it showed all the correct data, so everything should be fine. As a random test, I rebuilt the code so that stateXML is loaded first. After that, stateXML is null, and cityXML is correct.
So, no matter what the appointment was made immediately after the failure of the log, but everything that happens after that worked fine.
Here is a (somewhat sanitized) XML that is parsed:
<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Body> <com:MyCompanyRANIv.01 xmlns:com="com:myc:rani:1:0:message" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <com:raniResponse> <com:telephonyInfo> <com:countryCode>1</com:countryCode> <com:telephoneNumber>14121234567</com:telephoneNumber> </com:telephonyInfo> <com:geoInfo> <com:coordinates> <com:latLon> <com:lat>40.49</com:lat> <com:lon>-79.92</com:lon> </com:latLon> </com:coordinates> <com:countryInfo> <com:country> <com:featureName>United States</com:featureName> <com:featureTypeDescription>United States of America</com:featureTypeDescription> <com:featureCode value="US" system="ISO 3166" family="Country Code" systemVer="1-alpha-2" /> </com:country> </com:countryInfo> <com:stateProvInfo> <com:stateProv> <com:featureName>PENNSYLVANIA</com:featureName> <com:featureTypeDescription xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> <com:featureCode family="US State Code" system="FIPS State Alpha Code" systemVer="" value="PA" /> </com:stateProv> </com:stateProvInfo> <com:regionInfo> <com:region> <com:featureName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> <com:featureTypeDescription xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> <com:featureCode family="" system="" systemVer="" value="" /> </com:region> </com:regionInfo> <com:countyParishInfo> <com:countyParish> <com:featureName>ALLEGHENY</com:featureName> <com:featureTypeDescription xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> <com:featureCode family="" system="" systemVer="" value="" /> </com:countyParish> </com:countyParishInfo> <com:cityInfo> <com:city> <com:featureName>PITTSBURGH</com:featureName> <com:featureTypeDescription xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> <com:featureCode family="" system="" systemVer="" value="" /> </com:city> </com:cityInfo> <com:buildingInfo> <com:building> <com:featureName xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> <com:featureTypeDescription xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /> </com:building> </com:buildingInfo> <com:streetAddress address="" /> </com:geoInfo> <com:services host="false" wireless="false" other="false" /> </com:raniResponse> <com:raniRequest> <com:fullyQualifiedTelephoneNumber>14121234567</com:fullyQualifiedTelephoneNumber> </com:raniRequest> </com:MyCompanyRANIv.01> </soapenv:Body> </soapenv:Envelope>