Hi Bala,
There's other reasons why returning a DataSet from a web service is bad
- I think Scott Hanselman puts it very well in this article where he
compares a dataset to a fruitbowl when what you really should be
returning is the fruit:
http://www.hanselman.com/blog/Return...nTheWorld.aspx
So you want a .NET object that represents the data item that you return
from your webservice... let's pretend it's all the cars in your
showroom - your code may look something like this (note, this sample
uses .NET 2.0 generic collections but the same can be achieved in .NET
1.x).
using System.Collection.ObjectModel;
[WebMethod]
public ShowRoom GetShowRoom()
{
// call into a business component that calls the DAL and populates
a ShowRoom object with
// with all the cars from the DB. Simply loop through the
datareader [or dataset :( ] and create
// the objects as you go.
}
[XmlRoot("showRoom")]
public class ShowRoom
{
[XmlArray("cars"), XmlArrayItem("car")]
public Collection<Car> Cars;
}
public class Car
{
[XmlElement("manufacturer")]
public string Manufacturer;
[XmlElement("engineSize")]
public int EngineSize;
[XmlElement("color")]
public string Color;
// ... you get the idea!
}
This will generate a beautiful WSDL that will interoperate well and
generate an intuitive schema.
Finally, you could try dropping the DataSet approach and use a quick
forward-only datareader to generate your domain objects - here's a
great article on 4guys about DataSets vs DataReaders in ASP.NET:
http://aspnet.4guysfromrolla.com/articles/050405-1.aspx
Hope that all helps
Josh
http://www.thejoyofcode.com/