4

I started getting this error on our production Windows 2012 server running IIS 8.5:

Microsoft VBScript runtime error '800a01a8'

Object required: 'MERCHANTmydoc.documentElement'

The error seems to occur on this line:

Set MERCHANTmydoc=Server.CreateObject("Microsoft.xmlDOM")

No code was changed and the API has not changed (according to merchant support) when this started. I tested this same API string (inserting valid values) with Postman and got a valid reply, so I know the credentials work. I am beginning to suspect an issue with IIS, but don't know how to proceed.

MERCHANTstrXML = "<txn><ssl_merchant_ID>" & MERCHANT_ID & "</ssl_merchant_ID><ssl_user_id>" & MERCHANT_USER & "</ssl_user_id><ssl_pin>" & MERCHANT_PIN & "</ssl_pin><ssl_transaction_type>ccsale</ssl_transaction_type><ssl_card_number>" & merchant_card_number & "</ssl_card_number><ssl_exp_date>" & merchant_exp_date & "</ssl_exp_date><ssl_amount>" & merchant_trans_amount & "</ssl_amount><ssl_salestax>" & merchant_sales_tax & "</ssl_salestax>" & merch_indicator_var & "<ssl_cvv2cvc2>" & merchant_cvv2_code & "</ssl_cvv2cvc2><ssl_invoice_number>" & merchant_invoice_number & "</ssl_invoice_number><ssl_customer_code>" & merchant_customer_code & "</ssl_customer_code><ssl_first_name>" & merchant_first_name & "</ssl_first_name><ssl_last_name>" & merchant_last_name & "</ssl_last_name><ssl_avs_address>" & merchant_add1 & "</ssl_avs_address><ssl_avs_zip>" & merchant_zip & "</ssl_avs_zip><ssl_email>" & merchant_email & "</ssl_email><ssl_test_mode>" & MERCHANT_Test_Mode & "</ssl_test_mode></txn>"
        
if session("CHARGED") = "YES" then
    'Do nothing
else
    Set MERCHANTxmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP")

MERCHANTxmlhttp.Open "POST","https://api.convergepay.com/VirtualMerchant/processxml.do?xmldata=" & MERCHANTstrXML,false

MERCHANTxmlhttp.send 

MERCHANTresponsexml = MERCHANTxmlhttp.responseText  

Set MERCHANTmydoc=Server.CreateObject("Microsoft.xmlDOM")
MERCHANTmydoc.async= false
MERCHANTmydoc.loadxml(MERCHANTresponsexml)

I found a script to test xml requests and got this error: Sending XML data to http://localhost:8096/cart/receive3.asp msxml3.dll error '80072efd'

A connection with the server could not be established

/cart/post3.asp, line 12

These are the scripts I used

<%

    '// URL to which to send XML data
    URL="http://localhost:8096/cart/receive3.asp"

    Response.Write "Sending XML data to " & URL & "<br/>"

    information = "<Send><UserName>test</UserName><PassWord>user</PassWord><Data>100</Data></Send>"
    Set xmlhttp = server.Createobject("MSXML2.ServerXMLHTTP")
    xmlhttp.Open "POST", url, false
    xmlhttp.setRequestHeader "Content-Type", "text/xml" 
    xmlhttp.send information

    '// Report the response from the called page
    response.write "Response received:<hr/><span style='color:blue'>" & xmlhttp.ResponseText & "</span><hr/>"

%>
<%

    Dim objXmlRequest
    Set objXmlRequest = Server.CreateObject("MSXML2.DOMDOCUMENT.3.0")

    IF objXmlRequest.Load (Request) THEN

      'GET THE REQUEST FROM CLIENT
      strQuery = "//UserName"
      Set oNode = objXmlRequest.selectSingleNode(strQuery)
      strActionName = oNode.Text
      response.write "success! user name is " & strActionName  

    ELSE

        Response.Write "Failed to load XML file, reason: " & objXmlRequest.parseError.reason 

    END IF
%>
user692942
  • 16,398
  • 7
  • 76
  • 175
  • Do you check the response status (`MERCHANTxmlhttp.Status`) before attempting to load the XML? The one thing you don’t have control of is the end point you are calling, perhaps something as changed and you are no longer getting the response you are expecting? – user692942 Sep 24 '22 at 07:09
  • No, I did not check the status. The company claims that the API has not changed. I did test the same XML string in Postman and it is a valid string. – Thomas Milliken Sep 24 '22 at 20:02
  • Originally it was erroring because it was trying to load XML but the response (I suspect) wasn’t returning XML. With those testing scripts you’ve changed too many variables hence different errors. Instead you should stick with the original script and just try and output the raw response text to see what you get back, rather than assuming it’s XML. Something like `Response.Write MERCHANTresponsexml` and you could also output the HTTP Status code with `Response.Write MERCHANTxmlhttp.Status`. – user692942 Sep 24 '22 at 22:44
  • I am getting a 400 status when I added "response.write MERCHANTxmlhttp.Status" after sending the request. – Thomas Milliken Sep 25 '22 at 17:12
  • So the problem is the request, a `400 Bad Request` means the request has been rejected by the remote server because it’s malformed. What about `MERCHANTresponsexml`? – user692942 Sep 25 '22 at 22:39
  • Try using failed request tracing to see details about 400 error. – samwu Sep 26 '22 at 02:44
  • @samwu the `responseText` should tell you that. – user692942 Sep 26 '22 at 08:41
  • I did try to print the response text and nothing displays. If my server was not able to send the request, would it generate the 400 error or would that only come from the server I am sending the request to? – Thomas Milliken Sep 26 '22 at 17:37
  • It should be coming from the server the request was sent to. That is the purpose of 400 range errors, they are client errors that represent an issue with the request that was sent. – user692942 Sep 26 '22 at 21:40

2 Answers2

1

The solution was to change the way the API request was being sent. The credit card provider changed their API and didn't inform their support reps. This is the code that finally worked:

MERCHANTxmlhttp.Open "POST","https://api.convergepay.com/VirtualMerchant/processxml.do",false
        
MERCHANTxmlhttp.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"

MERCHANTxmlhttp.Send Server.urlEncode(MERCHANTstrXML)
user692942
  • 16,398
  • 7
  • 76
  • 175
  • So as suspected the API had changed even though the company claimed it didn’t. Glad you finally found the solution. – user692942 Sep 27 '22 at 21:11
0

The actual cause of the Object required (which was the initial question) is to do with the assumptions being made about the call out to the 3rd party API.

After calling Send() on the XmlHttp object you should always check what is being returned before doing anything with it, the easiest way is to check the Status in the response that is returned.

Option Explicit
Dim request_xml: request_xml= "..." 'Assumed valid XML
Dim xhr: Set xhr = Server.CreateObject("MSXML2.ServerXMLHTTP")
Call xhr.Open ("POST","https://api.convergepay.com/VirtualMerchant/processxml.do?xmldata=" & request_xml, False)
Call xhr.Send()

'Check we have a success HTTP response code.
If Left(xmlhttp.Status, 1) = 2 Then
  Dim response_xml: response_xml = xhr.responseText
  Dim xml: Set xml = Server.CreateObject("Microsoft.XMLDOM")
  xml.Async= False
  Call xml.LoadXml(response_xml)
Else
  Call Response.Write("Error calling API - " & xhr.Status)
End If

The error occurs because the API is not sending back a valid XML response so LoadXml() fails. This means when calling MERCHANTmydoc.documentElement the MERCHANTmydoc isn't instantiated.


Useful Links

user692942
  • 16,398
  • 7
  • 76
  • 175