views:

241

answers:

5
    <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Services>
                <asp:ServiceReference Path="WebService.asmx" />
            </Services>
   </asp:ScriptManager> 
   <script type="text/javascript">
            WebService.GetUpdate("hhh",OnComplete, OnTimeout, 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>
A: 

You can only reference a web service in the same domain using the ServiceReference

zincorp
@zincorp,do u know how to make the calls in a different domain
Dirk
A: 

You are trying to make a cross-domain call: you can’t make XMLHttpRequest calls from one domain to another.

Scobal
To Scobal, do u know how to make the cross-domain calls using javascript, thanks
Dirk
As Brian said above you need a proxy on the same domain. Check out this article: http://developer.yahoo.com/javascript/howto-proxy.html
Scobal
A: 

Make a call to the local server, and have the server make the call to the external web service. This is allowed.

Brian
thanks, my problem solved by your told
Dirk
+2  A: 

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);
});
Jay Zeng
Jay has the right idea, just don't send a full url as that opens you up to attacks. Just send an enumerated value (1 for xyz url, 2 for abc url, etc)
Allen
@allen - um... huh? do you have a majic dns server that will translate '1' to 'xyz.com'? ;-)
Sky Sanders
A: 

using the local webservice to call the external webservices and then use javascript to call the local function, then the problem solved

Dirk