【发布时间】:2012-07-30 15:45:37
【问题描述】:
我正在尝试从 Metro 应用程序调用 Web 服务。我正在使用 javascript 开发应用程序,并且 web 服务是基于 wcf 的。
我试过这样:
function callWCF() {
WinJS.xhr({
type: "GET",
url: "http://lei-023880-ws.sinternal.de:8732/sdata/myApp/myContract/-/employees",
}).done(
function (result) {
console.log(result.responseText)
},
function (request) {
}
);}
或者像这样:
var xhr = new XMLHttpRequest();
xhr.open("GET", "http://lei-023880-ws.s.de:8732/sdata/myApp/myContract/-/$schema", true);
xhr.responseType = "text";
xhr.onreadystatechange = function () {
if (xhr.readyState == xhr.DONE) {
var blob = xhr.reponse;
window.console.log(blob);
}
}
xhr.send();
我回来的只是一个网络错误,代码为:2efd。我用谷歌搜索了它。它是一个“Internet_cannot_connect”错误。当我将网址更改为“microsoft.com”时,它工作正常。所以我想问题出在 wcf 服务上? 在 Windows 8 浏览器中调用 URL 时,它也可以工作。 为什么app无法调用url?
提前致谢。
机智
【问题讨论】:
标签: javascript wcf web-services windows-8