XMLHttpRequest.open error

i have the following code:

// form to take user input of zipcode, and display city returned from web service
isc.DynamicForm.create({
ID:“zipForm”,
left:50, top:50, numCols:3, cellSpacing:5,
items:[
{name:“ZipCode”, keyPress: “if(keyName == ‘Enter’) form.callService()”},
{type:“button”, startRow:false, title:“Find City”, click:“form.callService()”},
{name:“City”, type:“staticText”}
],
callService: function () {
if (!this.zipCodeService) {
isc.say(“Please try again in a moment - still loading web service descriptor”);
return;
}
this.setValue(‘City’, ‘Loading…’);
// call the web service
this.zipCodeService.callOperation(
“pagina2”, // operation name
{}, // inbound data for operation
“//*”, // XPath, Type, or ElementName to extract result
“eval(String(data[3]))” // script to execute when operation returns
);
}
});

// load the zipcode-lookup web-service description
isc.XMLTools.loadWSDL(
“http://192.168.1.9/webservice2/service2.asmx?WSDL”, // URL
“zipForm.zipCodeService = service” // script to execute when description is loaded
);

this code is inside a .html page in the samples directory and works fine in IE, but when i try it in Mozilla Firefox occurs the following situation:

  • if i access the page writing the url http://alex/samples/myapp/index.html in the mozilla’s address bar it works fine.

  • if i access the page writing the url http://192.168.1.9/samples/myapp/index.html in the mozilla address bar it does not work and in the mozilla’s errors console appears the error ‘access denied to call XMLHttpRequest.open’.
    ¿ why occurs this ? and ¿ how can i resolve this problem ?

Thanks

Hi Alex,

What you are probably seeing is the browser’s “same origin” policy kicking in. Your WSDL file specifies the location at which the browser should contact the service (on the <soap:address> element). Depending on how you access the page as a whole, IE and FireFox are deciding that the web service endpoint is either from the same server that served the main page (in which case the request is allowed) or isn’t (in which case the request is blocked).

Can you tell us what the <soap:address> location attribute is in your WSDL file?

Regardless, if your page can be accessed via different hostnames or addresses, but in all cases the web service is available on the same host, you can use webService.setLocation() to ensure the web service address always matches the current hostname.