473,657 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Returning an ArrayList of Custom Objects From a Web Service

I have a current requirement to all a subsidiary to use a current legacy
application and interface with my new system to inject data when appropriate.
I wanted to create a web service since we are both .Net shops and this would
seem to be the easiest method. But I ran into one snafu. I wanted to return
to the subsidiary an ArrayList of my Organization objects which contain the
orgs id, name etc. so they can use that information in the data insert call.

I have done a lot of looking around but have not found the answer yet to
accomplish this. Here is some of the code:

1. Web service calls an object manager which returns the ArrayList:
1. ArrayList _array = ObjectManager.I nstance.GetAllO rgs();
2. Object manager calls the object data store returning ArrayList
1. ObjectStore.Ins tance.GetAllOrg s();
3. Object store makes database call, passes reader to method that loops
over results building an Org object and adding it to an array.:
1. public ArrayList GetAllOrgs()
{
ArrayList orgs = new ArrayList();

using (SqlConnection connection = new
SqlConnection(_ connectionStrin g))
{
connection.Open ();

SqlCommand command = new SqlCommand();

command.Connect ion = connection;
command.Command Type = CommandType.Sto redProcedure;
command.Command Text = "usp_GetOrg s";

SqlDataReader reader =
command.Execute Reader(CommandB ehavior.SingleR esult);

orgs = CreateOrgs(read er);

}

return orgs;
}

That is my issue in a nutshell - my web page that consumes the web service
does not know how to cope with the ArrayList with Org objects in it.

Any help would be much appreciated!
SharePoint Tips and Tricks
http://drewmace.blogspot.com
Jan 16 '08 #1
2 2625
=?Utf-8?B?RHJldw==?= <Dr**@discussio ns.microsoft.co mwrote in
news:69******** *************** ***********@mic rosoft.com:
That is my issue in a nutshell - my web page that consumes the web
service does not know how to cope with the ArrayList with Org objects
in it.
Try using a basic array, rather than an ArrayList.

--
sp**********@ro gers.com (Do not e-mail)
Jan 16 '08 #2
use the following attributes for your webmethod

[XmlInclude(type of(ArrayList))]
[XmlInclude(type of(Org))]

--
Misbah Arefin

"Spam Catcher" wrote:
=?Utf-8?B?RHJldw==?= <Dr**@discussio ns.microsoft.co mwrote in
news:69******** *************** ***********@mic rosoft.com:
That is my issue in a nutshell - my web page that consumes the web
service does not know how to cope with the ArrayList with Org objects
in it.

Try using a basic array, rather than an ArrayList.

--
sp**********@ro gers.com (Do not e-mail)
Jan 17 '08 #3

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

Similar topics

0
2480
by: Omer | last post by:
Hi All, We are trying to invoke EJB methods on simple stateless session beans from an Applet running remotely. One of our methods needs to return an ArrayList of Serializable objects. We have encoutered the following error: (please see end of post for stack trace). Some research has yielded the fact that even though the ArrayList
1
2573
by: Ed. | last post by:
I have an ArrayList of objects of class C. I need to return the list via a web method. What's the best approach? If I convert the list into a DataSet I could return the DataSet, but how would I do that? Do I need to create a strongly typed DataSet from my class C? Thanks.
1
7267
by: Knecke | last post by:
Hi all. I have a problem with returning a custom Result object with webservice. The classes i use is described below (some fields and properties is removed) public class Result { int statusCode;
18
4727
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the class where only the "searched" property has a value. I expected to get the index into the arraylist where I could then get the entire class instance. However, the 'indexof' is never calling my overloaded, overrides Equals method. Here is the...
12
5323
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded the custom employee class and have built it as a separate library (employee.dll). This employee.dll is being referenced by both the web service and the windows application. I face the following problem when I send this class to the webservice.
1
2062
by: Matthias De Ridder | last post by:
Hello, I really hope that someone will be able to help me, because I'm desperate now! I'm a student, graduating this year, and I'm working on a thesis where C# Web Services are involved. I only have three weeks to finish it all! My GUI and Web services were finished, but I hadn't tested them. So I linked the GUI to the Web service and started testing them.
5
19581
by: Stacey Levine | last post by:
I have a webservice that I wanted to return an ArrayList..Well the service compiles and runs when I have the output defined as ArrayList, but the WSDL defines the output as an Object so I was having a problem in the calling program. I searched online and found suggestions that I return an Array instead so I modified my code (below) to return an Array instead of an ArrayList. Now I get the message when I try to run just my webservice...
4
1940
by: =?Utf-8?B?a2lzaG9y?= | last post by:
Hi, has any one used webservices for returning custom objects other than datasets like custom classes and their internal classes ?. What problems you have faced if any ? is there any limitation ? what are advantages and disadvantages.. please let me know Kishor
2
2128
by: shredder249 | last post by:
Hi, I have one class called Track and another class called TrackList. TrackList is an ArrayList made up of Track objects. I can add Track objects to a TrackList but I cannot retrieve them as actual Track objects from the ArrayList, I can only retrieve them as generic objects. This means that I cannot use any methods from the Track class on them. How can I get Tracks out of a TrackList as actual Track objects? Cheers
0
8826
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
8732
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
8503
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
8605
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...
0
5632
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
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
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
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.