PHP ページから SOAP サービスを呼び出す際に問題があります。私は2つのページを実装しました。最初のページはphpで作成され、2番目のページはasp.netで作成されました。asp.net アプリケーションには、php から呼び出す必要がある SOAP サービスがあります。
私の 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 アプリケーションを開始します。
サービスで 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.