How to add schema information into xmldocument from typed dataset

Discussion in 'ASP .Net Web Services' started by Whoever, Nov 16, 2004.

  1. Whoever

    Whoever Guest

    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.
     
    Whoever, Nov 16, 2004
    #1
    1. Advertising

  2. Whoever

    Scott M. Guest

    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.


    "Whoever" <> wrote in message
    news:ewwRLZ$...
    > 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., Nov 16, 2004
    #2
    1. Advertising

  3. Whoever

    Whoever Guest

    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?


    "Scott M." <> wrote in message
    news:e7r383$...
    > 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.
    >
    >
    > "Whoever" <> wrote in message
    > news:ewwRLZ$...
    > > 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.
    > >
    > >

    >
    >
     
    Whoever, Nov 16, 2004
    #3
  4. 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/frlrfSystemDataDataSetClassWriteXmlTopic.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/frlrfsystemdatadatasetclassgetxmlschematopic.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



    "Whoever" <> wrote in message
    news:%23G4EG8$...
    > 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?
    >
    >
    > "Scott M." <> wrote in message
    > news:e7r383$...
    >> 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.
    >>
    >>
    >> "Whoever" <> wrote in message
    >> news:ewwRLZ$...
    >> > 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.
    >> >
    >> >

    >>
    >>

    >
    >
     
    Dino Chiesa [Microsoft], Nov 16, 2004
    #4
  5. Whoever

    Scott M. Guest

    I would use the GetXML and GetXMLSchema methods that return their respective
    data as strings.

    "Dino Chiesa [Microsoft]" <> wrote in message
    news:...
    > 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/frlrfSystemDataDataSetClassWriteXmlTopic.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/frlrfsystemdatadatasetclassgetxmlschematopic.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
    >
    >
    >
    > "Whoever" <> wrote in message
    > news:%23G4EG8$...
    >> 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?
    >>
    >>
    >> "Scott M." <> wrote in message
    >> news:e7r383$...
    >>> 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.
    >>>
    >>>
    >>> "Whoever" <> wrote in message
    >>> news:ewwRLZ$...
    >>> > 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., Nov 16, 2004
    #5
  6. Whoever

    Whoever Guest

    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?


    "Scott M." <> wrote in message
    news:...
    > I would use the GetXML and GetXMLSchema methods that return their

    respective
    > data as strings.
    >
    > "Dino Chiesa [Microsoft]" <> wrote in message
    > news:...
    > > 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/frlrfSystemDataDataSetClassWriteXmlTopic.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/frlrfsystemdatadatasetclassgetxmlschematopic.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
    > >
    > >
    > >
    > > "Whoever" <> wrote in message
    > > news:%23G4EG8$...
    > >> 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?
    > >>
    > >>
    > >> "Scott M." <> wrote in message
    > >> news:e7r383$...
    > >>> 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.
    > >>>
    > >>>
    > >>> "Whoever" <> wrote in message
    > >>> news:ewwRLZ$...
    > >>> > 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.
    > >>> >
    > >>> >
    > >>>
    > >>>
    > >>
    > >>

    > >
    > >

    >
    >
     
    Whoever, Nov 17, 2004
    #6
  7. Whoever

    Whoever Guest

    My Bad. // Re: How to add schema information into xmldocument from typed dataset

    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.



    "Whoever" <> wrote in message
    news:ewwRLZ$...
    > 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.
    >
    >
     
    Whoever, Nov 18, 2004
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nedu N
    Replies:
    1
    Views:
    1,826
    Chris Taylor
    Oct 31, 2003
  2. Shoval Tomer
    Replies:
    0
    Views:
    467
    Shoval Tomer
    Jul 9, 2003
  3. Nedu N
    Replies:
    2
    Views:
    2,192
  4. Ersin Gençtürk
    Replies:
    1
    Views:
    3,541
    Ersin Gençtürk
    Oct 6, 2004
  5. Nedu N
    Replies:
    2
    Views:
    232
    Jacob Yang [MSFT]
    Oct 31, 2003
Loading...

Share This Page