[RESOLVED] ArrayList - Passed over a web service
I'm writing a simple little web service.
Here are two functions from it:
VB Code:
<WebMethod()> _
Public Function addTwoNums(ByVal numOne As Integer, ByVal numTwo As Integer) As Long
addTwoNums = numOne + numTwo
Return addTwoNums
End Function
<WebMethod()> _
Public Function yadda() As ArrayList
yadda = New ArrayList
Dim str As String
str = "one"
yadda.Add(str)
str = "two"
yadda.Add(str)
Return yadda
End Function
On the other end I can use the addTwoNums() function fine.
But when I want to get the ArrayList from the service, I get an errors.
Here is the basic error.
Quote:
Error 1 Value of type '1-dimensional array of Object' cannot be converted to 'System.Collections.ArrayList'.
Here is my code to suck down the arrayList()
VB Code:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim result As ArrayList
result = thisServ.yadda()
End Sub
I guess the arrayList is converted to a system.object when it is being consumed?? Can I not cast it back into an arrayList so I can run through the items returned??
I've tried CType over and over to no avail. :(
I'm wanting to get a list of data from the web service with one function call rather than have to create a function for each element of the service.
Re: ArrayList - Passed over a web service
If the ArrayList is indeed converted to an Object array then you can't cast it back. If you want an ArrayList you'd have to do something like this:
VB Code:
Dim result As New ArrayList
result.AddRange(thisServ.yadda())
Re: ArrayList - Passed over a web service
That was it. Perfect.
Thanks.