Expand my Community achievements bar.

HTTPService XML trouble

Avatar

Level 1
Hi. I use HTTPSevice to dynamicly load xml elements for
mx:Tree. The xml is like

<root>

<row attr1="11" attr2="22".../>

<row attr1="111" attr2="222".../>

<row attr1="1111" attr2="2222".../>

.....

</root>

And everything works perfect. But!!! 1 of 5 (more or less)
times the error #1090:

*********

Microsoft Internet Explorer

Error #1090: XML parser failure: element is malformed.

*********

occurs. I'm sure the xml is correct. I've checked it. But
it's not small and attributes contain a long strings.

Has anybody confronted with such problem?

Thanks
10 Replies

Avatar

Level 3
Hi,



I haven't seen such problem! How big is your xml? Can you
also show me your result handler and the function which you call
httpservice? Are you using HttpService tag or actionscript class?
Are your httpservice instance is function's location variable? II
saw a problem before in socket which a single varaible referencing
all to start it. a = new Socket(); a.dosomething(); a = new
Socket(); a.dosomething()....... etc. It turnws out when the player
heap filled up. Garbage collector came in to destroy the non
referenced socket.

Thanks!



William Chan

Avatar

Level 1
There are mx:HTTPService tag

<mx:HTTPService id="ntreeXML" resultFormat="text"
useProxy="false" result="fHTTPServiceResult(event)"
fault="fHTTPServiceFault2(event)"/>

and

<mx:Tree id="mainTree"

change="changeEvt(event)"

......../>





public function changeEvt(event:Event):void {

..........

ntreeXML.url = "
http://localhost/TreeDoc2/bin/asp/pgTreeXML.asp?pSQLStr="
+ event.currentTarget.selectedItem.@URLTREESQL.toString();

ntreeXML.send();

..........

}



public var treeXMLInit2:XMLList;

public function fHTTPServiceResult(event:ResultEvent):void

{

treeXMLInit = new XMLList(event.result)}

****error happens here****

................



}



Result of HTTPService is



<_ROOT_>

<RT isOnceLoaded="false"
ID="ABC.1111111/11/11111.DOBLIST.1"
IDHIGH="ABC.1111111/11/11111.DOBLIST" URLOUTPUT="Deafult.asp"
LABEL="N: 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" ISFOLDER="1"
URLTREE="Deafult.asp" URLTREESQL="select
pkg_TREE_PROCEDURES.fDefault_PROCEDURE(
'125','10.21.21.99','ABCD','GTD.STYLE.1','GTD.TREE_1_3_DOBLIST','[:FVAL.ND];[:FVAL.NDBASE];[:FVAL.IDHIGH];[:FVAL.G32]','STRING;STRING;STRING;STRING','1111111/11/11111;X9;ABC.1111111/11/11111.DOBLIST.1;1',NULL)
TEXT_OUT from dual" URLOUTPUTSQL="select
pkg_TREE_PROCEDURES.fDefault_PROCEDURE(
'125','10.21.21.99','ABCD','GTD.STYLE.1','GTD.DOBLIST.1','[:FVAL.ND];[:FVAL.NDBASE];[:FVAL.IDHIGH];[:FVAL.G32]','STRING;STRING;STRING;STRING','1111111/11/11111;X9;ABC.1111111/11/11111.DOBLIST.1;1',NULL)
TEXT_OUT from dual" >

</RT>

......

nearly 200 RT tags

</ROOT>



It is correct. xml is 160KB. If I load xml from local xml
file, there is no problems. But if I take it from ASP page, it
works, but sometimes the problem (error #1090) happens.

I used URLLoader class instead of HTTPService tag, but the
result was the same.

Thank you for your answer

Victor

Avatar

Level 3
Hi,



Since it works in static page, it might be the asp problem.
Can you use a http sniffer to capture the asp output? When the
problem arises, you can verify the xml.



William Chan

Avatar

Level 1
Hi. Thank you William for your answers. It seems I've found a
way to manage the problem. But I haven't understood the reason. I
simply catch an error and use HTTPService send() again until xml
loads correctly. The problem is not in ASP.



Victor K.

Avatar

Level 1
Hi Bill

Hi Victor



I do have a similar problem. Im sending the result from a
HTTPService directly to an arrayCollection, everything works fine
when my XML has more than one object. If the XML has only one node
I get immediately a run time error saying



"Typumwandlung fehlgeschlagen: mx.utils::ObjectProxy@b614ac1
kann nicht in mx.collections.ArrayCollection umgewandelt werden."



which means that the objectProxy returned can not be
converted into an arrayCollection. I have checked during the last 2
days the XML and it is completely correct.



I can catch without any problem the result of the HTTPService
when I use the mehtod
.lastresult, however I need to manipulate the information
using an Array therefore i',m trying to use the arrayCollection
structure.



Have you any idea what could be the problem ?



Thanks

Avatar

Level 3
Hi,



How your xml look like? Does your xml contain repeating
element?

example

<mydata>

<name>abc</name>

<name>abc</name>

<name>abc</name>

</mydata>



lastResult.mydata.name is an array. If name just appears one,
it won't be converted as array. I am not sure it is the problem or
not.



William Chan

Avatar

Level 1
Hi!



I have the same problem with URLLoader class.



I use it that way:

var request:URLRequest = new URLRequest("
http://localhost/kinoflex.php");

var loader:URLLoader = new URLLoader();

public function send(datasend:String):void {

request.contentType = "text/xml";

request.method = URLRequestMethod.POST;

try {

request.data = datasend;

loader.load(request);

} catch (error:ArgumentError) {

Alert.show('An ArgumentError has occurred.','Error!');

} catch (error:SecurityError) {

Alert.show('A SecurityError has occurred.','Error!');

}

}



public function onInit():void {

loader.addEventListener('complete',receive);

}



public function receive(evtObj:Event):void {

var resXML:XML;

trace('Data format: '+loader.dataFormat);

trace('Bytes loaded: '+loader.bytesLoaded);

trace('Bytes total: '+loader.bytesTotal);

trace(loader.data);

resXML = XML(loader.data); // Error occures here

...

}



And the traces (repeating items skipped, xml formatted for
convenience):

Data format: text

Bytes loaded: 7713

Bytes total: 7713

<resp>

<cmd>get_libs</cmd>

<res>ok</res>

<movie>


<item><id>285</id><name>Адреналин</name><lid>976</lid></item>

[REPEATING_ITEMS]


<item><id>439</id><name>Прощальный
поцелуй</
TypeError: Error #1088: The markup in the document following the
root element must be well-formed.

at
kinoadmin/receive()[C:\pers\projects\flex\kinoadmin\kinoadmin.mxml:459]

at
flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()

at flash.events::EventDispatcher/dispatchEvent()

at
flash.net::URLLoader/flash.net:URLLoader::onComplete()


name><lid>1688</lid></item>


<item><id>434</id><name>Свидание
моей
мечты</name><lid>1696</lid></item>

[REPEATING_ITEMS]


<item><id>433</id><name>Эскадрилья
Лафайет</name><lid>1692</lid></item>

</movie>

</resp>яяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяяя`



As we can see, the error goes before the trace outputs all
the text. May be function XML(loader.data) starts before all the
response passed to loader.data? And strange symbols attached to the
end of file. Every time they are different. I have no such strings
in my script. I've tested the response of my script, addresing it
directly in firefox - the script returns valid XML without any
trailing wierd symbols.



The size of received file is 7 714 bytes. And in this case
error came on 7092 bytes.



I will be glad if u find my mistake or solution of this
problem.

Thanks!

Avatar

Level 1

quote:




Originally posted by:
aBill


Hi,



How your xml look like? Does your xml contain repeating
element?

example

<mydata>

<name>abc</name>

<name>abc</name>

<name>abc</name>

</mydata>



lastResult.mydata.name is an array. If name just appears one,
it won't be converted as array. I am not sure it is the problem or
not.



William Chan







This is exactly the problem I have. Any suggestions?

Avatar

Level 1
Temporarly solved the problem this way:



public function receive(evtObj:Event):void {

var resXML:XML;

if (loader.data.substring(loader.data.length-7) !=
'</resp>') {

var pos:int = loader.data.indexOf('</resp>');

loader.data = loader.data.substring(0,pos+7);

}

resXML = XML(loader.data);

...

}

Avatar

Level 1
Yes XML has repeating elements, but I think the problem is
not here.



It will be very interesting to see developers
comments.