Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error returning arraylist of objects
Message
From
18/09/2003 01:06:34
Keith Payne
Technical Marketing Solutions
Florida, United States
 
 
To
17/09/2003 11:58:14
Gary Otte
California Youth Authority
Sacramento, California, United States
General information
Forum:
ASP.NET
Category:
Web Services
Miscellaneous
Thread ID:
00829938
Message ID:
00830195
Views:
20
Gary,

You cannot return an ArrayList from an XML Web Service because it implements the ICollection interface. In this situation, it is probably best to return an array of Employee objects. You can do this easily with the ToArray() method of the ArrayList class.

The error that you are receiving is not the typical error that is thrown when trying to return an ArrayList, so you may have other problems as well. I am not familiar with a type specification that looks like "wsEmployee.EmpServices+Employee". Is the + sign part of the C# syntax for specifying a type? If it is not, you might have an issue with the Web Reference in the client project. Also, be sure to include the attribute in your class definition.

>I have defined a class called "Employee" in my web service that contains 3 instance variables: lastname, firstname and ssn. I have a web method that creates an arraylist of Employee objects. Stepping thru the debugger shows that the arraylist does indeed contain Employee objects as expected.
>
>However, returning this arraylist from the web method produces the following error:
>
>System.InvalidOperationException: There was an error generating the XML document. ---> System.InvalidOperationException: The type wsEmployee.EmpServices+Employee was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
>
>Reading the docs on XMLIncludeAttribute and SOAPIncludeAttribute just left me scratching my head.
>
>Thanks in advance for any comments to help solve this.
>
>Gary
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform