Solved

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

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

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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

What is an ISAPI filter?   •      It's an assembly (.dll file) that can add or change the way IIS works.   •      They can be enabled globally for your web server or on a site-by-site basis.   When the IIS server receives a request, enabling the ISAPI fi…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

910 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now