Solved

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

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

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 74

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 74

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 74

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 74

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

21 Experts available now in Live!

Get 1:1 Help Now