Google

Monday, May 12, 2008

Return ArrayList from Web Service

Recently i have tried to return an ArrayList collection from a Web Service.I had to face lots of difficulties.
Whenever i tried to return an ArrayList from my simple web service i got an error saying
"Value of Type '1-dimensional array of Object cannot be converted to System.Collections.ArrayList".
I searched a lot on the internet but found nothing.Then I posted my problem to some forums.
One expert from one forum gave me the solution.and This really works fine for me.

So i m puting the solution here for others

Here is the method code of my simple web service.


_
_
Public Function Test() As ArrayList

Dim lst As New ArrayList

lst.Add("Abc")
lst.Add("bca")
lst.Add("ahy")
lst.Add("fkc")

Return lst

End Sub



and Below is a code for consuming web Service.

Dim ws As New localhost.Service

Dim aList As New ArrayList(ws.Test)

ListBox1.DataSource = aList

No comments: