Problems with msxml2.http request

I am testing a hardcoded script to send CC info to our merchant.  Code is below, but when I browse to the page to test, I get the following error from the browser:

The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.


Cannot have multiple DOCTYPE declarations. Error processing resource '

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
The attached code is the only page in the script, please help.
Dim myHTTP 
Dim myResponse
Dim myXML 
'create the object
Set myHTTP = CreateObject("msxml2.xmlhttp")
'define the xml
myXML = "<?xml version=""1.0""?>" & _
	    "<NewOrder>" & _	    
            "<IndustryType>EC</IndustryType>" & _
            "<MessageType>A</MessageType>" & _
            "<BIN>000002</BIN>" & _
	    "<MerchantID>xxx</MerchantID>" & _
	    "<TerminalID>001</TerminalID>" & _
            "<AccountNum>xxx</AccountNum>" & _
	    "<Exp>0111</Exp>" & _
            "<CurrencyCode>840</CurrencyCode>" & _
            "<CurrencyExponent>2</CurrencyExponent>" & _
	    "<CardSecVal>111</CardSecVal>" & _	    
	    "<AVSzip>11111</AVSzip>" & _
	    "<AVSaddress1>xxx</AVSaddress1>" & _
	    "<AVScity>xxx</AVScity>" & _
	    "<AVSstate>OK</AVSstate>" & _     
	    "<AVSphoneNum>xxx</AVSphoneNum>" & _
            "<OrderID>18341834</OrderID>" & _
	    "<Amount>3000</Amount>" & _		    	
'open the connection
myHTTP.Open "post", "", False
'set headers
myHTTP.setRequestHeader "Content-type", "application/PTI21"
myHTTP.setRequestHeader "Document-Type", "Request"
myHTTP.setRequestHeader "Mime-Version", "2.0"
myHTTP.setRequestHeader "Content-Length", Len(myXML)
myHTTP.setRequestHeader "Content-Transfer-Encoding", "text/xml"
myHTTP.setRequestHeader "DTDVersion", "PTI42"
'send the XML
'Display the response
myResponse = myHTTP.Responsetext
response.write myResponse

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

It looks like the processor is returning bad data, or the msxml2.xmlhttp object is doing something odd.

Try these two things:
First, before response.write, send response.contentType = "text/plain".  This might prevent IE from interpreting the xml data as xml, which might let you see what is actually being returned.

Second, don't use the msxml2.xmlhttp on servers.  Use "MSXML2.ServerXMLHTTP.3.0" instead.  The XmlHttp object is not designed for server-side use.
Looks like you are being returned a bad format in the request.

If you added this:
response.AddHeader "Content-Type", "text/xml"
myResponse = "<root><test>badelement</test2></root>"

before your response.write you get the same kind of error (the first part, the second refers to the purposeful error I included). Try viewing the source of what you are being returned. What format do you expect?

As for your example I had to change to
Set myHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
for it to work.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
What was the solution?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.