Question about methodology for Gurus

J

JR

Hi,

I have a question about the best method to return sql records through a web
service.

I will potentially be sending back anywhere from one to a thousand records
from a sql call through a webmethod. I would like some advice on the "Best"
way to send the data to the client. Right now I am filling a dataset from
the sql call, writing the xml to an xmlwriter object, then converting that
to a string which I then return to the client.

Would it be better to send back a collection or custom object or is there
another approach that I'm missing? I would like to keep this as scalable as
possible so I would like to avoid using datasets and such.


Thanks in advance,
Jamie
 
J

Jan Tielens

If you want to avoid a DataSet, I would recommend using custom objects in a
collection. Ofcourse this will be somehow a performance degradation, like
you have now when you serialize your DataSet to a string. Using custom
objects you get the advantage that you are working with types, instead of a
long string with xml in it. Ofcourse xml in string format is the most
flexible solution, so it's always the choice between flexibility and
ease-of-use.

If your concern is interoperability (e.g. communication with java clients),
the custom objects won't raise any issues. I've succesfully implemented such
a solution without any problems regarding the communication between .NET and
Java.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 
J

JR

Great info, thanks for the advise Jan.


Jan Tielens said:
If you want to avoid a DataSet, I would recommend using custom objects in a
collection. Ofcourse this will be somehow a performance degradation, like
you have now when you serialize your DataSet to a string. Using custom
objects you get the advantage that you are working with types, instead of a
long string with xml in it. Ofcourse xml in string format is the most
flexible solution, so it's always the choice between flexibility and
ease-of-use.

If your concern is interoperability (e.g. communication with java clients),
the custom objects won't raise any issues. I've succesfully implemented such
a solution without any problems regarding the communication between .NET and
Java.

--
Greetz

Jan Tielens
________________________________
Read my weblog: http://weblogs.asp.net/jan
 
D

Dino Chiesa [Microsoft]

If you want the table metaphor, you can also do something like

[WebMethod(Description="returns an XmlNode derived from a DataSet. This
form excludes schema info. ")]
public System.Xml.XmlNode GetDataSet_XmlDoc(int orderId) {
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
System.Data.DataSet ds= Service(orderId);
doc.LoadXml(ds.GetXml());
return doc;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top