我已使用以下代码成功连接到服务,但我需要将响应保存到 XML 文件 results.xml。
Dim xml As New System.Xml.XmlDocument()
xml.Load("c:\testfile.xml")
Dim req = WebRequest.Create("????")
req.Method = "POST"
req.ContentType = "application/xml"
Using ms = New MemoryStream()
xml.Save(ms)
req.ContentLength = ms.Length
ms.WriteTo(req.GetRequestStream())
End Using
Dim results As XmlReader = XmlTextReader.Create(req.GetResponse().GetResponseStream)
Dim settings As New XmlWriterSettings()
settings.Indent = True
settings.IndentChars = vbTab
Dim writer As XmlWriter = XmlWriter.Create("c:\results.xml", settings)
writer.WriteNode(results, False)
代码运行但只生成一个空白文件。任何帮助将不胜感激。