473,795 Members | 3,386 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best Practices

I have a DataSet with relations and other constraints being populated from
the backend (SQL Server 2005). I use DataSet.FillSch ema to retrieve the
table schema for each table in the dataset. I then create the appropriate
relations between the tables. I will use a webmethod with a return type of
either XmlNode or DataSet to return the data and the schema? Each call to
the webmethod will return the data and the schema.

Question:

1. Does this scheme seem to follow best practices?
2. The data, the table schema and the relations are all defined via 1
method. Should this be broken up into 2 methods? GetSchema() & GetData(int
ID).
3. Is there an advantage to wrapping the data in a mapped class and then
serializing the class or does providing the dataset schema accomplish the
same thing thing (typed data)?
4. For this scenario, is there a preferable return type or will either
DataSet or XmlNode be okay?

Sample xml returned from Webmothod:

<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns="http://www.somedataset .com/ws/test.xml">
<xs:schema id="PersonDataS et" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="PersonDat aSet" msdata:IsDataSe t="true"
msdata:UseCurre ntLocale="true" >
<xs:complexType >
<xs:choice minOccurs="0" maxOccurs="unbo unded">
<xs:element name="Entity">
<xs:complexType >
<xs:sequence>
<xs:element name="EntityID" msdata:ReadOnly ="true"
msdata:AutoIncr ement="true" msdata:AutoIncr ementSeed="-1"
msdata:AutoIncr ementStep="-1" type="xs:int" />
<xs:element name="EntityTyp eID" type="xs:int" minOccurs="0" />
<xs:element name="ParentEnt ityID" type="xs:int"
minOccurs="0" />
<xs:element name="EntitySta tusID" type="xs:int"
minOccurs="0" />
<xs:element name="UpdatedBy ID" type="xs:int" />
<xs:element name="UpdatedDa te" type="xs:dateTi me" />
<xs:element name="RecordIsA ctive" type="xs:boolea n"
default="true" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Person">
<xs:complexType >
<xs:sequence>
Nov 6 '06 #1
2 2300
I think the manner in which you populate a dataset is irrelevant - that is
the service consumer is only concerned with "how" to get data from the
webservice, and not so much how the service will go about fullfilling that
request.

That being said, there's debate over the "return dataset from webservice"
topic - http://www.theserverside.net/tt/arti...Top5WSMistakes

I think the notion of a WebMethod signature with a DataSet as a return type
does little to offer semantic meaning to the service. That is, I believe the
following:

[WebMethod]
public DataSet GetEmployees(){ }

is semantically different than:

[WebMethod]
public GetEmployeesRes ponse GetEmployees()
{
DataSet emps = _db.GetEmployee s();
GetEmployeesRes ponse resp = new GetEmployeesRes ponse();
emp.Employees = _empMapper.ToEm ployeeType(emps );
return resp;
}

On the wire, the GetEmployeesRes ponse message is self describing versus a
message containing an array of Employee objects.

Here is some more opinion on the subject:

http://www.lhotka.net/WeBlog/Thought...bServices.aspx

Code to map a dataset to a "message" is not a whole lot of fun to write,
even for a single-tabled dataset it can be tedious.

If you can consider a redesign of the service, the following might be
useful.

http://www.thinktecture.com/Resource...kthrough1.html

There you can download the WSCF tool and the walkthrough is an excellent
starting point for getting into "contract-first" development of web
services.

Ron

"Eddie" <Ed***@discussi ons.microsoft.c omwrote in message
news:88******** *************** ***********@mic rosoft.com...
>I have a DataSet with relations and other constraints being populated from
the backend (SQL Server 2005). I use DataSet.FillSch ema to retrieve the
table schema for each table in the dataset. I then create the appropriate
relations between the tables. I will use a webmethod with a return type
of
either XmlNode or DataSet to return the data and the schema? Each call to
the webmethod will return the data and the schema.

Question:

1. Does this scheme seem to follow best practices?
2. The data, the table schema and the relations are all defined via 1
method. Should this be broken up into 2 methods? GetSchema() &
GetData(int
ID).
3. Is there an advantage to wrapping the data in a mapped class and then
serializing the class or does providing the dataset schema accomplish the
same thing thing (typed data)?
4. For this scenario, is there a preferable return type or will either
DataSet or XmlNode be okay?

Sample xml returned from Webmothod:

<?xml version="1.0" encoding="utf-8"?>
<DataSet xmlns="http://www.somedataset .com/ws/test.xml">
<xs:schema id="PersonDataS et" xmlns=""
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata">
<xs:element name="PersonDat aSet" msdata:IsDataSe t="true"
msdata:UseCurre ntLocale="true" >
<xs:complexType >
<xs:choice minOccurs="0" maxOccurs="unbo unded">
<xs:element name="Entity">
<xs:complexType >
<xs:sequence>
<xs:element name="EntityID" msdata:ReadOnly ="true"
msdata:AutoIncr ement="true" msdata:AutoIncr ementSeed="-1"
msdata:AutoIncr ementStep="-1" type="xs:int" />
<xs:element name="EntityTyp eID" type="xs:int" minOccurs="0"
/>
<xs:element name="ParentEnt ityID" type="xs:int"
minOccurs="0" />
<xs:element name="EntitySta tusID" type="xs:int"
minOccurs="0" />
<xs:element name="UpdatedBy ID" type="xs:int" />
<xs:element name="UpdatedDa te" type="xs:dateTi me" />
<xs:element name="RecordIsA ctive" type="xs:boolea n"
default="true" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Person">
<xs:complexType >
<xs:sequence>
.
.
.
.
.

<xs:unique name="Constrain t1" msdata:PrimaryK ey="true">
<xs:selector xpath=".//Entity" />
<xs:field xpath="EntityID " />
</xs:unique>
<xs:unique name="Person_Co nstraint1"
msdata:Constrai ntName="Constra int1" msdata:PrimaryK ey="true">
<xs:selector xpath=".//Person" />
<xs:field xpath="PersonID " />
</xs:unique>

.
.
.
.
.
.

<diffgr:diffgra m xmlns:msdata="u rn:schemas-microsoft-com:xml-msdata"
xmlns:diffgr="u rn:schemas-microsoft-com:xml-diffgram-v1">
<PersonDataSe t xmlns="">
<Entity diffgr:id="Enti ty1" msdata:rowOrder ="0">
<EntityID>10000 </EntityID>
<EntityTypeID>1 000</EntityTypeID>
<UpdatedByID>22 222</UpdatedByID>
<UpdatedDate>20 06-11-02T07:54:45.873-06:00</UpdatedDate>
<RecordIsActive >true</RecordIsActive>
</Entity>

Nov 6 '06 #2
"Eddie" <Ed***@discussi ons.microsoft.c omwrote in message
news:88******** *************** ***********@mic rosoft.com...
>I have a DataSet with relations and other constraints being populated from
the backend (SQL Server 2005). I use DataSet.FillSch ema to retrieve the
table schema for each table in the dataset. I then create the appropriate
relations between the tables. I will use a webmethod with a return type
of
either XmlNode or DataSet to return the data and the schema? Each call to
the webmethod will return the data and the schema.

Question:

1. Does this scheme seem to follow best practices?
No.
2. The data, the table schema and the relations are all defined via 1
method. Should this be broken up into 2 methods? GetSchema() &
GetData(int
ID).
3. Is there an advantage to wrapping the data in a mapped class and then
serializing the class or does providing the dataset schema accomplish the
same thing thing (typed data)?
What do you expect your clients to do with the schema? Load it into a
DataSet? That might work if they're all .NET clients.
4. For this scenario, is there a preferable return type or will either
DataSet or XmlNode be okay?
It would be preferable if you kept platform-specific data types out of your
web service contract. That way, your web service could be used by any client
you can think of, and many more that you've never heard of, nor ever will
hear of. Instead, define the structure of your data using a schema. Include
that schema in your WSDL. Transform your data into that format however you
like, and return it as an XmlNode (or XmlElement), using the appropriate
attributes to indicate the local name and namespace of the element you're
returning.
John
Nov 7 '06 #3

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

Similar topics

2
1974
by: byrocat | last post by:
I'm chasing after a documetn that was available on one of the Microsoft websites that was titled somethign like "MS SQL Server Best Practices" and detailed a nyumber of best practices about securing the server. Included in this was revoking public access to the system table objects. Can someone post the URL where I can pick this up, or drop me a note on contacting them for a copy of the document?
136
9460
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
13
2285
by: john doe | last post by:
A quick question, about so-called 'best practices', I'm interested in which of A/B of the two examples people would choose, and why. public enum MyEnum { Option1 = 0, Option2 = 1, Option3 = 2, Option4 = 3
1
1416
by: | last post by:
Hi can someone send or point me to Any nice Material on .NET Best Practices -regards
2
1830
by: Amelyan | last post by:
Could anyone recommend a book (or a web site) that defines best practices in ASP.NET application development? E.g. 1) Precede your control id's with type of control btnSubmit, txtName, etc. 2) Group relevant .aspx files into subfolders within your project etc.
4
1849
by: Luis Esteban Valencia | last post by:
Hello. Can somebody recomend me books of design patterns in c# and best practices too.
10
3484
by: jojobar | last post by:
Hello, I am trying to use vs.net 2005 to migrate a project originally in vs.net 2003. I started with creation of a "web site", and then created folders for each component of the site. I read somewhere that each folder under the "web site" is compiled in separate assembly. I however, did not find that the "web site" creation in vs.net 2005 created any AssemblyInfo.cs file.
0
1720
by: Louis Aslett | last post by:
I hope this is the correct newsgroup for this query (if not please give me a pointer to where is best): I understand the theory of normalisation etc and am trying to follow best practices in the design of the database for a new project, but I am unsure as to the best practice when one wants to store data relating to combinations of arbitrary numbers of sets of data. For example, take the following two groups of sets, each containing...
10
3003
by: Ren | last post by:
Hi All, I'm still rather new at vb.net and would like to know the proper way to access private varibables in a class. Do I access the variable directly or do I use the public property? public class MyClass private _variableName as integer public property VariableName as integer
3
2246
by: John Dalberg | last post by:
I am looking for an ASP.NET application on CodePlex which exemplifies best practices for the following: - Use of interfaces - Seperation of the UI, business and data tiers - Data Tier that uses Enterprise Libraries data layer (if possible) - Use of providers (if possible) - use of factories (if possible) - use of caching - Session management
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10437
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
9042
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
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
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3723
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.