I want to return an ArrayList from my web service. I can write this part and
everything compiles but I can't get the web application that uses the web
service to compile. I call the service aynchronously so then in my code I
have this to retrieve the ArrayList object.
public void CalcCallback(IAsyncResult ar)
{
ArrayList arrResults = ws.MyFunction(ar);
}
If I try to compile this I get an error
Cannot implicitly convert type 'object[]' to 'System.Collections.ArrayList'
Any idea how I can fix this? I found a sample web service on MDSN that
returned an ArrayList but it doesn't include the client app to go with it.

Signature
Steve
Opa - 10 Nov 2004 14:09 GMT
try casting the result
ArrayList arrResults = (ArrayList )ws.MyFunction(ar);
let me know if this helps
> I want to return an ArrayList from my web service. I can write this part and
> everything compiles but I can't get the web application that uses the web
[quoted text clipped - 12 lines]
> Any idea how I can fix this? I found a sample web service on MDSN that
> returned an ArrayList but it doesn't include the client app to go with it.
Christoph Schittko [MVP] - 10 Nov 2004 15:20 GMT
If you look at the proxy code generated by Visual Studio or the WSDL,
you'll see that the Web service simply returns an array of objects. You
are not mentioning about adding attributes to declare the types found in
the ArrayList, which you need to do via attaching XmlElement attributes
on the return value if the return type is actually ArrayList
[WebMethod]
[return: XmlElement( typeof(arrayItemType ) )]
public ArrayList GetArrayList()
{
// ...
}
You may want to check out Christian Weyer's Contract First tool [0] to
generate the proxy code. Maybe it helps in your scenario.
Christoph
[0]
http://www.thinktecture.com/Resources/Software/WSContractFirst/default.h
tml
> -----Original Message-----
> From: SteveR [mailto:SteveR@discussions.microsoft.com]
[quoted text clipped - 23 lines]
> --
> Steve