Reputation: 427
I have a big problem with Web Service included in MVC app. I've made a MVC app and it's hosting on IIS 7.0. Everything works perfect. Than I must add Web Service (of course it could be a WCF, by WS allready exists) to this project. So in Visual Studio 2010, I added new item, choosed a Web Service for current project. On dev machine, it's OK. Everyting wokrs fine. But when I try to publish whole project to IIS (it's on another server), MVC app don't see WS.
That's how I call WS, in MVC :
$('#test').click(function test2() {
alert('start');
$.ajax({
type: "POST",
url: "/../WebServicePrzeczytany.asmx/HelloWorld",
data: "{}",
dataType: "xml",
success: function suc(msg) {
alert("recieved: " + msg.text);
},
faild: fail
});
alert('stop');
});
function fail() {
alert("doesn't work");
};
It's jquery, as you see. But my question is : why it doesn't work ? Should I set or configure something on IIS ?
I'll by grateful for any help or clues.
Marcin
Upvotes: 1
Views: 235
Reputation: 4461
You are doing an approach which is a violation to a cross-domain policy that is you are calling or executing client-side calls to your webservice via javascript. However there is already existing approach if you want to execute or call the service via ajax using JSONP provided you meet the following conditions:
*You have control on your webservice code namely you can modify the code and customize it for JSONP
*You wrap all your webservice response to a JSONP callback.
for more info see http://api.jquery.com/jQuery.ajax/
Without JSONP it's working locally but if you are in the live environment that's not gonna work.
Upvotes: 0
Reputation: 563
Your web service url is not correct. "/../WebServicePrzeczytany.asmx/HelloWorld" your app should be pointing to the published web service and not a relative url like the one above. The url should be something like
http://someipaddressordomainname/WebServicePrzeczytany.asmx/HelloWorld
Upvotes: 1
Reputation: 10011
Your url looking strange. Have you tried to specify absolute url (http://example.com/some/path/WebServicePrzeczytany.asmx/HelloWorld) before publish?
Upvotes: 0