473,581 Members | 2,915 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Simple ASP scripting question?

I'm not that great with ASP but I've hacked together a simple server
side script that uses the Microsoft XML ServerXMLHTTP object. The
problem is that when other people use the script sometimes they get an
error that the object can not be created, due likely to the required
Microsoft XML libraries not being installed. I'd like to try creating
the XMLHTTP object in an if/else block so that if the object can not be
created then it tries another object creation approach... here is the
code I'm using to create the object:

var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP.4.0");

The above line often fails because the object doesn't exist so I would
like to trap the error and try to create the object like:

var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP");

Can someone provide me with the code snippet that will result in the
variable objSrvHTTP having a ServerXMLHTTP object inside that works?
Also, if there are other variations on that object name then please
include those objects as well...

FYI, I'm only using open, setRequestHeade r, send and responseText
methods on the object.

Thanks,
Cliff.

Aug 24 '06 #1
7 7973


Cliff wrote:

var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP.4.0");

The above line often fails because the object doesn't exist so I would
like to trap the error and try to create the object like:

var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP");
var progIds = [
'Msxml2.ServerX MLHTTP.4.0',
'Msxml2.ServerX MLHTTP.3.0',
'Msxml2.ServerX MLHTTP'
];
var httpRequest = null;
for (var i = 0, l = progIds.length; i < l; i++) {
try {
httpRequest = new ActiveXObject(p rogIds[i]);
break;
}
catch (e) {}
}
if (httpRequest != null) {
// make your request here
}
else {
// no object found
}

There are also MSXML 5 and 6 so depending on what you do expect on the
server you could use e.g.

var progIds = [
'Msxml2.ServerX MLHTTP.6.0',
'Msxml2.ServerX MLHTTP.5.0',
'Msxml2.ServerX MLHTTP.4.0',
'Msxml2.ServerX MLHTTP.3.0',
'Msxml2.ServerX MLHTTP'
];
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 24 '06 #2
Try using the generic object:

var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP");

Brian
Aug 24 '06 #3
"Cliff" <cl***@thesolut ioncafe.comwrot e in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
I'm not that great with ASP but I've hacked together a simple server
side script that uses the Microsoft XML ServerXMLHTTP object. The
problem is that when other people use the script sometimes they get an
error that the object can not be created, due likely to the required
Microsoft XML libraries not being installed. I'd like to try creating
the XMLHTTP object in an if/else block so that if the object can not be
created then it tries another object creation approach... here is the
code I'm using to create the object:

var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP.4.0");

The above line often fails because the object doesn't exist so I would
like to trap the error and try to create the object like:

var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP");

Can someone provide me with the code snippet that will result in the
variable objSrvHTTP having a ServerXMLHTTP object inside that works?
Also, if there are other variations on that object name then please
include those objects as well...

FYI, I'm only using open, setRequestHeade r, send and responseText
methods on the object.
Will this help? You can test is as-is.

<html>
<head>
<title>xmlhttpx .html</title>
<script type="text/javascript">
function getRequestObj() {
var ret = null;
var xml = [
"MSXML2.XMLHTTP .5.0",
"MSXML2.XMLHTTP .4.0",
"MSXML2.XMLHTTP .3.0",
"MSXML2.XMLHTTP ",
"Microsoft.XMLH TTP"];
if (window.ActiveX Object) {
for (var i=0; i<xml.length; i++) {
try {
ret = new ActiveXObject(x ml[i]);
break;
} catch(e) {}
}
} else if(window.XMLHt tpRequest) {
try {
ret = new XMLHttpRequest( );
} catch(e) {}
}
return ret;
}

var sURL = "http://www.gabocorp.co m/";
var oXML = getRequestObj() ;
oXML.open("GET" ,sURL,false);
oXML.send();

alert(oXML.resp onseText);
</script>
</head>
<body>
</body>
</html>
Also, check out this link:

Identify which components are installed on the server.
<URL:
http://www.planet-source-code.com/vb...odeId=8976&lng
WId=4>

It can be adapted to run on any user's PC as a VBS file instead of ASP.
Just remove "<%", "%>", "Server.", and "<BR>"
and change "Response.Write " to "WScript.Ec ho"
then save it as "Components.vbs " and run it via the command line
"cscript.ex e //nologo Components.vbs Components.txt"
Aug 24 '06 #4
This looks like it worked perfectly. Is there any advantage or
disadvantage to the order of object creation, for example, are newer
versions of the object more security constrained? Also, is it possible
to avoid going through the loop each time the page is called once the
appropriate library has been determined?

Cliff.
Martin Honnen wrote:
Cliff wrote:

var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP.4.0");

The above line often fails because the object doesn't exist so I would
like to trap the error and try to create the object like:

var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP");

var progIds = [
'Msxml2.ServerX MLHTTP.4.0',
'Msxml2.ServerX MLHTTP.3.0',
'Msxml2.ServerX MLHTTP'
];
var httpRequest = null;
for (var i = 0, l = progIds.length; i < l; i++) {
try {
httpRequest = new ActiveXObject(p rogIds[i]);
break;
}
catch (e) {}
}
if (httpRequest != null) {
// make your request here
}
else {
// no object found
}

There are also MSXML 5 and 6 so depending on what you do expect on the
server you could use e.g.

var progIds = [
'Msxml2.ServerX MLHTTP.6.0',
'Msxml2.ServerX MLHTTP.5.0',
'Msxml2.ServerX MLHTTP.4.0',
'Msxml2.ServerX MLHTTP.3.0',
'Msxml2.ServerX MLHTTP'
];
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 25 '06 #5


Cliff wrote:
Is there any advantage or
disadvantage to the order of object creation, for example, are newer
versions of the object more security constrained?
There are differences, consult the MSXML SKD for details, it is online here
<http://msdn.microsoft. com/library/default.asp?url =/library/en-us/dnanchor/html/anch_xmlprod.as p>
Also, is it possible
to avoid going through the loop each time the page is called once the
appropriate library has been determined?
Change the code to store the program id that could be successfully
created and used that program id from there one.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Aug 25 '06 #6

"Cliff" <cl***@thesolut ioncafe.comwrot e in message
news:11******** *************@i 42g2000cwa.goog legroups.com...
I'm not that great with ASP but I've hacked together a simple server
side script that uses the Microsoft XML ServerXMLHTTP object. The
problem is that when other people use the script sometimes they get an
error that the object can not be created, due likely to the required
Microsoft XML libraries not being installed. I'd like to try creating
the XMLHTTP object in an if/else block so that if the object can not be
created then it tries another object creation approach... here is the
code I'm using to create the object:

var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP.4.0");

The above line often fails because the object doesn't exist so I would
like to trap the error and try to create the object like:

var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP");

Can someone provide me with the code snippet that will result in the
variable objSrvHTTP having a ServerXMLHTTP object inside that works?
Also, if there are other variations on that object name then please
include those objects as well...

FYI, I'm only using open, setRequestHeade r, send and responseText
methods on the object.
I just stick with MSXML2.ServerXM LHTTP.3.0 it's always there on Win2K above
and I know exactly what I'm getting and what it can and can't do.
Thanks,
Cliff.

Aug 29 '06 #7
Cliff.
Martin Honnen wrote:
Cliff wrote:

var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP.4.0");
>
The above line often fails because the object doesn't exist so I would
like to trap the error and try to create the object like:
>
var objSrvHTTP=Serv er.CreateObject ("MSXML2.Server XMLHTTP");
var progIds = [
'Msxml2.ServerX MLHTTP.4.0',
'Msxml2.ServerX MLHTTP.3.0',
'Msxml2.ServerX MLHTTP'
];
var httpRequest = null;
for (var i = 0, l = progIds.length; i < l; i++) {
try {
httpRequest = new ActiveXObject(p rogIds[i]);
break;
}
catch (e) {}
}
if (httpRequest != null) {
// make your request here
}
else {
// no object found
}

There are also MSXML 5 and 6 so depending on what you do expect on the
server you could use e.g.

var progIds = [
'Msxml2.ServerX MLHTTP.6.0',
'Msxml2.ServerX MLHTTP.5.0',
'Msxml2.ServerX MLHTTP.4.0',
'Msxml2.ServerX MLHTTP.3.0',
'Msxml2.ServerX MLHTTP'
];
Cliff wrote:
This looks like it worked perfectly. Is there any advantage or
disadvantage to the order of object creation, for example, are newer
versions of the object more security constrained? Also, is it possible
to avoid going through the loop each time the page is called once the
appropriate library has been determined?
Why even do that? I mean, the object is on the server, not the client.
Just figure out which one you have on your server and store it in an
application variable.

If you maintain your own server, it's even easier, since you should
know what libraries are on it and if/when they're updated.

Aug 29 '06 #8

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

Similar topics

2
1727
by: Trimbitas Sorin | last post by:
Hello I have a simple syntax question : What does the following line mean: 1: %checkType; ?? I know that @test="" is an array and $test="" is a simple variable. Thank you With best regards Trimbitas Sorin
13
2248
by: Jason Swett | last post by:
I want to do graphics with C++. Surprisingly, so far nobody has been able to tell me anything helpful. How do I do it? Any input would be greatly appreciated. Jason
51
8250
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct code? many thx!
3
1542
by: msnews.microsoft.com | last post by:
Hello All, In the "Find Dialog" (Ctrl-F) of the IDE there is an option called "Mark All". When I click "Mark All", this marks the occurences of my search text. How will I clear this mark? Thanks for your time.
7
6340
by: Scott Frankel | last post by:
Still too new to SQL to have run across this yet ... How does one return the latest row from a table, given multiple entries of varying data? i.e.: given a table that looks like this: color | date --------+------------ red | 2004-01-19 blue | 2004-05-24
1
1532
by: adam | last post by:
I have a simple form question. I order to access a payment gateway I have a asp.net page which has to have a form that use POST for method and _blank for target. Before the information of the form can be send of, a checksum has to be calculated. I want to calculate the checksum server side for security reasons. The way I do it the checksum is...
6
2028
by: Jim M | last post by:
I've been distributing a fairly mature, very specific MS Access application to end users in small offices of colleges for several years now. This is a part-time venture and low volume operation- this is somewhat of a hobby for me. Many of my end users are computer phobic and get little support from their IT departments. It is a split database...
3
2321
by: Chrism2671 | last post by:
I'm new to XSLT/XML and I have a very simple, quick question. i've been trying to convert simple xml files into CSV files and have made a simple XSLT template using the w3 tutorials, but it doesn't seem to display anything. It does display plain text I enter into the templates, the value-of tags just render whitespace. If anybody can write...
3
2302
by: Ashik | last post by:
I have a simple compilation question, but I haven't been able to find an answer for it anywhere online. I've made a simplified version of my problem using a few files. The main problem is that when I try compiling my code using gcc in cygwin, I get this error: $ make gcc -L C:/temp/ -o askForHelp askForHelp.c...
5
1191
by: Oriane | last post by:
Hi, With Asp.net 2.0, when a internet user logs in with a "login authentication form", is the password encrypted when it is sent to the server ? Is is hashed ? Best regards
0
7883
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7808
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8158
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8312
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6567
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5366
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1413
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1147
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.