winform post xml 并获取返回xml

        public XDocument sendXmlAndGetResponse(XDocument xDocument)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(xDocument.Document.ToString());
WebResponse resp;
string strUrl = XMLTools.getXmlValue("LFListenerAddress", "Address");// "http://localhost:8008/hello/";
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(strUrl);
myRequest.ContentType = "text/xml";
myRequest.Method = "POST";
Stream stm = myRequest.GetRequestStream();
doc.Save(stm);
stm.Close();
resp = myRequest.GetResponse();
stm = resp.GetResponseStream();

var reDoc = new XmlDocument();
reDoc.Load(stm);

return reDoc.ToXDocument();
}
原文地址:https://www.cnblogs.com/zhuduozhe/p/2321834.html