Problems with msxml2.http request

Posted on 2008-11-19
Last Modified: 2012-05-05
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

Question by:mdward4
    LVL 18

    Expert Comment

    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.
    LVL 1

    Accepted Solution

    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.
    LVL 18

    Expert Comment

    What was the solution?

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
    I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
    Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    746 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

    20 Experts available now in Live!

    Get 1:1 Help Now