K
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
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