日期:2014-05-17 浏览次数:20616 次
public static string PostXml(string url, string Method, string xml)
{
string ResponseResult = "";
string para = "xml=" + xml;
HttpWebRequest request = null;
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
request = WebRequest.Create(url) as HttpWebRequest;
//request.ProtocolVersion = HttpVersion.Version10;
}
else
{
request = WebRequest.Create(url) as HttpWebRequest;//创建一个请求
}
request.KeepAlive = false;
request.Method = Method;
WebHeaderCollection webHead = new WebHeaderCollection();
webHead.Add("Accept-Encoding:gzip,deflate");
request.Headers = webHead;
request.Accept = "text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2";
request.ContentType = "application/x-www-form-urlencoded";
Stream st = null;
if (Method == "POST")
{
byte[] data = Encoding.UTF8.GetBytes(para);
request.ContentLength = data.Length;
&