loading

Discussion in 'ASP .Net Web Services' started by John Hopper, May 18, 2005.

  1. John Hopper

    John Hopper Guest

    I must be missing something pretty simple. I set a web reference to a web
    service and pass it an xml document. At the provider end I validate the
    received document against an xsd. I want to parse it after validation using
    an xmlNodeReader and selectSingleNode. This works fine when I save the file
    first and then xmlDocument.load(uri), with the uri the location of the saved
    xml file. But I don't want to save the file. I see I can pass the
    xmlDocument.load method a stream, but how do I get the stream to pass it? Any
    help very much appreciated. I've tried a number of ways without success.

    John Hopper
    John Hopper, May 18, 2005
    #1
    1. Advertising

  2. John Hopper

    John Hopper Guest

    addendum: loading

    Also, I get "root element is missing" (at the "load" step in the snippet
    below) when I try what I think should work, ie:

    Dim deSer As New XmlSerializer(oReport.GetType)
    Dim ms As New MemoryStream
    deSer.Serialize(ms, oReport)
    Dim theEncoding As New System.Text.UTF8Encoding
    Dim str As String = theEncoding.GetString(ms.GetBuffer)
    Dim tr As New XmlTextReader(ms)

    'Dim sr As New StringReader(oReport.OuterXml.ToString)

    'Dim stream As Stream = deSer.Deserialize(

    'Dim myXmlReader As XmlReader
    Dim myXmlDataDoc As XmlDataDocument = New XmlDataDocument
    'myXmlDataDoc.Load("http://localhost/mc/ws050513/doc.xml")
    myXmlDataDoc.Load(tr)



    "John Hopper" wrote:

    > I must be missing something pretty simple. I set a web reference to a web
    > service and pass it an xml document. At the provider end I validate the
    > received document against an xsd. I want to parse it after validation using
    > an xmlNodeReader and selectSingleNode. This works fine when I save the file
    > first and then xmlDocument.load(uri), with the uri the location of the saved
    > xml file. But I don't want to save the file. I see I can pass the
    > xmlDocument.load method a stream, but how do I get the stream to pass it? Any
    > help very much appreciated. I've tried a number of ways without success.
    >
    > John Hopper
    John Hopper, May 18, 2005
    #2
    1. Advertising

  3. "=?Utf-8?B?Sm9obiBIb3BwZXI=?=" <>
    wrote in news::
    > the location of the saved xml file. But I don't want to save the file. I
    > see I can pass the xmlDocument.load method a stream, but how do I get
    > the stream to pass it? Any help very much appreciated. I've tried a
    > number of ways without success.


    You have to create a stream. There are memory streams, and many other types.
    See the FCL reference or MSDN.


    --
    Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
    "Programming is an art form that fights back"

    Blog: http://blogs.atozed.com/kudzu
    Chad Z. Hower aka Kudzu, May 18, 2005
    #3
  4. John Hopper

    John Hopper Guest

    In the addendum (my 2nd message) above I show code creating a memory file.

    Thank you, but that is just giving me "root element missing" at the
    xmlDocument.Load step.

    John Hopper



    "Chad Z. Hower aka Kudzu" wrote:

    > "=?Utf-8?B?Sm9obiBIb3BwZXI=?=" <>
    > wrote in news::
    > > the location of the saved xml file. But I don't want to save the file. I
    > > see I can pass the xmlDocument.load method a stream, but how do I get
    > > the stream to pass it? Any help very much appreciated. I've tried a
    > > number of ways without success.

    >
    > You have to create a stream. There are memory streams, and many other types.
    > See the FCL reference or MSDN.
    >
    >
    > --
    > Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
    > "Programming is an art form that fights back"
    >
    > Blog: http://blogs.atozed.com/kudzu
    >
    John Hopper, May 18, 2005
    #4
  5. John Hopper

    John Hopper Guest

    RE: addendum: loading

    I can convert the xmlDocument to a dataset from a memory stream using the
    example at http://thecodeproject.com/dotnet/XmlToTypedDataSet.asp, and that's
    more useful anyway.

    But I'd still be interested, if anyone can answer my previous question.

    Thank you

    "John Hopper" wrote:

    > Also, I get "root element is missing" (at the "load" step in the snippet
    > below) when I try what I think should work, ie:
    >
    > Dim deSer As New XmlSerializer(oReport.GetType)
    > Dim ms As New MemoryStream
    > deSer.Serialize(ms, oReport)
    > Dim theEncoding As New System.Text.UTF8Encoding
    > Dim str As String = theEncoding.GetString(ms.GetBuffer)
    > Dim tr As New XmlTextReader(ms)
    >
    > 'Dim sr As New StringReader(oReport.OuterXml.ToString)
    >
    > 'Dim stream As Stream = deSer.Deserialize(
    >
    > 'Dim myXmlReader As XmlReader
    > Dim myXmlDataDoc As XmlDataDocument = New XmlDataDocument
    > 'myXmlDataDoc.Load("http://localhost/mc/ws050513/doc.xml")
    > myXmlDataDoc.Load(tr)
    >
    >
    >
    > "John Hopper" wrote:
    >
    > > I must be missing something pretty simple. I set a web reference to a web
    > > service and pass it an xml document. At the provider end I validate the
    > > received document against an xsd. I want to parse it after validation using
    > > an xmlNodeReader and selectSingleNode. This works fine when I save the file
    > > first and then xmlDocument.load(uri), with the uri the location of the saved
    > > xml file. But I don't want to save the file. I see I can pass the
    > > xmlDocument.load method a stream, but how do I get the stream to pass it? Any
    > > help very much appreciated. I've tried a number of ways without success.
    > >
    > > John Hopper
    John Hopper, May 19, 2005
    #5
    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. Timothy
    Replies:
    1
    Views:
    525
    Gaurav Khanna [C# MVP]
    Jan 27, 2004
  2. David Segall
    Replies:
    2
    Views:
    436
    Thomas Kellerer
    Jan 2, 2007
  3. Replies:
    4
    Views:
    310
  4. edfialk
    Replies:
    0
    Views:
    187
    edfialk
    May 10, 2007
  5. ofir
    Replies:
    0
    Views:
    183
Loading...

Share This Page