473,503 Members | 1,768 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AJAX + Webserivces = error 12030

kpg
I have an AJAX enabled web service consumed by an AJAX
enabled web app, given a zip code it returns the city
and state.

Tested the web service, it works fine.

I created a services collection in the script manager
and pointed to my web service.

I call the web service from an html input button click,
per MS examples.

I get a 12030 error.

Now it seems the web service must be in the same domain
as the web app, while this is a severe limitation I
figured this was the problem.

So I created the web service on my localhost, I get
the same error.

I played around with page methods but kept getting object
not defined errors so I gave up on that. (It seems the
web method must be declared in the aspx file, but I still
get this error.)

Considering that the same domain limitation was enough to
make the whole effort pointless (the web service will NOT
be in the same domain as the web app) I thought I would go
the traditional route and use xmlhttprequest. I've used
It before in asp.net 1.1 and it worked well.

So I copy my working code from a 1.1 app, change the url to
point to my Web service, invoke it and get access denied.

Why access denied? No doubt it's MS protecting me from
myself again.

Here's the code:

I'm using ?wsdl just to get some xml back for testing.

function Button1_onclick() {
debugger;
var url = 'http://localhost/webServices/ZipCode/ZipCodeService.asmx?
wsdl';
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = onComplete;
req.open("POST", url, true);
req.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = onComplete;
req.open("POST", url, true);
req.send();
}
}
}

function onComplete(arg,usercontent) {
debugger;
if (req.readyState == 4) {
if (req.status == 200) {
// ...processing statements go here...
} else {
window.status="There was a problem retrieving the XML
data:" + req.statusText;
}
}
}

Alternately I would love to use ASP.AJAX features to do this the
'right' way, but that 12030 error occurs no matter what I try.

I'm sure I could get an update panel to work, but that requires a
postback and processing of the page, even though the user's page is
not refreshed- that seems to defeat the purpose of doing AJAX in the
first place.

kpg
Jul 26 '07 #1
2 8823
It's a security feature.
IE and Firefox will not let you connect to other server than the one page
was served from.

George.
"kpg" <no@spam.comwrote in message
news:Xn*******************************@207.46.248. 16...
>I have an AJAX enabled web service consumed by an AJAX
enabled web app, given a zip code it returns the city
and state.

Tested the web service, it works fine.

I created a services collection in the script manager
and pointed to my web service.

I call the web service from an html input button click,
per MS examples.

I get a 12030 error.

Now it seems the web service must be in the same domain
as the web app, while this is a severe limitation I
figured this was the problem.

So I created the web service on my localhost, I get
the same error.

I played around with page methods but kept getting object
not defined errors so I gave up on that. (It seems the
web method must be declared in the aspx file, but I still
get this error.)

Considering that the same domain limitation was enough to
make the whole effort pointless (the web service will NOT
be in the same domain as the web app) I thought I would go
the traditional route and use xmlhttprequest. I've used
It before in asp.net 1.1 and it worked well.

So I copy my working code from a 1.1 app, change the url to
point to my Web service, invoke it and get access denied.

Why access denied? No doubt it's MS protecting me from
myself again.

Here's the code:

I'm using ?wsdl just to get some xml back for testing.

function Button1_onclick() {
debugger;
var url = 'http://localhost/webServices/ZipCode/ZipCodeService.asmx?
wsdl';
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = onComplete;
req.open("POST", url, true);
req.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = onComplete;
req.open("POST", url, true);
req.send();
}
}
}

function onComplete(arg,usercontent) {
debugger;
if (req.readyState == 4) {
if (req.status == 200) {
// ...processing statements go here...
} else {
window.status="There was a problem retrieving the XML
data:" + req.statusText;
}
}
}

Alternately I would love to use ASP.AJAX features to do this the
'right' way, but that 12030 error occurs no matter what I try.

I'm sure I could get an update panel to work, but that requires a
postback and processing of the page, even though the user's page is
not refreshed- that seems to defeat the purpose of doing AJAX in the
first place.

kpg

Jul 26 '07 #2
kpg
Finally got it to work.

Problem was mostly me. I (for some reason) could not let go
of the idea that a web service was a standalone service on a
server, independent of the web application. The concept of
having an asmx file as part of a project mixed in with the
standard aspx files escaped me. Sure, that's exactly what the
video tutorial showed, but I was thinking this was not how
such a project would be deployed. Silly me.

The solution is really quite simple.

1. Add an web service page to the web app.

2. Reference it in the script manager. In my
case this resides in a master page.

3. In javascript call the web service:

var ret = myclass.mywebservice(myargs, onComplete, OnFailure, usercontent);

Provide the callback functions onComplete and onFailure .

4. If the web service is external, create a web reference in the
project, then in the local asmx page call the referenced web
service, otherwise just perform the logic there.
In reviewing my asp 1.1 httprequest code (that works) I actually
post to an aspx page in the same project and the page returns an
xml response (a cool trick I can show if anyone's interested).
This technique is really quite similar to that described above,
except in the above the ASP.AJAX code handles most of the
troublesome details.

kpg
Jul 27 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6901
by: anandplace | last post by:
Hi, I am getting the following error when I try to get xmlhttp.responseText . System error: -1072896658 I am setting the following to the xmlhttp object before sending:
2
4366
by: hardrock | last post by:
Hello! I'm working with the prototype library version 1.4.0 and having a strange error lately. When I want to make an Ajax.Updater call, it basically works. But as soon as I put the call into...
0
6593
by: mark4asp | last post by:
I'm accessing the website locally via IIS. I get an error message shown in DropDownList2: I can't see what I'm doing wrong. I changed CascadingDropDown1.Category from "Continent" to...
1
8169
by: Not Me | last post by:
Hi there, I'm using a hovermenuextender attached to a templatefield of a gridview, and everything seemed to work fine.. however I've moved on to add dynamic attributes to the hovermenu. Now I...
2
2339
by: Angel666 | last post by:
We are using forms authenication with AJAX update control panels. We get various results but no redirect when the user has timed out and is no longer authenicated and does a asyncpostback. We...
1
10774
by: mfaisalwarraich | last post by:
Hi All, I am new in the Ajax. I want to know how i can run Ajax code in my local computer. For example i am using the following code to get the text of a text file named data.txt: <html>...
5
2310
by: =?Utf-8?B?TWlrZSBDb2xsaW5z?= | last post by:
The following line of code gives me an error. I'm guessing it is an Ajax related error. this.get_element().style.display = 'block'; This is the function that the line of code is in when it...
3
17663
by: George | last post by:
I am doing an AJAX call using JQuery on my page to which returns JSON objects and everything works fine. Now I decided to use ashx handler instead of and simply write JSON out. Then my problems...
0
7076
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
7274
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7323
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
6984
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
7453
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5576
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
3162
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
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
377
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.