如何使用jquery ajax从ssl安全页面调用WCF服务?

时间:2022-10-30 23:19:07

I have a WCF service returning JSON to jQuery ajax calls and presenting the results on an ASPX page. When the page is NOT under SSL, the ajax calls work perfectly. When the page IS under SSL, the calls fail. I understand that this behavior must be due to the Same Origin Policy (SOP).

我有一个WCF服务,它将JSON返回给jQuery ajax调用,并在一个ASPX页面上显示结果。当页面不在SSL下时,ajax调用可以完美地工作。当页面位于SSL之下时,调用将失败。我知道这种行为一定是源于同源策略(SOP)。

So, how do I setup my WCF service to accept calls from an SSL-secured page? Does the WCF service also need to be secured? If so, how do I do this?

那么,如何设置WCF服务以接受来自ssl安全页面的调用呢?是否还需要保护WCF服务?如果是的话,我该怎么做呢?

Thanks,

谢谢,

Joe

3 个解决方案

#1


2  

If the problem is SOP, could you host the JSON services on the same server as the ASPX pages?

如果问题是SOP,是否可以将JSON服务托管在与ASPX页面相同的服务器上?

It may be that it is a browser setting which blocks a combination of SSL and non-SSL content.

可能是浏览器设置阻止了SSL和非SSL内容的组合。

#2


0  

you have to make sure that the browser has a valid certificate for the web service end point.

您必须确保浏览器拥有web服务端点的有效证书。

what happens when you fire up a javascript editor within your browser, and make a call to the web service? do you get any specific errors back?

当您在浏览器中启动javascript编辑器并调用web服务时会发生什么?你有没有收到什么特别的错误?

in firefox, install "firebug" if you haven't already. look at your ajax calls and see what headers are returned from the server. specifically the status code. than you can be sure which part of your call is failing and with what error

在firefox中,如果你还没有安装“firebug”。查看您的ajax调用并查看从服务器返回哪些头。特别是状态代码。然后你就可以确定你的电话哪一部分出了问题,有什么错误

#3


0  

Just wanted to post a follow up on this. It was so long ago that I can't remember if I actually figured out the cause, but in the end I realized that the data in my calls wasn't of a critically scure nature anyway. No user data was being passed. So, I just ran the page without SSL and my AJAX calls worked just fine. Sorry for no real resolution in this for anyone that was wondering! :(

我只是想发布一个跟进的消息。那是很久以前的事了,我不记得我是否真的找到了原因,但最后我意识到,我的电话中的数据无论如何都不具有批判性的纯洁性。没有传递任何用户数据。所以,我只是在没有SSL的情况下运行页面,我的AJAX调用运行良好。很抱歉,在这件事上没有真正的解决办法。:(

#1


2  

If the problem is SOP, could you host the JSON services on the same server as the ASPX pages?

如果问题是SOP,是否可以将JSON服务托管在与ASPX页面相同的服务器上?

It may be that it is a browser setting which blocks a combination of SSL and non-SSL content.

可能是浏览器设置阻止了SSL和非SSL内容的组合。

#2


0  

you have to make sure that the browser has a valid certificate for the web service end point.

您必须确保浏览器拥有web服务端点的有效证书。

what happens when you fire up a javascript editor within your browser, and make a call to the web service? do you get any specific errors back?

当您在浏览器中启动javascript编辑器并调用web服务时会发生什么?你有没有收到什么特别的错误?

in firefox, install "firebug" if you haven't already. look at your ajax calls and see what headers are returned from the server. specifically the status code. than you can be sure which part of your call is failing and with what error

在firefox中,如果你还没有安装“firebug”。查看您的ajax调用并查看从服务器返回哪些头。特别是状态代码。然后你就可以确定你的电话哪一部分出了问题,有什么错误

#3


0  

Just wanted to post a follow up on this. It was so long ago that I can't remember if I actually figured out the cause, but in the end I realized that the data in my calls wasn't of a critically scure nature anyway. No user data was being passed. So, I just ran the page without SSL and my AJAX calls worked just fine. Sorry for no real resolution in this for anyone that was wondering! :(

我只是想发布一个跟进的消息。那是很久以前的事了,我不记得我是否真的找到了原因,但最后我意识到,我的电话中的数据无论如何都不具有批判性的纯洁性。没有传递任何用户数据。所以,我只是在没有SSL的情况下运行页面,我的AJAX调用运行良好。很抱歉,在这件事上没有真正的解决办法。:(