By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,411 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,411 IT Pros & Developers. It's quick & easy.

AJAX + Webserivces = error 12030

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.