469,323 Members | 1,506 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,323 developers. It's quick & easy.

AJAX: Web Service - How to cross-domain call the server

6
hi guys,
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
  1. <asp:ScriptManager ID="ScriptManager1" runat="server" >
  2.             <Services>
  3.                 <asp:ServiceReference Path="http://192.168.1.123/TestAjax/HRService.asmx"/>
  4.             </Services>
  5.         </asp:ScriptManager>
  6.  
After that I called the web service using javascript which is HRService.GetEmployee(.....);

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.
Feb 25 '08 #1
1 3226
acoder
16,027 Expert Mod 8TB
Use a web proxy. Make a request to a script in your own domain which makes a Http request to the other domain and returns the response.
Feb 26 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by shadow.demon | last post: by
8 posts views Thread by DartmanX | last post: by
6 posts views Thread by Joel Byrd | last post: by
3 posts views Thread by blueapricot416 | last post: by
3 posts views Thread by caston | last post: by
6 posts views Thread by =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post: by
4 posts views Thread by =?Utf-8?B?R2VyaGFyZA==?= | last post: by
4 posts views Thread by JJ | last post: by
9 posts views Thread by Trapulo | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by mdpf | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by listenups61195 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.