473,473 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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

6 New Member
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 3380
acoder
16,027 Recognized Expert Moderator MVP
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

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

Similar topics

2
by: shadow.demon | last post by:
So ajax is the new black, i've had a couple ideas about how to implement it. I've alook at ajax.net and few other implementations but to me they're a bit complex. Maybe it's the way to go to have...
8
by: DartmanX | last post by:
Hi, Looking for recommendations for a decent API for AJAX work. I need it to be somewhat documented so I can figure out how to actually use it. My most critical need right now is clean code...
6
by: Joel Byrd | last post by:
I want a website that works in the following way: It has a main content div, and of course menu items. When you click a menu item, it should use AJAX to change the main content div to the content...
3
by: blueapricot416 | last post by:
I have some javascript in a standard HTML page that uses the ubiquitous "XMLHttpRequest" to send data to a remote ASP page. If that page "answers back" by sending a string using a simple...
3
by: caston | last post by:
Well, everybody can now agree with the fact that the Ajax hype is over. Still multiple Ajax Frameworks are flourishing, aren't they? So, last night I questioned myself with the following: "When...
3
by: BG Mahesh | last post by:
hi We are looking for a good Ajax library which has very good support for iframe. The ones we have considered so far are, Backbase.com - not happy with the speed Zapatech.com - it is good but...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
4
by: =?Utf-8?B?R2VyaGFyZA==?= | last post by:
I am just stating to use ajax, and have a perfect place to use the accordion control. I have it working fine, but need to have a normal asp button in one of the panes that fires an onclick event...
4
by: JJ | last post by:
Just considering my first ajax enabled site.... I notice that Ajax is 'compatible with most modern browsers'. What do you more experienced ajax users do when it comes to older browser...
9
by: Trapulo | last post by:
Hello, with ASP.NET 2.0 Ajax every unexpected error is managed client-side with a popup that reports the error to the user. In ASP.NET 3.5 this behavor has been changed: how can I have a similar...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.