473,785 Members | 2,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Web Service Data Conversion Problem


In a web service I am using a SqlDataReader to retrieve the
information to populate an ArrayList.

public ArrayList ReadHistory(int ItemPK)
{
SDrdr = SDcmd.ExecuteRe ader();
ArrayList AL = new ArrayList();

while(SDrdr.Rea d())
{
AL.Add(SDrdr["name"]);
}
return AL;
}

The web service is called from another project.

public ArrayList ReadHistory(int ItemPK)
{
wsrKeyCodeServi ce.KeyCodeInfor mation WSR = new
wsrKeyCodeServi ce.KeyCodeInfor mation();
ArrayList AL =
WSR.ReadKeyCode History(Vehicle PK);
return AL;

The problem is when I build the project I get the following error.
Cannot implicitly convert type 'object[]' to
'System.Collect ions.ArrayList'

When I change the type from ArrayList to Array…

public Array ReadHistory(int ItemPK)
{
wsrKeyCodeServi ce.KeyCodeInfor mation WSR = new
wsrKeyCodeServi ce.KeyCodeInfor mation();
Array AL = WSR.ReadHistory (ItemPK);
return AL;
}
The error goes away.

Apparently when the ArrayList is sent from the web service it is
converted to an Array.

Questions

1. Why does it do this?
2. What do I need to do to get an ArrayList on the receiving side? I
need to be able to resize the array. An Array can't be resized, the
ArrayList can.

Thanks for the help.

Nov 16 '05 #1
2 4928
This is not a C# question but here goes anyway. Comments inline:

<xm******@yahoo .com> wrote in message
news:40******** ******@news.dsl extreme.com...

In a web service I am using a SqlDataReader to retrieve the
information to populate an ArrayList.

public ArrayList ReadHistory(int ItemPK)
{
SDrdr = SDcmd.ExecuteRe ader();
ArrayList AL = new ArrayList();

while(SDrdr.Rea d())
{
AL.Add(SDrdr["name"]);
}
return AL;
}

The web service is called from another project.

public ArrayList ReadHistory(int ItemPK)
{
wsrKeyCodeServi ce.KeyCodeInfor mation WSR = new
wsrKeyCodeServi ce.KeyCodeInfor mation();
ArrayList AL =
WSR.ReadKeyCode History(Vehicle PK);
return AL;

The problem is when I build the project I get the following error.
Cannot implicitly convert type 'object[]' to
'System.Collect ions.ArrayList'

When I change the type from ArrayList to Array.

public Array ReadHistory(int ItemPK)
{
wsrKeyCodeServi ce.KeyCodeInfor mation WSR = new
wsrKeyCodeServi ce.KeyCodeInfor mation();
Array AL = WSR.ReadHistory (ItemPK);
return AL;
}
The error goes away.

Apparently when the ArrayList is sent from the web service it is
converted to an Array.

Questions

1. Why does it do this?
Whatever you return from a WebMethod needs to be serializable to SOAP. The
type ArrayList is not serializable to SOAP so it gets converted to an array
of objects (object[]) which is SOAP serializable (provided the objects in
the array are SOAP serializable).
2. What do I need to do to get an ArrayList on the receiving side? I
need to be able to resize the array. An Array can't be resized, the
ArrayList can.


ArrayList al = new ArrayList(WSR.R eadHistory(Item PK));

Regards,
Sami


Nov 16 '05 #2
Thank you. That solved it. :)

On Fri, 11 Jun 2004 17:07:51 +0300, "Sami Vaaraniemi"
<sa**********@p leasejippii.fi> wrote:
This is not a C# question but here goes anyway. Comments inline:

<xm******@yaho o.com> wrote in message
news:40******* *******@news.ds lextreme.com...

In a web service I am using a SqlDataReader to retrieve the
information to populate an ArrayList.

public ArrayList ReadHistory(int ItemPK)
{
SDrdr = SDcmd.ExecuteRe ader();
ArrayList AL = new ArrayList();

while(SDrdr.Rea d())
{
AL.Add(SDrdr["name"]);
}
return AL;
}

The web service is called from another project.

public ArrayList ReadHistory(int ItemPK)
{
wsrKeyCodeServi ce.KeyCodeInfor mation WSR = new
wsrKeyCodeServi ce.KeyCodeInfor mation();
ArrayList AL =
WSR.ReadKeyCode History(Vehicle PK);
return AL;

The problem is when I build the project I get the following error.
Cannot implicitly convert type 'object[]' to
'System.Collect ions.ArrayList'

When I change the type from ArrayList to Array.

public Array ReadHistory(int ItemPK)
{
wsrKeyCodeServi ce.KeyCodeInfor mation WSR = new
wsrKeyCodeServi ce.KeyCodeInfor mation();
Array AL = WSR.ReadHistory (ItemPK);
return AL;
}
The error goes away.

Apparently when the ArrayList is sent from the web service it is
converted to an Array.

Questions

1. Why does it do this?


Whatever you return from a WebMethod needs to be serializable to SOAP. The
type ArrayList is not serializable to SOAP so it gets converted to an array
of objects (object[]) which is SOAP serializable (provided the objects in
the array are SOAP serializable).
2. What do I need to do to get an ArrayList on the receiving side? I
need to be able to resize the array. An Array can't be resized, the
ArrayList can.


ArrayList al = new ArrayList(WSR.R eadHistory(Item PK));

Regards,
Sami


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1539
by: John P. Looney | last post by:
Yesterday, I installed service pack 4 + the latest hotfixes on some of my webservers. They run different websites, run by different people. The problem that all four developed was that any date comparisons fail. It turns out that no matter what the regional settings are (they should be 'english(ireland)'), it returns american date formats, which break some of the comparisons.
0
1585
by: Stephan Lux | last post by:
Hi all, I have developed a windows service with Visual Basic .NET which starts a file conversion tool via the commandline. The tool open the files (z.B. Word, Excel, Acrobat...) and prints them over an image printer driver to tiff-files. On my Windows XP client it works fine, but on the target system (Windows 2003 Server) some issues occured: My first release uses the framework process class to start the application. As a standalone...
1
7939
by: M DL via .NET 247 | last post by:
Hi all, i have one problem with a method of an xml web service that use a datetime data type input variable, and may be all is caused by international settings. The XML web service (localized in italy, with italian settings) have the following method: MYXWS.MyMethod(input_var as datetime) On my dev machine (localized in italy, with italian settings) i have created a web application that use the proxy class for call the XML wer...
1
1488
by: Prashant | last post by:
We have an ATL COM server developed with VC++ 6.0 which acts a a server . Then we have VB6 modules Acting as clients and interfacing with the server . We want to migrate the ATL COM server to .Net platform and host it as a web service . The client modules
0
1794
by: pumaken68 | last post by:
Does anyone has experience with calling web service from pocket pc 2003 project in VS 2005 environment? I just migrated a smart device(pocket pc 2003) solution from VS 2003 to VS 2005. There are 3 projects inside solution: 1. pocket PC 2003 windows form project; 2. Business rules 3. a web service which will be used to download and upload data via wireless from/to backend database. After converted and built successfully, the web service...
0
2191
by: pwilliams | last post by:
NCOALink Change of Address Verification Each year over 40 million Americans change their mailing addresses. This change is equivalent to every person in California deciding to change addresses and not tell you that they have moved. This uncertainty results in wasted spending on undeliverable address mail, returned mail and processing fees related to direct mail campaigns. NCOALink solves this problem for you. NCOALink provides you...
2
2260
by: shyam | last post by:
I have a C++ COM based windows service which have more than 30k lines of code and which is stablized over years. We need to take the advantage of the ..NET framework for this project, especially the GUI for this service and the other windows non gui .NET clients. What's the best migaration pattern for us considering not to rewrite the thousands of lines of code. The question i have are the follows.
0
1149
by: iw3arv | last post by:
Hello, I've, probably, a simple problem but I'm not able to figure the solution!!! I've realized a web service method that reads an Excel sheet and convert the information in xml. This conversion is time consuming and I've the idea to spilt the web service in 3 metods: "Xls2Xml" that converts the files, generate the xml and store it in the
7
3830
by: Rick | last post by:
I have a web service that I converted from VS 2003 Framework 1.1. to VS 2005 Framework 2.0. I tried to use the same IIS web site to run the web service. I deleted the Framework 1.1 files published the 2.0 files changed IIS to use Framework 2.0 and changed the application pool, also restarted IIS. When I try to get to the web service it tells me the file cannot be found. The web service file(asmx) is in the same place and named the same. The...
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
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
10357
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
10162
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...
1
10101
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7509
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...
1
4063
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 we have to send another system
2
3665
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.