Last post Aug 22, 2008 06:33 PM by rjbdetroit
Aug 21, 2008 05:02 PM|rjbdetroit|LINK
I'm at a total loss on this one. Sure hope someone can help...
I have a web service that returns a custom object which contains an array of custom objects. When I access the .asmx file, I get the error in the subject.
The code below shows that Class FileDataCollection defines the property as an Array. I used to define the property as an ArrayList but read everywhere that you can't use a type ArrayList with web services because it can't serialize, so I changed everything
around to use Array instead. But I'm still getting the error. Does anyone know what I'm doing wrong here? Any help REALLY appreciated... Thanks.
<bunch of funcitons that deals with the ArrayList...>
<few more Private variables>
m_ID = value
<few more properties>
<Implement functions CompareTo, Equals, and Compare so I can easily manipulate the items in the ArrayList - IS THIS CAUSING THE PROBLEM??>
Aug 21, 2008 06:04 PM|mrmercury|LINK
It would mean changing you code again, but generics could do the trick: using List<FileDataItem> should do the work.
Aug 22, 2008 12:21 PM|rjbdetroit|LINK
mr - Thanks for the info! Do you have a link to description/samples of how to use "generics". I'm not familiar with it and searchingon .NET list yields dropdownlist, and the like...
maipulate/display items. So, I still need it to be a web method to be accessed from within the same project, but I don't necessarily want it available externally and, if possible, exclude it from the .asmx file (i.e. exclude it when using wsdl.exe to create
the .wsdl file). Is this possible? Is there a way to define the web method so it's excluded when you browse to the .asmx file, and not accessible outside the project?
Aug 22, 2008 02:11 PM|mrmercury|LINK
Generics allow you to create strong type collections of objects, List(T) is the generics equivalent to ArrayList, the important part here is that you can serialize
List(T) so you can use it as the return value of your webmethod.
check this link:
Aug 22, 2008 06:33 PM|rjbdetroit|LINK
mr - Thanks!! That was it. I greatly appreciate your help!
For other's reference, I just changed ArrayList and Array references to List(Of ListDataItem) and some minor tweeks elsewhere in my code, and all worked great!