Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / February 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
UL-Tomten - 26 Feb 2008 09:05 GMT
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
approach.

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
that.

Any thoughts? All I want is early-bound, typed, programmatic access to
data in the DataSet.
UL-Tomten - 26 Feb 2008 09:14 GMT
For example, the SOAP response can look like this:

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

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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.