Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-01-12
11
Medium Priority
?
2,942 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

636 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