Return a XmlSchema object

G

Guest

I am writing a web service in C#. One method queries a database for xml
formatted data and responds to the requester with an XMLDocument (this part
works fine). What I want now is another method that will return the schema
for that document.
My idea is to create a DataSet using the xml document and inferring its
schema (the data sources for these xml docs are varied). Then the schema
could be extracted from the dataset and sent to the requester.
But looking at the methods available to DataSet, it seems I would have to
WriteXmlSchema to a file on the server then use XmlSchema.Read to get back a
XmlSchema that I could then send in the response.
Surely there is a better way to get the schema into the response?
 
D

David Browne

Beanweed said:
I am writing a web service in C#. One method queries a database for xml
formatted data and responds to the requester with an XMLDocument (this
part
works fine). What I want now is another method that will return the schema
for that document.
My idea is to create a DataSet using the xml document and inferring its
schema (the data sources for these xml docs are varied). Then the schema
could be extracted from the dataset and sent to the requester.
But looking at the methods available to DataSet, it seems I would have to
WriteXmlSchema to a file on the server then use XmlSchema.Read to get back
a
XmlSchema that I could then send in the response.
Surely there is a better way to get the schema into the response?

Look at the overloads for DataSet.WriteXmlSchema. There's one for
TextWriter and one for Stream. You can write it directly to an Response or
a NetworkStream, or into a string, and write it from there.

David
 

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

Top