How to return XML Document from web service.

Discussion in 'ASP .Net Web Services' started by GH, Feb 4, 2007.

  1. GH

    GH Guest

    Can someone point me to an example of a VB.Net client that reads an
    XML Document from a web service?

    I have a web service that successfully creates an XML document, saves
    it on the server and returns it to the calling client.

    Maybe I don't understand all I know about this but for some reason
    what is returned is an XMLNode, not a document. How does one usually
    return an XML Document from a web service? SHould I be using
    XMLDatadocument?

    Thanks,
    GH
    GH, Feb 4, 2007
    #1
    1. Advertising

  2. GH

    Scott M. Guest

    If your webmethod's return value is an XMLDocument and that is, in fact,
    what your code returns, then your web service returns an XMLDocument. So,
    the calling code would look something like:

    [vb.net]

    'Assuming you have already made your web reference
    Dim ws As New someServer.someService()
    Dim xmlDoc As Xml.XmlDocument = ws.someMethodThatReturnsAnXMLDocument()




    "GH" <> wrote in message
    news:...
    > Can someone point me to an example of a VB.Net client that reads an
    > XML Document from a web service?
    >
    > I have a web service that successfully creates an XML document, saves
    > it on the server and returns it to the calling client.
    >
    > Maybe I don't understand all I know about this but for some reason
    > what is returned is an XMLNode, not a document. How does one usually
    > return an XML Document from a web service? SHould I be using
    > XMLDatadocument?
    >
    > Thanks,
    > GH
    >
    Scott M., Feb 5, 2007
    #2
    1. Advertising

  3. GH

    GH Guest

    On Feb 4, 8:28 pm, "Scott M." <> wrote:
    > If your webmethod's return value is an XMLDocument and that is, in fact,
    > what your code returns, then your web service returns an XMLDocument. So,
    > the calling code would look something like:
    >
    > [vb.net]
    >
    > 'Assuming you have already made your web reference
    > Dim ws As New someServer.someService()
    > Dim xmlDoc As Xml.XmlDocument = ws.someMethodThatReturnsAnXMLDocument()
    >
    > "GH" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > Can someone point me to an example of a VB.Net client that reads an
    > > XML Document from a web service?

    >
    > > I have a web service that successfully creates an XML document, saves
    > > it on the server and returns it to the calling client.

    >
    > > Maybe I don't understand all I know about this but for some reason
    > > what is returned is an XMLNode, not a document. How does one usually
    > > return an XML Document from a web service? SHould I be using
    > > XMLDatadocument?

    >
    > > Thanks,
    > > GH- Hide quoted text -

    >
    > - Show quoted text -



    Thanks but when I do what you suggest I get the error:
    "Unable to cast object of type 'System.Xml.XmlElement' to type
    'System.Xml.XmlDocument'." This implies that my web service is not
    really returning a document, however....


    My web service says
    Public Function GetWebOrders() As XmlDocument
    Dim Doc As New XmlDocument
    ...... Build the document and Doc.Save it on the server
    (which works fine)....
    Return Doc
    End Function

    My Client says:
    Dim xmlDoc As Xml.XmlDocument = ws.GetWebOrders()
    ....that's when I get the error above.


    It has been suggested that I return the XML as a String but I dont
    think that is the best way to do it.

    --GH
    GH, Feb 5, 2007
    #3
  4. GH

    Scott M. Guest

    > It has been suggested that I return the XML as a String but I dont
    > think that is the best way to do it.


    Personally, I think that is the best way to do it. But, have you tried
    casting your result as an XMLDocument?
    Scott M., Feb 5, 2007
    #4
    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. Tony Prichard
    Replies:
    0
    Views:
    715
    Tony Prichard
    Dec 12, 2003
  2. Manish Hatwalne
    Replies:
    1
    Views:
    392
    Martin Honnen
    Jul 13, 2004
  3. R.A.

    how to return xml document from a web service

    R.A., Nov 24, 2004, in forum: ASP .Net Web Services
    Replies:
    4
    Views:
    528
    Dan Rogers
    Nov 29, 2004
  4. Andrew

    Return XML Document from Web Service (.net v2)

    Andrew, Mar 11, 2009, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    936
    Andrew
    Mar 11, 2009
  5. Leo Violette
    Replies:
    0
    Views:
    1,001
    Leo Violette
    Apr 17, 2009
Loading...

Share This Page