Do you think that it would help if you converted your array collection to an 
array collection of typed objects before sending it  to .net?

--- In [email protected], Angelo Anolin <angelo_ano...@...> wrote:
>
> Hi Sam Lai,
> 
> THanks for the input and my apologies for replying late since I felt the need 
> to get deeper on the issue I am encountering.
> 
> In my web service, the arraycollection is received as an array list and yes, 
> it is like an array of xml nodes.
> 
> In my arraycollection, say I have 5 columns and when one of the columns 
> contains an empty string, when I pass it to my .NET webservice, the arraylist 
> will have an array which only contains 4 columns (instead of the expected 
> 5).� That is why the empty field is actually causing me some problems.
> 
> I am trying to find some E4x documentation / article specifically tackling 
> this kind of .NET and Flex integration. Do you know of some?
> 
> Thanks and regards,
> 
> Angelo
> 
> 
> 
> 
> ________________________________
> From: Sam Lai <samuel....@...>
> To: [email protected]
> Sent: Saturday, 4 July, 2009 12:54:53
> Subject: Re: [flexcoders] ArrayCollection Does Not Show Items In Order When 
> Passed to .NET WebService
> 
> 
> 
> 
> 
> I just wrote up a simple C# web service that accepts an ArrayList:
> 
> [WebMethod]
> public bool ArrayListTest( System.Collectio ns.ArrayList a)
> { ... }
> 
> Then in Flex I wrote this,
> 
> <mx:Script>
> <![CDATA[
> import mx.collections. ArrayCollection;
> private function sendWebServiceCall( ):void
> {
> trace("appComplete" );
> ws.ArrayListTest( new ArrayCollection( [ {name:"bob", id:"808" }, {
> name:"fred", id:"" }]));
> }
> ]]>
> </mx:Script>
> <mx:WebService wsdl="http://localhost: 63868/Service1. asmx?WSDL" id="ws">
> <mx:operation name="ArrayListTest " result="trace( event.result) "
> fault="trace( event.fault. faultString) "/>
> </mx:WebService>
> 
> When sendWebServiceCall is triggered, it calls the C# web service and
> passes the ArrayCollection to it.
> 
> In the web service, the ArrayCollection is received as an array list
> of XmlNodes. Each XmlNode contains a node for each field, even if it
> is an empty string.
> 
> <tns:id xmlns:tns="http://tempuri. org/">808</tns:id>
> <tns:name xmlns:tns="http://tempuri. org/">bob</tns:name>
> 
> <tns:id xmlns:tns="http://tempuri. org/"></tns:id>
> <tns:name xmlns:tns="http://tempuri. org/">fred</tns: name>
> 
> Is this anything like what you're getting? The edge case you described
> in another email about an empty string causing problems doesn't seem
> to cause problems.
> 
> Also see inline.
> 
> 2009/7/3 Angelo Anolin <angelo_anolin@ yahoo.com>:
> > 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?
> 
> As you're using a dataset, this isn't really an option. A dataset as
> opposed to a collection of typed objects are two ways of handling data
> from data sources; it is arguable which way is better.
> 
> The problem in your case, is that the XML generated as a result of
> passing an ArrayCollection to a web service method cannot be passed
> into the dataset's readXml method. (Even if it could by inferring a
> schema, it would be different to your database's schema.)
> 
> The only way I know of to do seamless transfer of data without having
> to parse XML is to use WebORB. Otherwise you will have to parse the
> XML produced on both sides to re-create the dataset/object.
> 
> > 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?
> 
> I wonder if it is possible to bind your datagrid directly to the e4x
> XML? That way you can pass the entire XML doc back to .NET via the web
> service, and hence you can re-create the dataset using
> dataset.readXML.
> 
> > ____________ _________ _________ __
> > 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@ 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.lai@ gmail. com>
> >> To: flexcod...@yahoogro ups.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
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >>
> >
> >
> >
> >
>


Reply via email to