I am trying to call a web service from an metro application. I am developing the app with javascript and the webservice is wcf-based.
I tried it like this:
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) {
}
);}
or like this:
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();
All im getting back is an network-error with code: 2efd. I googled it. Its an “Internet_cannot_connect”-error. When im changing the url to “microsoft.com” it works fine. So i guess the problem lies with the wcf-service?
When calling the URL in windows 8- browser it also works.
Why is the app not able to call the url?
Thanks in advance.
robidd
Since microsoft.com works, it sounds like the internet connectivity option has been set in the manifest? (Not trying to be Captain Obvious :), but I’ve overlooked that a few times!)
You might try Fiddler and see how far the request is going – if at all. Fiddler with Windows 8 is tricky, but this post should help you set it up: http://blogs.msdn.com/b/fiddler/archive/2011/09/14/fiddler-and-windows-8-metro-style-applications-https-and-private-network-capabilities.aspx