异常很简单: {"Unable to connect to the remote server"}{"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 202.40.243.120:443"}
{"Unable to connect to the remote server"}{"A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 202.40.243.120:443"}
sendUrl=https://smsgw.saasconnect.com/obh/SendSMSLegacyBC就是这个地址!
我修改了代码如下,还是不行 string SenSMSUrl = sendUrl;
byte[] bytes = Encoding.UTF8.GetBytes(SendSMSOnBehalfReq.InnerXml.ToString()); HttpWebRequest request;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
request = WebRequest.Create(SenSMSUrl) as HttpWebRequest;
request.ProtocolVersion = HttpVersion.Version10; request.Method = "POST";
request.ContentLength = bytes.Length;
//request.ContentType = "application/x-www-form-urlencoded";
request.Timeout = 50000;
request.KeepAlive = true;
request.ContentType = "text/xml";
request.ServicePoint.Expect100Continue = false; Stream requestStream;
try
{
requestStream = request.GetRequestStream();
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
}
catch (Exception)
{ throw;
} // using (Stream requestStream = request.GetRequestStream())
// { // }
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); if (response.StatusCode != HttpStatusCode.OK)
{
string message = String.Format("POST failed. Received HTTP {0}", response.StatusCode);
throw new ApplicationException(message);
} private static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
}
{"Cannot send a content-body with this verb-type."}还是不行呀