【发布时间】:2012-06-23 15:05:52
【问题描述】:
我在从 php 页面调用肥皂服务时遇到问题。我实现了两页,第一页是在 php 中创建的,第二页是在 asp.net 中创建的。在 asp.net 应用程序中,我有 SOAP 服务,应该从 php 调用哪些方法。
我的 SOAP 服务上的方法,如下所示:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public bool UpdateVotes(string vote) {
//Code
}
在 PHP 应用程序中,我在下一个方法中调用 UpdateVotes 方法:
$.ajax({
type: "POST",
url: "http://localhost:5690/VoteServices.asmx/UpdateVotes",
data: "{'vote': '" + vote + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
},
error: function (xhr, status, error) {
}
});
首先我使用 SOAP 服务运行 asp.net 应用程序,然后启动 php 应用程序。
当我点击在服务 i 浏览器控制台上调用 web 方法的按钮时,出现此错误:
Failed to load resource: the server responded with a status of 500 (Internal Server Error) http://localhost:5690/VoteServices.asmx/UpdateVotes
XMLHttpRequest cannot load http://localhost:5690/VoteServices.asmx/UpdateVotes. Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin.
【问题讨论】:
-
你用谷歌搜索了错误信息吗?
-
Origin localhost:8080 是 Access-Control-Allow-Origin 不允许的 - 你应该阅读一下 JSONP、CORS - stackoverflow.com/questions/3616440/…