var sXML:String = "<root>"; sXML += myXMLListCollection.toXMLSTring();
sXML+= "</root"; myWebService.setUserPermits(sXML,sSID); on the .net side: <WebMethod(Description:="Updates multiple UserPermit records")> _ Public Function setUserPermits(ByVal sRowsXml As String, ByVal sSId As String) As DataTable . Tracy Spratt, Lariat Services, development services available _____ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Angelo Anolin Sent: Tuesday, July 07, 2009 8:09 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Hi Tracy, I would certainly appreciate if you could point me in the right direction on using XMLListCollection and sending it back to .NET as a string. Thanks. Regards, Angelo _____ From: Tracy Spratt <tr...@nts3rd.com> To: flexcoders@yahoogroups.com Sent: Tuesday, 7 July, 2009 4:45:56 Subject: RE: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Why not use XMLListCollection and send the xml to .net as a string? There is little value in building an ArrayCollection of generic obects. You can sort/filter an XMLListCollection. XML is more verbose than some other methods, but if bandwidth is truly an issue, then you should be looking at a binary protocol. Tracy Spratt, Lariat Services, development services available _____ From: flexcod...@yahoogro ups.com [mailto: flexcod...@yahoogro ups.com ] On Behalf Of Angelo Anolin Sent: Friday, July 03, 2009 2:09 AM To: flexcod...@yahoogro ups.com Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Hi Sam, Basically this is the process which I am using. .NET Retrieve records from Oracle DB and store the same into a dataset. Return the dataset as XML string via the command DataSet.GetXML. Flex In the event handler of my webservice method call, I parse the string into XML, then ArrayCollection via the following codes: private var _xmlData:XML; [Bindable] private var arrDP:ArrayCollecti on = new ArrayCollection; _xmlData = XML(event.result) ; var oTemp:Object; var xl:XMLList = _xmlData.children( ); var i:int; for(i = 0; i < xl.length(); i++) { oTemp = {NAME:xl[i]. NAME.text( ), TEAM:xl[i].TEAM. text(), JERSEY :xl[i] .JERSEY.text( ), MANAGER:xl[i] .MANAGER. text()}; arrDP.addItem( oTemp); } and in my datagrid, I am setting its dataProvider to the arrDP variable. I used Array Collection because I implemented a search and filter functionality which searches and filters the data accordingly for the dataprovider which is then reflected back to the datagrid. Now, when I need to return the ArrayCollection to .NET, I simply pass the same as a parameter to a .NET function which accepts ArrayList as parameter. .NET Once the function receieves the arraycollection (which is then now an array list), I get the arrays inside the arraylist and get the values inside the array. I think by doing things like this, it may not be the best way. You mentioned you'd map the XML to typed objects in .NET. How can I do this? Instead of using arraycollection as dataprovider in my datagrid, can I use another which would be much easier when I pass back to the .NET function? Whats the best way to interact large set of data (datasets) between .NET and Flex? Thanks a lot. _____ From: Sam Lai <samuel....@gmail. com> To: flexcod...@yahoogro ups.com Sent: Friday, 3 July, 2009 13:52:12 Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When Passed to .NET WebService Instead of using an array list and trying to emulate the type-less abilities of AS3, I'd try to map the XML to typed objects in .NET. Or does the XML from your Flex app differ too wildly to do this? Are you using the XmlSerializer to deserialize this? Or are you using WCF? Or are you doing it some other way, or manually? I'd provide an example, but I don't know enough details on your situation to give something useful :) 2009/7/3 Angelo Anolin <angelo_anolin@ <mailto:angelo_anolin%40yahoo.com> yahoo.com>: > > > Hi Sam, > > Care to show some examples? I am parsing the arrayCollection into an > ArrayList on .NET. This is particularly not too appealing since I just > discovered that for example, if one of the objects in the arraycollection > would have an empty string value, the number of items inside the array is > not reflected properly in .NET. > > Like: > > private var arrR:ArrayCollectio n = new ArrayCollection( [{ID:"001" , > Value:"Select" }, > {ID:"002", > Value:"Choose" }, > {ID:"003", > Value:""},]) ; > > When I pass this var arrR into a .NET webservice and delegate it to an > ArrayList, the items in the array list will have one of the arrays only > containing 1 item (instead of 2). > > Adding to my problem is the fact that the arrays inside the array list when > read in .NET should have the object ID and Value be in order but they are > not. This is further true when there are many items in the array > collection. Sometimes, the first item becomes the last one in the array > list, and sometimes the order is not well. > > In any case, I am finding a solution on how I would be able to pass an > ArrayCollection to .NET and be able to parse it properly. > > Thanks. > > ____________ _________ _________ __ > From: Sam Lai <samuel....@gmail. com <mailto:samuel.lai%40gmail.com> > > To: flexcod...@yahoogro ups.com <mailto:flexcoders%40yahoogroups.com> > Sent: Thursday, 2 July, 2009 15:46:58 > Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When > Passed to .NET WebService > > How is it being parsed in .NET? You can parse it into a hashtable, or > better yet, use a pre-defined object. > > Not sure why the order is different, but it is probably fragile to > rely on the order in this case. > > 2009/7/2 Angelo Anolin <angelo_anolin@ yahoo.com>: >> >> >> Hi FlexCoders, >> >> I have an array collection which I am populating as follows: >> >> var oTemp:Object; >> var xl:XMLList = _xmlData.children( ); >> var i:int; >> for(i = 0; i < xl.length(); i++) >> { >> oTemp = {ID_TAG:xl[i] .ID.text( ), CAT_TAG:xl[i] .CAT.text( ), >> DET_TAG:xl[i] .DET.text( ), REP_DATE_TAG: xl[i].REP_ DATE.text( ), >> IND_TAG:xl[i] .IND.text( )}; >> arrDP.addItem( oTemp); >> } >> Now, when I pass back this Array Collection back into a web service, the >> fields are not in order as I have added them into the array collection. >> >> I am expecting that in my Web Service, when I parse this arraycollection >> (via arraylist), I would be getting the same order of columns as I have >> added them, i.e. the first array in the array list would have element 0 to >> be the value I placed in the ID. >> >> Since the arraylist does not have the field tag (represented by ID_TAG, >> DET_TAG, CAT_TAG, etc..), it becomes a trial and error (hit and miss) on >> my >> part since I can only reference the value via the index on the array. >> >> Now, how would I be able to include the tags inside array collection such >> that when I read them as an array list in my .NET webservice, I know which >> element I am referring to in a particular index. >> >> Thanks. >> >> Regards, >> Angelo >> >> >> > > > >