469,627 Members | 936 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,627 developers. It's quick & easy.

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.Instance.GetAllOrgs();
2. Object manager calls the object data store returning ArrayList
1. ObjectStore.Instance.GetAllOrgs();
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(_connectionString))
{
connection.Open();

SqlCommand command = new SqlCommand();

command.Connection = connection;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "usp_GetOrgs";

SqlDataReader reader =
command.ExecuteReader(CommandBehavior.SingleResult );

orgs = CreateOrgs(reader);

}

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 2439
=?Utf-8?B?RHJldw==?= <Dr**@discussions.microsoft.comwrote in
news:69**********************************@microsof t.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**********@rogers.com (Do not e-mail)
Jan 16 '08 #2
use the following attributes for your webmethod

[XmlInclude(typeof(ArrayList))]
[XmlInclude(typeof(Org))]

--
Misbah Arefin

"Spam Catcher" wrote:
=?Utf-8?B?RHJldw==?= <Dr**@discussions.microsoft.comwrote in
news:69**********************************@microsof t.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**********@rogers.com (Do not e-mail)
Jan 17 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Omer | last post: by
1 post views Thread by Matthias De Ridder | last post: by
4 posts views Thread by =?Utf-8?B?a2lzaG9y?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.