I am building my web page using AJAX in ASP.Net, now I want to make a cross-domain call from my web application to my web service that both of them are hosted at different machine.
I used the steps below to make the cross-domain call to the web service.
First of all, I created a web service named as HRService.asmx and it is working fine by running under IIS 5.1.
Secondy, I make a reference to the web service proxies by writing the code in the html body
Expand|Select|Wrap|Line Numbers
- <asp:ScriptManager ID="ScriptManager1" runat="server" >
- <Services>
- <asp:ServiceReference Path="http://192.168.1.123/TestAjax/HRService.asmx"/>
- </Services>
- </asp:ScriptManager>
However at the end, when I run the application it shows a message dialog that the class is 'undefined'.
I did found the answer from msdn that we cannot reference to the web service directly by using ServiceReference because hackers can use the JSON wire format to try and exploit cross domain scripts within browsers. Therefore it has been disabled due to security issues.
So, now my question is, if we cannot make cross-domain call to the web service directly, then how can we remotely call the web service from Javascript?
Does anyone know? Thank you very much.