我正在尝试将XML文件发送到Web服务。
这里是加载XML并将其保存到流中的代码:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlFilePath);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(mesServiceURL);
request.Method = "POST";
request.ContentType = "application/xml";
Stream request_stream = request.GetRequestStream();
xmlDoc.Save(request_stream);
request_stream.Close();
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream r_stream = response.GetResponseStream();
StreamReader response_stream = new
StreamReader(r_stream, System.Text.Encoding.GetEncoding("utf-8"));
string sOutput = response_stream.ReadToEnd();
request_stream对象的length属性包含:
'request_stream.Length' threw an exception of type 'System.NotSupportedException'
在磁盘上,XML为3 kb,因此它并不大。
那么,我该如何解决这个问题?
提前致谢。