• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 693
  • Last Modified:

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 'https://www.xxx.com/new/new_cc_processing/Res...

<!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>" & _		    	
	    "</NewOrder>"
 
'open the connection
myHTTP.Open "post", "xxx.com", 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
myHTTP.Send
 
'Display the response
myResponse = myHTTP.Responsetext
response.write myResponse
 
%>

Open in new window

0
mdward4
Asked:
mdward4
  • 2
1 Solution
 
ChetOS82Commented:
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.
0
 
simon_thwaitesCommented:
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.
0
 
ChetOS82Commented:
What was the solution?
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now