473,387 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

XMLHttpRequest problem with Firefox and Netscape

Hi Guys,

I have a security concern with Mozilla and Netscape browsers(In IE it gives secuirity pop window) in Remote server(Client's server).When I am trying to call an Asp.NET web service from javascript using the XmlHttpRequest object

XmlHttpRequest .Open("POST", ServicesPath, false);

Problem is only in Cleint's server ,Where in web Service path given in Webconfig file is server name(not the Ip Address, We noticed that Client is using same IP number with diffrent Port number to access the diffrent application. I.e The server IP number and a port also used to access this application). I think it works fine, if we mention webservice path as IP Number with the correct PORT number. which combination is used to access the application. But we cannot modify the Host file in Client machine.

It works beautifully! in local server , where we are modifying the local host file by regestering the IP number with name, and using name in webconfig file to give service path.

CODE SNIPPET :

function createXMLHttp(sxml)
{
if (typeof XMLHttpRequest != "undefined") {
return new XMLHttpRequest();
}
else if (window.ActiveXObject) {
var aVersions = [ "MSXML2.XMLHttp.5.0",
"MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",
"MSXML2.XMLHttp","Microsoft.XMLHttp"];

for (var i = 0; i < aVersions.length; i++) {
try {
var oXmlHttp = new ActiveXObject(aVersions[i]);
return oXmlHttp;
}
catch (oError) {
//Do nothing
}
}
}
throw new Error("XMLHttp object could be created.");
}


function CallWS(methodXml, methodName)
{
var xddoc, xhhttp, sxml
//alert(gc_lmsServicesPath);
// Create SOAP request
sxml = "<SOAP-ENV:Envelope xmlns:SOAP-ENV = 'http://schemas.xmlsoap.org/soap/envelope/'>";
sxml = sxml + "<SOAP-ENV:Body>";
sxml = sxml + methodXml;
sxml = sxml + "</SOAP-ENV:Body>";
sxml = sxml + "</SOAP-ENV:Envelope>";

xddoc = createxddoc(sxml);
// Creating HTTP request
xhhttp = new createXMLHttp(sxml);
alert(gc_lmsServicesPath);

//BELOW LINE IS NOT EXECUTING WHEN SERVICE PATH GIVEN IN WEB CONGIF IS SERVER NAME(for ex : http://ClentServer/App_Name/Service.asmx ")
xhhttp.open("POST", gc_lmsServicesPath, false);

xhhttp.setRequestHeader("SOAPAction", "http://tempuri.org/" + methodName);
xhhttp.setRequestHeader("MessageType", "CALL");
xhhttp.setRequestHeader("Content-Type", "text/xml");
try
{
// Sending request to the web service by HTTP
xhhttp.send(xddoc);
xhhttp.close;
}
catch(e)
{
throw(e);
}
if(gc_ThirdPlmsServicesPath!="")
SecondCall(sxml, methodName);

// Getting response from Web Service
xddoc = result(xhhttp);
return xddoc;

}
In webconfig file Service path given as follows

<add key="Service" value="http://ServerName/Service.asmx"/>


Any ideas? Thanks.
Jan 8 '07 #1
1 7566
b1randon
171 Expert 100+
Hi Guys,

I have a security concern with Mozilla and Netscape browsers(In IE it gives secuirity pop window) in Remote server(Client's server).When I am trying to call an Asp.NET web service from javascript using the XmlHttpRequest object

XmlHttpRequest .Open("POST", ServicesPath, false);

Problem is only in Cleint's server ,Where in web Service path given in Webconfig file is server name(not the Ip Address, We noticed that Client is using same IP number with diffrent Port number to access the diffrent application. I.e The server IP number and a port also used to access this application). I think it works fine, if we mention webservice path as IP Number with the correct PORT number. which combination is used to access the application. But we cannot modify the Host file in Client machine.

It works beautifully! in local server , where we are modifying the local host file by regestering the IP number with name, and using name in webconfig file to give service path.

CODE SNIPPET :

function createXMLHttp(sxml)
{
if (typeof XMLHttpRequest != "undefined") {
return new XMLHttpRequest();
}
else if (window.ActiveXObject) {
var aVersions = [ "MSXML2.XMLHttp.5.0",
"MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",
"MSXML2.XMLHttp","Microsoft.XMLHttp"];

for (var i = 0; i < aVersions.length; i++) {
try {
var oXmlHttp = new ActiveXObject(aVersions[i]);
return oXmlHttp;
}
catch (oError) {
//Do nothing
}
}
}
throw new Error("XMLHttp object could be created.");
}


function CallWS(methodXml, methodName)
{
var xddoc, xhhttp, sxml
//alert(gc_lmsServicesPath);
// Create SOAP request
sxml = "<SOAP-ENV:Envelope xmlns:SOAP-ENV = 'http://schemas.xmlsoap.org/soap/envelope/'>";
sxml = sxml + "<SOAP-ENV:Body>";
sxml = sxml + methodXml;
sxml = sxml + "</SOAP-ENV:Body>";
sxml = sxml + "</SOAP-ENV:Envelope>";

xddoc = createxddoc(sxml);
// Creating HTTP request
xhhttp = new createXMLHttp(sxml);
alert(gc_lmsServicesPath);

//BELOW LINE IS NOT EXECUTING WHEN SERVICE PATH GIVEN IN WEB CONGIF IS SERVER NAME(for ex : http://ClentServer/App_Name/Service.asmx ")
xhhttp.open("POST", gc_lmsServicesPath, false);

xhhttp.setRequestHeader("SOAPAction", "http://tempuri.org/" + methodName);
xhhttp.setRequestHeader("MessageType", "CALL");
xhhttp.setRequestHeader("Content-Type", "text/xml");
try
{
// Sending request to the web service by HTTP
xhhttp.send(xddoc);
xhhttp.close;
}
catch(e)
{
throw(e);
}
if(gc_ThirdPlmsServicesPath!="")
SecondCall(sxml, methodName);

// Getting response from Web Service
xddoc = result(xhhttp);
return xddoc;

}
In webconfig file Service path given as follows

<add key="Service" value="http://ServerName/Service.asmx"/>


Any ideas? Thanks.
If it works on local only then your problem is probably that for security reasons most browsers will only let you call XMLRequests to the same domain as the page came from (unless the page is locally hosted which explains why it works locally). The only way around this is either to a) be synchronous and call a page so that your server can access the web service or b) stay asynchronous but use an ajax call to your server which will call your WS, then return it's results back to the browser. It's a hairy mess, I know, but it is one of the only ways to keep web pages from making calls all over the web without the client realizing it.
Jan 8 '07 #2

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

Similar topics

6
by: Chris Smith | last post by:
This is a bit of a weird problem. Unfortunately, I can't reproduce it in a simple example, so I can only poke it out there and see if anyone has seen something similar. I have a script that...
1
by: Henri Sivonen | last post by:
I got the following error: Error: " nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" .... with Firefox when using XMLHttpRequest. What's happenening? Is the object being garbage collected...
4
by: one man army | last post by:
Hi All- after reading a bit more, and writing a few examples, I have begun a project which really uses the Dynamic data loading. BUT when I tried the code out, I get 'permission denied' in...
13
by: TLaufenberg | last post by:
I'm new to Javascript programming and I've run into a bit of a snag with making an XMLHttpRequest in the Safari browser. Actually, the request doesn't work in Firefox either but only when I use a...
5
by: Peter Michaux | last post by:
Hi, The FAQ correctly says the following: "Mozilla (NN6.2+, Firefox, Ice Weasle etc), Opera 7.6+, Safari1.2+, the Windows version of IE versions 5+, and some other browsers provide the XML...
1
by: Charlie | last post by:
I am trying to make an XMLHttpRequest which violates the default "same- origin"policy in Firefox. I checked the archives and found a method that should work but it does not. Below is the test code...
7
RMWChaos
by: RMWChaos | last post by:
Bizarro, that's all I can say. Aren't FF2.0.0.8 and NN9 both Mozilla 2 based browsers? So why would the exact same code work in one and not the other? To add insult to injury, it works just fine in...
1
by: Iain Adams | last post by:
My code is as follows. http_request = false; if (window.XMLHttpRequest) { alert("firefox"); http_request = new XMLHttpRequest(); } // IE else if (window.ActiveXObject) { alert("ie");
8
by: sbettadpur | last post by:
hello I am using xmlHttpRequest method in my application, this method is giving problem in the following browsers 1) Internet Explorer 7 2) Mozila Firefox(2.0.0.16) I got solution for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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...

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.