views:

376

answers:

1

Hi, I want to pass an XmlDocument as a parameter to my webservice method. After I have loaded an XML file from a path, when I try to send the XmlDocument as a parameter by webservice method, I come across this error. What can be the reason? I use StreamWriter and I close it. I don't use XmlWriter.
The development environment is VS 2008

Error Message:

Cannot write XML declaration. WriteStartDocument method has already written it.


Edit (from comments):

I can't post all the code because it has more than 1000 lines. Also when I load Xmldocument in web, I can't use this method without problem. Maybe Webservice causes a problem?

Dim xml As New XmlDocument
xml.Load("\My Documents\" & xmlfile & ".xml")
myTransfer.Save_XML(xml, 1)
<<<<<<'here crashes this is my web service method
<WebMethod()> _
Public Sub Save_XML(ByVal m_xmlMyDoc As XmlDocument, ByVal p_ID As Integer)
end sub
A: 

Pass the XmlDocument.OuterXml string to the webservice instead.

You can load it back into an XmlDocument with XmlDocument.LoadXml at the other end.

Wim Coenen