日期:2014-05-17 浏览次数:20904 次
Encoding encoding = Encoding.GetEncoding("utf-8");
byte[] data = encoding.GetBytes(xml);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
//发送数据
request.Method = "POST";
request.ContentType = "application/soap+xml; charset=UTF-8";
request.ContentLength = data.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(data, 0, data.Length);
requestStream.Close();
//接收返回值
HttpWebResponse res = (HttpWebResponse)request.GetResponse();
StreamReader sReader = new StreamReader(res.GetResponseStream(), System.Text.Encoding.UTF8);
string returnXml = sReader.ReadToEnd();
sReader.Close();
res.Close();
info.RESULT_TYPE = true;
info.RESULT_DATA = returnXml;
return info;
}
catch (HttpListenerException ex)
{
info.RESULT_DATA = ex.Message;
return info;
}
catch (WebException ex)
{
&n