By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,114 Members | 1,574 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,114 IT Pros & Developers. It's quick & easy.

retrieve arraylist returned from webservice

P: n/a
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.
--
Steve
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Opa
try casting the result
ArrayList arrResults = (ArrayList )ws.MyFunction(ar);

let me know if this helps

"SteveR" wrote:
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.
--
Steve

Nov 21 '05 #2

P: n/a

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/Resource...irst/default.h
tml
-----Original Message-----
From: SteveR [mailto:St****@discussions.microsoft.com]
Posted At: Wednesday, November 10, 2004 8:00 AM
Posted To: microsoft.public.dotnet.framework.webservices
Conversation: retrieve arraylist returned from webservice
Subject: retrieve arraylist returned from webservice

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. --
Steve


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.