<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic E00003 – An error occurred while parsing the XML request...I don't send XML in Integration and Testing</title>
    <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/E00003-An-error-occurred-while-parsing-the-XML-request-I-don-t/m-p/68647#M41812</link>
    <description>&lt;P&gt;How could I get an XML parsing error when I don't send XML.&amp;nbsp; Here is my Authorize.Net ACH Processing function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    Private Function AuthNet_ACH(ByVal oGtwy As Gateway,
                                 ByVal oInv As InvoiceDet,
                                 ByVal oACHDet As ACHDet) As Results
        Try
            '* Set the security protocol
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
            System.Net.ServicePointManager.ServerCertificateValidationCallback = (Function(sender, certificate, chain, sslPolicyErrors) True)

            '* Create the request
            If oGtwy.TestMode Then
                ApiOperationBase(Of ANetApiRequest, ANetApiResponse).RunEnvironment = AuthorizeNet.Environment.SANDBOX
            Else
                ApiOperationBase(Of ANetApiRequest, ANetApiResponse).RunEnvironment = AuthorizeNet.Environment.PRODUCTION
            End If
            ApiOperationBase(Of ANetApiRequest, ANetApiResponse).MerchantAuthentication = New merchantAuthenticationType() With {
                .name = oGtwy.LoginID,
                .ItemElementName = ItemChoiceType.transactionKey,
                .Item = oGtwy.Password
                }

            Dim bankAccount As New bankAccountType
            Select Case oACHDet.AcctType
                Case ACHDet.AcctTypes.S
                    bankAccount.accountType = bankAccountTypeEnum.savings
                Case Else
                    bankAccount.accountType = bankAccountTypeEnum.checking
            End Select
            bankAccount.routingNumber = oACHDet.ABA
            bankAccount.accountNumber = oACHDet.AcctNum
            bankAccount.nameOnAccount = oACHDet.AcctName
            Select Case oACHDet.AuthType
                Case ACHDet.AuthTypes.ARC
                    bankAccount.echeckType = echeckTypeEnum.ARC
                Case ACHDet.AuthTypes.BOC
                    bankAccount.echeckType = echeckTypeEnum.BOC
                Case ACHDet.AuthTypes.CCD
                    bankAccount.echeckType = echeckTypeEnum.CCD
                Case ACHDet.AuthTypes.PPD
                    bankAccount.echeckType = echeckTypeEnum.PPD
                Case ACHDet.AuthTypes.TEL
                    bankAccount.echeckType = echeckTypeEnum.TEL
                Case Else
                    bankAccount.echeckType = echeckTypeEnum.WEB
            End Select
            'bankAccount.bankName = "Wells Fargo Bank NA"

            Dim paymentType = New paymentType With {
                .Item = bankAccount
                }

            Dim transRequest As New transactionRequestType
            transRequest.amount = oInv.Amount

            Dim arrSettings As New List(Of settingType)
            arrSettings.Add(New settingType With {
                                .settingName = settingNameEnum.emailCustomer.ToString,
                                .settingValue = oGtwy.SendEmail
                                })
            arrSettings.Add(New settingType With {
                                .settingName = settingNameEnum.headerEmailReceipt.ToString,
                                .settingValue = oGtwy.EmailHeader.ToString
                                })
            arrSettings.Add(New settingType With {
                                .settingName = settingNameEnum.footerEmailReceipt.ToString,
                                .settingValue = oGtwy.EmailFooter.ToString
                                })

            Select Case oACHDet.TransType
                Case TransTypes.SALE
                    transRequest.transactionType = transactionTypeEnum.authCaptureTransaction.ToString
                Case TransTypes.VOID
                    'transRequest.transactionType = transactionTypeEnum.voidTransaction.ToString
                    transRequest.transactionType = transactionTypeEnum.refundTransaction.ToString
                    transRequest.refTransId = oACHDet.PNRef.ToString
                Case TransTypes.CRED
                    transRequest.transactionType = transactionTypeEnum.refundTransaction.ToString
                    transRequest.refTransId = oACHDet.PNRef.ToString
                Case Else   '* Use Authorize as the Default
                    transRequest.transactionType = transactionTypeEnum.authOnlyTransaction.ToString
                    transRequest.amount = 0.01D
                    arrSettings(0).settingValue = False
            End Select

            transRequest.transactionSettings = arrSettings.ToArray
            transRequest.payment = paymentType
            transRequest.lineItems = Nothing

            Dim arrFields As New List(Of userField)
            arrFields.Add(New userField With {
                            .name = "Market",
                            .value = oInv.Comment1.Split(":")(0)
                            })
            arrFields.Add(New userField With {
                            .name = "AcctName",
                            .value = oInv.Comment1.Split(":")(1)
                            })
            arrFields.Add(New userField With {
                            .name = "AcctNum",
                            .value = oInv.Comment2.ToString
                            })
            transRequest.userFields = arrFields.ToArray

            Dim Cust = New customerDataType With {
                .email = oInv.EmailAddr.ToString
                }
            transRequest.customer = Cust

            Dim request = New createTransactionRequest With {
                .transactionRequest = transRequest
                }

            ' Step 3 - Send the request to the gateway
            Dim controller = New createTransactionController(request)
            controller.Execute()
            Dim Resp = controller.GetApiResponse()

            If Not Resp Is Nothing Then
                Dim oResp As Results = New Results(DirectCast(Resp, createTransactionResponse))

                Try
                    If ConfigurationManager.AppSettings("AUTHNET_RES_LOG") IsNot Nothing Then
                        If CBool(ConfigurationManager.AppSettings("AUTHNET_RES_LOG")) Then
                            SimpleLog.WriteLog(oResp)
                        End If
                    End If
                Catch ex As Exception
                End Try

                Return oResp
            Else
                Dim oRes = New Results
                Dim errorResponse As ANetApiResponse = controller.GetErrorResponse()

                If errorResponse.messages.message.Length &amp;gt; 0 Then
                    oRes.Response = "Controller_Name Creation Failed."
                    oRes.RespMsg = "Error message: " &amp;amp; errorResponse.messages.message(0).text
                    oRes.Result = errorResponse.messages.message(0).code
                Else
                    oRes.Response = "Null Response."
                End If

                Return oRes
            End If

        Catch ex As Exception
            SimpleLog.WriteLog(ex)
            Throw CustomException(ex)
        End Try
    End Function&lt;/PRE&gt;&lt;P&gt;And here's the fun part.&amp;nbsp; Sometimes it works...sometimes it doesn't.&amp;nbsp; Works all the time for most clients, and sporadically for one client.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 06 Aug 2019 15:23:01 GMT</pubDate>
    <dc:creator>SSirica</dc:creator>
    <dc:date>2019-08-06T15:23:01Z</dc:date>
    <item>
      <title>E00003 – An error occurred while parsing the XML request...I don't send XML</title>
      <link>https://community.developer.cybersource.com/t5/Integration-and-Testing/E00003-An-error-occurred-while-parsing-the-XML-request-I-don-t/m-p/68647#M41812</link>
      <description>&lt;P&gt;How could I get an XML parsing error when I don't send XML.&amp;nbsp; Here is my Authorize.Net ACH Processing function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    Private Function AuthNet_ACH(ByVal oGtwy As Gateway,
                                 ByVal oInv As InvoiceDet,
                                 ByVal oACHDet As ACHDet) As Results
        Try
            '* Set the security protocol
            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12
            System.Net.ServicePointManager.ServerCertificateValidationCallback = (Function(sender, certificate, chain, sslPolicyErrors) True)

            '* Create the request
            If oGtwy.TestMode Then
                ApiOperationBase(Of ANetApiRequest, ANetApiResponse).RunEnvironment = AuthorizeNet.Environment.SANDBOX
            Else
                ApiOperationBase(Of ANetApiRequest, ANetApiResponse).RunEnvironment = AuthorizeNet.Environment.PRODUCTION
            End If
            ApiOperationBase(Of ANetApiRequest, ANetApiResponse).MerchantAuthentication = New merchantAuthenticationType() With {
                .name = oGtwy.LoginID,
                .ItemElementName = ItemChoiceType.transactionKey,
                .Item = oGtwy.Password
                }

            Dim bankAccount As New bankAccountType
            Select Case oACHDet.AcctType
                Case ACHDet.AcctTypes.S
                    bankAccount.accountType = bankAccountTypeEnum.savings
                Case Else
                    bankAccount.accountType = bankAccountTypeEnum.checking
            End Select
            bankAccount.routingNumber = oACHDet.ABA
            bankAccount.accountNumber = oACHDet.AcctNum
            bankAccount.nameOnAccount = oACHDet.AcctName
            Select Case oACHDet.AuthType
                Case ACHDet.AuthTypes.ARC
                    bankAccount.echeckType = echeckTypeEnum.ARC
                Case ACHDet.AuthTypes.BOC
                    bankAccount.echeckType = echeckTypeEnum.BOC
                Case ACHDet.AuthTypes.CCD
                    bankAccount.echeckType = echeckTypeEnum.CCD
                Case ACHDet.AuthTypes.PPD
                    bankAccount.echeckType = echeckTypeEnum.PPD
                Case ACHDet.AuthTypes.TEL
                    bankAccount.echeckType = echeckTypeEnum.TEL
                Case Else
                    bankAccount.echeckType = echeckTypeEnum.WEB
            End Select
            'bankAccount.bankName = "Wells Fargo Bank NA"

            Dim paymentType = New paymentType With {
                .Item = bankAccount
                }

            Dim transRequest As New transactionRequestType
            transRequest.amount = oInv.Amount

            Dim arrSettings As New List(Of settingType)
            arrSettings.Add(New settingType With {
                                .settingName = settingNameEnum.emailCustomer.ToString,
                                .settingValue = oGtwy.SendEmail
                                })
            arrSettings.Add(New settingType With {
                                .settingName = settingNameEnum.headerEmailReceipt.ToString,
                                .settingValue = oGtwy.EmailHeader.ToString
                                })
            arrSettings.Add(New settingType With {
                                .settingName = settingNameEnum.footerEmailReceipt.ToString,
                                .settingValue = oGtwy.EmailFooter.ToString
                                })

            Select Case oACHDet.TransType
                Case TransTypes.SALE
                    transRequest.transactionType = transactionTypeEnum.authCaptureTransaction.ToString
                Case TransTypes.VOID
                    'transRequest.transactionType = transactionTypeEnum.voidTransaction.ToString
                    transRequest.transactionType = transactionTypeEnum.refundTransaction.ToString
                    transRequest.refTransId = oACHDet.PNRef.ToString
                Case TransTypes.CRED
                    transRequest.transactionType = transactionTypeEnum.refundTransaction.ToString
                    transRequest.refTransId = oACHDet.PNRef.ToString
                Case Else   '* Use Authorize as the Default
                    transRequest.transactionType = transactionTypeEnum.authOnlyTransaction.ToString
                    transRequest.amount = 0.01D
                    arrSettings(0).settingValue = False
            End Select

            transRequest.transactionSettings = arrSettings.ToArray
            transRequest.payment = paymentType
            transRequest.lineItems = Nothing

            Dim arrFields As New List(Of userField)
            arrFields.Add(New userField With {
                            .name = "Market",
                            .value = oInv.Comment1.Split(":")(0)
                            })
            arrFields.Add(New userField With {
                            .name = "AcctName",
                            .value = oInv.Comment1.Split(":")(1)
                            })
            arrFields.Add(New userField With {
                            .name = "AcctNum",
                            .value = oInv.Comment2.ToString
                            })
            transRequest.userFields = arrFields.ToArray

            Dim Cust = New customerDataType With {
                .email = oInv.EmailAddr.ToString
                }
            transRequest.customer = Cust

            Dim request = New createTransactionRequest With {
                .transactionRequest = transRequest
                }

            ' Step 3 - Send the request to the gateway
            Dim controller = New createTransactionController(request)
            controller.Execute()
            Dim Resp = controller.GetApiResponse()

            If Not Resp Is Nothing Then
                Dim oResp As Results = New Results(DirectCast(Resp, createTransactionResponse))

                Try
                    If ConfigurationManager.AppSettings("AUTHNET_RES_LOG") IsNot Nothing Then
                        If CBool(ConfigurationManager.AppSettings("AUTHNET_RES_LOG")) Then
                            SimpleLog.WriteLog(oResp)
                        End If
                    End If
                Catch ex As Exception
                End Try

                Return oResp
            Else
                Dim oRes = New Results
                Dim errorResponse As ANetApiResponse = controller.GetErrorResponse()

                If errorResponse.messages.message.Length &amp;gt; 0 Then
                    oRes.Response = "Controller_Name Creation Failed."
                    oRes.RespMsg = "Error message: " &amp;amp; errorResponse.messages.message(0).text
                    oRes.Result = errorResponse.messages.message(0).code
                Else
                    oRes.Response = "Null Response."
                End If

                Return oRes
            End If

        Catch ex As Exception
            SimpleLog.WriteLog(ex)
            Throw CustomException(ex)
        End Try
    End Function&lt;/PRE&gt;&lt;P&gt;And here's the fun part.&amp;nbsp; Sometimes it works...sometimes it doesn't.&amp;nbsp; Works all the time for most clients, and sporadically for one client.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2019 15:23:01 GMT</pubDate>
      <guid>https://community.developer.cybersource.com/t5/Integration-and-Testing/E00003-An-error-occurred-while-parsing-the-XML-request-I-don-t/m-p/68647#M41812</guid>
      <dc:creator>SSirica</dc:creator>
      <dc:date>2019-08-06T15:23:01Z</dc:date>
    </item>
  </channel>
</rss>

