Solved

Server.CreateObject("Msxml2.ServerXMLHTTP") not working

Posted on 2013-01-12
11
2,641 Views
Last Modified: 2013-05-02
I have an ASP.NET page hosted on IIS 7 which used to work fine, making an Ajax call to a remote SMS gateway which parses a string, sends an SMS message and returns a status code. The ASP page no longer works and it appears the issue lies with creating the object within my ASP page. The code in question looks similar to this...

Dim MobNum As String
Dim objXmlHttp
Dim strHTML As String
Dim statusresponse As String
                
MobNum = "+447977123456"
objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
strHTML = "https://www.mysms.com/gateway/xyz.aspx?" & _
		"&destination=" & MobNum & _
		"&message=Foo" & _
				
' resolve, connect, send, receive - in milliseconds 
objXmlHttp.setTimeouts(10000, 10000, 10000, 10000)

objXmlHttp.open("GET", strHTML, False)
objXmlHttp.send()
statusresponse = objXmlHttp.ResponseText
objXmlHttp = Nothing

Open in new window


Loading my ASP page in the browser, I get an error after around 10 secs stating "A connection with the server could not be established", highlighting the line objXmlHttp.send().

I have executed the call to the remote server simply placing the Ajax string in my browser and it works fine, the SMS is sent and I get the response code. I have also set up a Stored Procedure to execute the same Ajax call and it also works fine, sending the SMS and returning the response code. So, the issue seems to lie somewhere within my ASP page/IIS instance, and specifically with Server.CreateObject("Msxml2.ServerXMLHTTP").

Any ideas?
0
Comment
Question by:drl1
  • 6
  • 5
11 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38770375
Is this ASP.NET or classic ASP (you tagged this as the former)?
0
 

Author Comment

by:drl1
ID: 38770388
The original page is the former. I'm also running some testing in classic and get the same issue.
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 38770400
If it's ASP.NET, then why not just use the XmlDocument class?

If you must stick with late binding, then try the example demonstrated here:  http://msdn.microsoft.com/en-us/library/windows/desktop/ms766431(v=vs.85).aspx
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:drl1
ID: 38770410
I will look in to that however I would still like to understand why the code that used to work is no longer functioning. When using the same approach within a Stored Procedure fired from SQL on another physical server it works fine, so this appears to be something specific to IIS/this box and the object creation. Can you offer some thoughts on that point?
0
 

Author Comment

by:drl1
ID: 38770440
If it helps, when I comment out all of the objXmlHttp code beneath...objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP") I still get the error. So...

Dim MobNum As String
Dim objXmlHttp
Dim strHTML As String
Dim statusresponse As String
                
MobNum = "+447977123456"
objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
strHTML = "https://www.mysms.com/gateway/xyz.aspx?" & _
		"&destination=" & MobNum & _
		"&message=Foo" & _
				
' resolve, connect, send, receive - in milliseconds 
'objXmlHttp.setTimeouts(10000, 10000, 10000, 10000)

'objXmlHttp.open("GET", strHTML, False)
'objXmlHttp.send()
'statusresponse = objXmlHttp.ResponseText
'objXmlHttp = Nothing 

Open in new window


As soon as that line of code (objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
) is also commented out, I get no error. So it appears the problem stems from creating the object.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38770453
The only discrepancy I see from the link I posted is that you have the version number following "XMLHTTP". Perhaps a system update updated that library, causing the code to break.
0
 

Author Comment

by:drl1
ID: 38770559
This throws no error...

Dim MobNum As String
Dim objXmlHttp
Dim strHTML As String
Dim statusresponse As String
                
MobNum = "+447977123456"
set objXmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP")
strHTML = "https://www.mysms.com/gateway/xyz.aspx?" & _
		"&destination=" & MobNum & _
		"&message=Foo" & _
				
' resolve, connect, send, receive - in milliseconds 
' objXmlHttp.setTimeouts(10000, 10000, 10000, 10000)

' objXmlHttp.open("GET", strHTML, False)
' objXmlHttp.send()
' statusresponse = objXmlHttp.ResponseText
objXmlHttp = Nothing  

Open in new window


As soon as I try to assign any attributes to the object (e.g. just uncommenting the objXmlHttp.setTimeouts line) the page returns an error.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38770578
Have you tried it like this yet?

set objXmlHttp = Server.CreateObject ("Msxml2.ServerXMLHTTP.6.0")

Open in new window

0
 

Author Comment

by:drl1
ID: 38770586
Yes and it makes no difference. Using Microsoft.XMLHTTP from within the SPROC on my SQL server, and passing all the same attributes and Ajax call as above works fine. I don't get why this ASP page on IIS no longer works.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38770743
What user is your site running as under IIS: One of the system accounts, or a user you crated?
0
 

Author Comment

by:drl1
ID: 38770764
The Application Pool is running under the default ApplicationPoolIdentity account. Should this be changed to Local System in order that the object can be manipulated correctly?
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question