Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > .NET Web Services
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old June 17th, 2003, 08:23 PM
Registered User
Join Date: Jun 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Return Collection object from a Web Method

I would like to return a custom collection object from a web method.
I created my custom collection by inheriting CollectionBase and implementing strongly typed

Item, Add, Remove, Count, etc methods/properties. But when the result is serialized to XML

the collection is converted to a generic Array, which is not what I want.

Does anyone know how to return an actual custom collection from a Web Method?
Could you provide some sample code?

PS: I would prefer not to use a DataSet for this.
Old June 23rd, 2003, 10:12 PM
Registered User
Join Date: Jun 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to firdausnasar

You can very well use a class collection to be returned from the Web Method. All you need to do is to define a similar class at the Web Service Consumer application. Then you assign the returned class collection from the webservice to the Consumer Side instance of a similar class.

Best of Luck...
Old June 17th, 2006, 07:42 AM
Registered User
Join Date: Jun 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to syedAhamed Send a message via Yahoo to syedAhamed

Thank you for your suggestion firdausnasar,

But I would have tried that also, but still its returning as generic array.

Any other suggestion

Similar Threads
Thread Thread Starter Forum Replies Last Post
return collection by function in class jimusa Visual Basic 2005 Basics 1 July 30th, 2008 03:18 PM
function return collection in class by VB jimusa Visual Studio 2005 1 July 30th, 2008 03:12 PM
Return OleDb.OleDbConnection from the WEB method? Dmitriy Pro VB 6 2 May 4th, 2004 07:10 AM
Return DataTable from Web Method Function kasie ASP.NET 1.0 and 1.1 Basics 2 February 11th, 2004 06:23 AM
Object as parameter in a web service method evandro.paula .NET Web Services 3 October 14th, 2003 02:20 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.