我有一个 XMLTextWriter 写入 WebRequest 的流。一切正常:
Dim wr As WebRequest = WebRequest.Create("https://wwwcie.ups.com/ups.app/xml/ShipAccept")
With wr
.Method = "POST"
.ContentType = "application/x-www-form-urlencoded"
End With
Dim requestStream As Stream = wr.GetRequestStream
Using requestStream
Dim x As New XmlTextWriter(requestStream, Encoding.UTF8)
Using x
With x
.WriteStartDocument()
'XML
.WriteStartElement("ShipmentAcceptRequest")
'ShipmentAcceptRequest
.WriteStartElement("Request")
'Request
.WriteElementString("RequestAction", sar.Request.RequestAction)
'/Request
.WriteEndElement()
.WriteElementString("ShipmentDigest", sar.ShipmentDigest)
'/ShipmentAcceptRequest
.WriteEndElement()
'/XML
.WriteEndDocument()
.Flush()
End With
End Using
End Using
我怎样才能截获这个被编写为 XMLDocument 类型的 XML?我尝试从流中获取它,但这给了我一个“流不支持阅读”。例外(这并不让我感到惊讶)。
谢谢