473,505 Members | 15,212 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(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
2 9966
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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4603
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...
5
10943
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...
5
7196
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 ...
1
2381
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
3194
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...
0
1663
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...
0
3423
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...
5
1390
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...
8
4390
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...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7303
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,...
0
7367
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...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5028
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...
0
3187
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...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
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.