How to return XML Document from web service.

G

GH

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
 
S

Scott M.

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()
 
G

GH

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()




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
 
S

Scott M.

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?
 

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

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top