473,659 Members | 2,965 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(IA syncResult ar)
{
ArrayList arrResults = ws.MyFunction(a r);
}

If I try to compile this I get an error

Cannot implicitly convert type 'object[]' to 'System.Collect ions.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
2 9975
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(IA syncResult ar)
{
ArrayList arrResults = ws.MyFunction(a r);
}

If I try to compile this I get an error

Cannot implicitly convert type 'object[]' to 'System.Collect ions.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

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(arrayIte mType ) )]
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****@d iscussions.micr osoft.com]
Posted At: Wednesday, November 10, 2004 8:00 AM
Posted To: microsoft.publi c.dotnet.framew ork.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(IA syncResult ar)
{
ArrayList arrResults = ws.MyFunction(a r);
}

If I try to compile this I get an error

Cannot implicitly convert type 'object[]' to
'System.Collect ions.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4614
by: Jamus Sprinson | last post by:
Before I continue, I'm going to begin by saying I'm not by any means an expert- I've been using .NET with C# for about 4 months now, and basically just learning by example and docs. A game project I work on uses Xml serialization to store game objects for loading. One of the techniques we use is to make an array property and use the set block to perform actions on the values after they're loaded from the xml, as in: public string Ids
5
10950
by: Pete Hearn | last post by:
Hello All, New to the whole C#/Webservice/ADO.NET thing, so apologies in advance if this is a daft question! I have a webservice which returns a dataset - no problem there and all very standard. However, I want to pass an arraylist of objects to the method which returns the dataset (the arraylist contains QBE parameter objects) but the compiler chokes saying it wants an object array instead.
5
7203
by: GeRmIc | last post by:
Hi, I am doing an interop from unmanaged code to C#. How do i pass an ArrayList pointer from an unmanaged code, (structres are easily passed by between C# and C). //This is the C code NameStruct lnames; //This is a structure in C#
1
2388
by: JPSutor | last post by:
I am trying to pass back an ArrayList from a WebService to a windows application. The app barks at me saying this is an ilegal operation. Any hints or sample code out there?
1
3201
by: Ankita | last post by:
Hi I have a webservice which has 2 webmethods: 1.One that returns a String 2.One that returns an ArrayLis I need to use this WebService in VBA environment. I am using the Webservices References Tool 2.0 for accessing this Webservice. I've added the WebService and I'm able to get the string returned from the first web method. But I'm getting error when trying to access the webmethod which returns an arraylist I found this Microsoft Web...
0
1672
by: Grant Wickman | last post by:
Our team has just fixed a really nasty problem that appears to be caused by an obscure bug in the sort method of Arraylist and daisy-chained webservice stubs. We've fixed the bug so I'll not investigate any further but there was nothing about it when googling the newsgroups so I am posting a note in case it helps somebody else out. The problem was in a system with a web front end calling through to a chain of 3 webservices i.e.
0
3432
by: Steven | last post by:
I'm having trouble using an arraylist of a custom object as an argument in a webservice, everything is in VB.Net. Visual Studio I can pass the custom object as an argument to other webmethods fine, and can return it fine. I can have the webservice return an arraylist of the objects and consume them with no dramas. But whenever I call the method it gives this error, failing on the call, before it actually goes 'into' the function. "The...
5
1402
by: Eveready | last post by:
I have a webservice that needs to return a paired list, such as created by an arraylist. The problem appears to be in serlizing the xml. Any help on how to return a paired list or arraylist would be gratly appreciated. ***********code <WebMethod()> _ Public Function getMyData() As ArrayList Dim lvSqlString = "SELECT * FROM PRODUCTS" Dim myData As New ArrayList
8
4395
by: amazon | last post by:
I have a following structure that I am using with array list: Private Structure arrayliststruct Public Name As String Public value As String Public type As String End Structure and following function to format arraylist the way I want and calling it from button click event: Private Function formatarray(ByVal inarray As ArrayList, _
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8747
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.