I just left a comment but then immediately noticed this:
using (Stream stm = webRequest.GetRequestStream())
{
using (StreamWriter stmw = new StreamWriter(stm))
{
stmw.Write(soapEnvelopeXml); <--------
}
}
The
TextWriter.Write Method (System.IO) | Microsoft Learn[
^] (
StreamWriter
inherits from
TextWriter
) calls
ToString()
on the object being passed in. This is probably not what you want to happen, you probably want the content of the XML file to be sent direct?
Could you not just read the contents of
XMLFile.xml
into a
string
and then write that content directly to the
StreamWriter
?