jQuery AJAX到C#Web服务ASMX从HTTPS到HTTP域
我使用Visual Studio(asmx页面)创建了一个正在调用HTTP页面的Web服务:jQuery AJAX到C#Web服务ASMX从HTTPS到HTTP域,jquery,ajax,https,asmx,Jquery,Ajax,Https,Asmx,我使用Visual Studio(asmx页面)创建了一个正在调用HTTP页面的Web服务: WebRequest request = WebRequest.Create("http://ws.geonames.org/countryCode?lat=" + lat + "&lng="+lng); 此服务通过HTTPS提供: https://mydevdomain.com/geonames/Service1.asmx/getGeoname 现在当我从https://mydev
WebRequest request = WebRequest.Create("http://ws.geonames.org/countryCode?lat=" + lat + "&lng="+lng);
此服务通过HTTPS提供:
https://mydevdomain.com/geonames/Service1.asmx/getGeoname
现在当我从https://mydevdomain.com/page.html
使用此jQuery代码
var request= $.ajax({
type: "POST",
url: "https://mydevdomain.com/geonames/Service1.asmx/getGeoname",
data: "{ 'lat':'"+coordinatesMap[f][1]+"', lng:'"+ coordinatesMap[f][2]+"'}",
contentType: "application/json; charset=utf-8",
dataType: "json"
});
…我在explorer上有一个经典警报,告诉我存在不安全的内容!
为什么?jQuery怎么可能知道服务正在调用一个不安全的页面
另外,我做这项服务是因为我想避开警报页面。不确定这是否有帮助,但它修复了我在该警报中遇到的类似问题 我用来修复。这并不重要,但我的班级是一个ASMX C#WebService(详见下文) 下面的示例:
//Force Trust with server
ServicePointManager.ServerCertificateValidationCallback = delegate(
Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) {return (true); };
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://999.999.99/PI/services/UCP");
request.Headers.Add("SOAPAction", "");
request.ContentType = "text/xml;charset=\"utf-8\"";
request.Accept = "text/xml";
request.Method = "POST";
更多代码
using System;
using System.Collections.Specialized;
using System.Net;
using System.Net.Security;
using System.IO;
using System.Xml;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
[WebService]
public class UCPSvc : WebService {
[WebMethod (Description="Proxy for ACS UCP WebService")]
public XmlDocument Proxy()
{
//...
}
}
就在我看这个的时候。。。我记得有过同样的问题,我必须为HttpCertificates合并一个C#对象并设置信任级别。我将查找代码。。。