Can AJAX calling a external webservices functions
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="WebService.asmx" />
</Services>
</asp:ScriptManager>
<script type="text/javascript">
WebService.GetUpdate("hhh",OnComplete, 开发者_如何学JAVAOnTimeout, OnError);
</script>
this code is working fine, but when I change the Path to an external webservices, it give me an error, the class name is not defined. can someone help me out, thanks the changed one is
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="http://mysite/WebService.asmx" />
</Services>
</asp:ScriptManager>
<script type="text/javascript">
WebService.GetUpdate("hhh",OnComplete, OnTimeout, OnError);
</script>
Rather than using Javascript to make cross-domain calls, if you can change the web service implementation, your can make the cross-domain calls in web service, then retrieve the result from your client.
With Javascript, as far as I know, some Javascript libraries (like dojo) have support for this. Below is a sample code snippet.
var callee = dojox.io.windowName.send("GET", {url:"http://xyz.com/data"});
callee.addCallback(function(data){
console.log(data);
});
Make a call to the local server, and have the server make the call to the external web service. This is allowed.
You are trying to make a cross-domain call: you can’t make XMLHttpRequest calls from one domain to another.
using the local webservice to call the external webservices and then use javascript to call the local function, then the problem solved
You can only reference a web service in the same domain using the ServiceReference
精彩评论