Web Service returning untyped DataSets only; how to get typed dataaccess?



I am consuming an ASP.NET Web Service which returns only DataSets for
all operations. The format/schema of the data returned by each method
is known and doesn't change. Untyped DataSets are inelegant to use on
the client when the data format is known, so I want typed data access
to each response type. Using a typed DataSet would be fine, but
anything that programmatically lets me access data is fine.

What is the "Visual Studio" (2005, 2008, doesn't matter) solution to
this? I have attempted to create typed DataSets from the Web Service
using every VS method I could think of, but I haven't gotten it to
work. Things I've tried include

1. xsd.exe /d using actual response XML: the generated .xsd file is
not usable as a typed DataSet as far as I can see.

2. xsd.exe /d using an XSD generated with WriteXmlSchema on the
DataSet returned by the Web Method: same as above.

3. "Create schema" in Visual Studio using actual response XML: I've
found no way to go from here to a typed DataSet.

My current solution is very old-school and relies on XmlSerializer to
deserialize the DataSet/DiffGram XML embedded in the DataSet returned
by the Web Method. This seems to me like a very un-Visual Studio
approach. The only working alternative I have so far is manually
creating typed DataSets, using the Visual Studio designer, to match
the response DataSets. Obviously, this too feels like a suboptimal

There are numerous references to "Generate DataSet" in the
documentation, but that command is always disabled, regardless of how
I create an XML schema. I'm assuming strict requirements are made on
the XML schema for this to work, but I can't find any information in
the documentation. Maybe it doesn't work the way I imagine it does.
I've also found many references to the drawbacks of using DataSets as
response types in Web Services, but there's nothing I can do about

Any thoughts? All I want is early-bound, typed, programmatic access to
data in the DataSet.




For example, the SOAP response can look like this:

<xs:schema id="NewDataSet">
(Actual schema here.)
<MyItem diffgr:id="MyItem1" msdata:rowOrder="0">

What I am asking is what the most proper/official/recommended way to
generate a type called MyItem with a MyProperty property is.

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