[英]How to enable cross domain calls for self hosted WCF service
我创建了一个在Windows机器上运行的自托管WCF服务。 现在我想使用AJAX调用来使用服务的操作。 无论是在iExplorer,Firefox还是Chrome中,我都没有得到应有的JSON流。
我必须添加到自托管服务才能允许跨域调用?
关心西蒙
http://pranayamr.blogspot.se/2011/06/calling-cross-domain-wcf-service-using.html似乎是一篇有效的文章。 您需要相应地配置服务。 这在过去对我有用。
对于托管在localhost \\ Service.mvc上的服务GetPerson,请使用:
$.ajax({
type: 'GET', //GET or POST or PUT or DELETE verb
url: 'Service.svc/GetPerson', // Location of the service
data: userid, //Data sent to server
contentType: 'application/json; charset=utf-8', // content type sent to server
dataType: 'json', //Expected data format from server
processdata: true, //True or False
success: function (data) {//On Successfull service call
alert(data.Name);
},
error: function (msg) {// When Service call fails
alert(msg);
}
});
链接: http : //www.cleancode.co.nz/blog/1041/complete-example-wcf-ajax-ssl-http
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.