Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / November 2004

Tip: Looking for answers? Try searching our database.

retrieve arraylist returned from webservice

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
SteveR - 10 Nov 2004 14:00 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.