Delivering Collections via Web Service [with ASMX]

Topics: General Discussion Forum, July and December Releases Forum
Apr 19, 2007 at 2:52 PM
In a previous post I saw that it's easy to specify
I want a collection of a DataObject as property, provided
you're working with WCF...
After having done a couple of days of work with the ASMX
version I'm a bit stuck now, any quick example/tip on how
I can correctly do that in ASMX?

Apr 19, 2007 at 6:09 PM
You cannot create collection types with the ASMX package the same way that you do with WCF. However, you may specify a collection type for that property and in this case, it might be a generic collection with your custom item type, like System.Collections.Generic.IList<MyType> or the like.
Apr 20, 2007 at 9:50 AM
I understood that the asmx package didn't include that opportunity,
you confirmed to me what I thought... just go and change the code.

I was wondering if the serialization/deserialization could have had
any problem doing that, I tried it this morning and could confirm
that it seems to work (I'm able to expose service and see the function
parameters) but you have to use List<...> and not IList<...> otherwise
the service is exposed but when you try to see its functions you get
an error stating that (someone) cannot serialize an interface.

Apr 20, 2007 at 11:56 AM
Right, you should use List or any other implemented class. Nevertheless, when I said that you may specify the generic collection type, that was in the page wizard "Type" column so you don't need to do it "by hand" in the generated code. Just wanted to put it clear.