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
Solved

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

Posted on 2013-01-12
11
2,663 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

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.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

789 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