I've got an XMLTextWriter writing to a Stream of a WebRequest. Everything works as it should:
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
How can I intercept this XML that's being written as an XMLDocument type? I tried snagging it from the stream but that gave me a 'The stream does not support reading.' exception (which didn't surprise me).
Thanks