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 / November 2004

Tip: Looking for answers? Try searching our database.

How to add schema information into xmldocument from typed dataset

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Whoever - 16 Nov 2004 16:06 GMT
Hi,

I'm trying to return an XmlDocument or XmlNode converted from a typed
dataset.

public XmlNode whatever() {
   MyTypedDataSet ds = new MyTypedDataSet();
   return new XmlDataDocument(ds);
}

In WSDL, it shows returned type as xml; in the result, it shows the xml
data.

How do I put schema information in both places?

Thanks.
Scott M. - 16 Nov 2004 17:04 GMT
You don't have to have all the XML in one XML document.

You can first load up the DataSet with the schema:
dataset.ReadXMLSchema(xmlSchemaNode)
and then read in the data from a different node:
dataset.ReadXML(xmlDataNode)

Be sure to read the schema in first though.

> Hi,
>
[quoted text clipped - 12 lines]
>
> Thanks.
Whoever - 16 Nov 2004 17:09 GMT
Thanks for the reply.  I'm not try to read, but to write.  I already have
data in the dataset and trying to return it from a web service as
xmldocument of course.

Just saw there's a ds.WriteXml(????, XmlWriteMode.WriteSchema)

But all examples I can find are trying to write to a file.  I need to write
into an XmlNode/XmlDocument/XmlDataDocument and return it.

Of course, it's better to have the schema information in WSDL as well.

Any ideas?

> You don't have to have all the XML in one XML document.
>
[quoted text clipped - 21 lines]
> >
> > Thanks.
Dino Chiesa [Microsoft] - 16 Nov 2004 21:30 GMT
The WriteXml method on the DataSet  allows you to write to a string or to a
stream.
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataDataSetClassWr
iteXmlTopic.asp


You do not need to write to a file.

You can also call GetXmlSchema method on the dataset, and put that into a
string.
http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdatadatasetclassge
txmlschematopic.asp


Consider using 2 methods - one that returns the schema and one that returns
the data.  Either that or put them into different XmlDocuments.

-Dino

> Thanks for the reply.  I'm not try to read, but to write.  I already have
> data in the dataset and trying to return it from a web service as
[quoted text clipped - 35 lines]
>> >
>> > Thanks.
Scott M. - 16 Nov 2004 21:46 GMT
I would use the GetXML and GetXMLSchema methods that return their respective
data as strings.

> The WriteXml method on the DataSet  allows you to write to a string or to
> a stream.
[quoted text clipped - 51 lines]
>>> >
>>> > Thanks.
Whoever - 17 Nov 2004 12:45 GMT
Thanks again for your follow up.

When returning a string, how can I add the schema information to WSDL so
that the service client have access to the data structure at design time?

> I would use the GetXML and GetXMLSchema methods that return their respective
> data as strings.
>
> > The WriteXml method on the DataSet  allows you to write to a string or to
> > a stream.

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemDataDataSetClassWr
iteXmlTopic.asp


> > You do not need to write to a file.
> >
> > You can also call GetXmlSchema method on the dataset, and put that into a
> > string.

http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemdatadatasetclassge
txmlschematopic.asp


> > Consider using 2 methods - one that returns the schema and one that
> > returns the data.  Either that or put them into different XmlDocuments.
[quoted text clipped - 41 lines]
> >>> >
> >>> > Thanks.
Whoever - 18 Nov 2004 05:07 GMT
Just picked up a message I posted a few days ago where  Dan Rogers points
out some confusion I had all these time.

Basically DataSet has type any in WSDL and schema as part of the return data
at run time.  The truth is schema information should be in WSDL to
facilitate design time reference.  I have already done that through custom
collection, but still kind of stucked with the idea of making schema part of
the return data, which is mostly uneccessary (Excel web query still
complains it has no schema, but I think I'll pass that one).

So seems fine tuning the custom collection with XmlAttribute is a more
practical approach.

Thanks for everyone's help.  Really appreicate it.

BTW, if anyone has a good example of using typed dataset and still be able
to have a perfect WSDL, I wouldn't mind rewrite all my codes.  Somehow Typed
DataSet always sounds better.

> Hi,
>
[quoted text clipped - 12 lines]
>
> Thanks.

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.