still having problem return arraylist of objects in webservice....

M

Milsnips

hi there,

i have a webservice which my function calls a database( eg. customer table),
what i have is my own Customer class, and i want to return an array of my
"Customer" objects.

here is my code i use (c.GetList returns an arraylist of customer objects
from the database:


<WebMethod()> _
Function GetClientList() As <XmlElement(GetType(getAway.Client))> ArrayList
Dim c As New getAway.Client
Dim a As ArrayList = c.GetList(False)
Return a
End Function

i still get the same error below:

System.InvalidOperationException: There was an error generating the XML
document. ---> System.InvalidOperationException: The type getAway.Client was
not expected. Use the XmlInclude or SoapInclude attribute to specify types
that are not known statically.

any help appreciated...

Paul.
 
D

Dino Chiesa [Microsoft]

use XmlInclude or
XmlArray and XmlArrayItem attributes to specify that type. eg


<XmlArrayItem(ElementName := "item", Type:= GetType(getAway.Client)) , _
XmlArray(ElementName := "stuff")> _
 
S

Surya Yadav

I am ruuning into a similar problem. Even XmlInclude does
not seem to work.
My webservice method ( calls Author.GetAuthors() to build
and return an IList of authors.
The webservice method is defined as:
[WebMethod]
public IList GetAllAuthors()
{
Author author=new Author();
return author.GetAuthors();
The Author class is defined in a separate class library
called AuthPubsDAL. Author.GetAuthors() is defined as
public IList GetAuthors()
{
...}
which accesses the pubs database and builds an arraylist
of author objects.

I added [XmlInclude (typeof(Author))] to the webservice
class, to the Author class and to the WebMethod
GetAllAuthors() which is part of the webservice class
with no luck. I am not sure as to what's the proper use
of XmlInclude and where it should be added. Please help.

Surya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top