Quickbooks Web 连接器 "Response is not well-formed XML" 错误

Quickbooks Web Connector "Response is not well-formed XML" error

我们将 Quickbooks Web 连接器 (QBWC) 与 Consolibyte Quickbooks PHP 开发工具包一起使用。我们已经在 QBWC 工作中使用该软件 4 年,没有出现重大问题;但是,现在我们正在添加一个额外的 QBWC 作业来访问不同的 QB 公司文件和不同的处理程序。每次运行此作业时都会出现错误“响应格式不正确 XML”:

20211117.18:47:19 UTC   : QBWebConnector.RegistryManager.getUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock = FALSE
20211117.18:47:19 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to True
20211117.18:47:19 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session locked *********************
20211117.18:47:19 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : Initiated connection to the following application.
20211117.18:47:19 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppName: SCS Consulting QB Integrator Prod 2
20211117.18:47:19 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppUniqueName (if available): SCS Consulting QB Integrator Prod 2
20211117.18:47:19 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppURL: https://nest.scscertified.com/quickbooks/qbwc_integrator.php?legal_entity=scs_consulting
20211117.18:47:19 UTC   : QBWebConnector.SOAPWebService.do_serverVersion() : *** Calling serverVersion().
20211117.18:47:20 UTC   : QBWebConnector.SOAPWebService.do_serverVersion() : Actual error received from web service for serverVersion call: <Response is not well-formed XML.>. For backward compatibility of all webservers, QBWC will catch all errors under app-not-supporting-serverVersion.
20211117.18:47:20 UTC   : QBWebConnector.SOAPWebService.do_serverVersion() : This application does not contain support for serverVersion. Allowing update operation for backward compatibility.
20211117.18:47:20 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : *** Calling clientVersion() with following parameter:<productVersion="2.2.0.71">
20211117.18:47:20 UTC   : QBWebConnector.SOAPWebService.updateWS() : Actual error received from web service for clientVersion call: <Response is not well-formed XML.>. For backward compatibility of all webservers, QBWC will catch all errors under app-not-supporting-clientVersion.
20211117.18:47:20 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : This application does not contain support for clientVersion. Allowing update operation for backward compatibility.
20211117.18:47:20 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : Authenticating to application 'SCS Consulting QB Integrator Prod 2', username = 'scsc_qb'
20211117.18:47:20 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : *** Calling authenticate() with following parameters:<userName="scsc_qb"><password=<MaskedForSecurity>
20211117.18:47:21 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : QBWC1012: Authentication failed due to following error message.
Response is not well-formed XML.

错误从 serverVersion() 开始,但作业实际上并没有失败,直到 authenticate()。看来问题出在 PHP 处理程序中;但是,它没有记录任何错误,并且开发工具包日志 table 显示正确的 XML:

 | Handler is starting up...: Array
(
    [qb_company_file] => 
    [qbwc_min_version] => 
    [qbwc_wait_before_next_update] => 
    [qbwc_min_run_every_n_seconds] => 
    [qbwc_version_warning_message] => 
    [qbwc_version_error_message] => 
    [qbwc_interactive_url] => 
    [autoadd_missing_requestid] => 1
    [check_valid_requestid] => 1
    [server_version] => PHP QuickBooks SOAP Server v3.0 at /quickbooks/qbwc_integrator.php?legal_entity=scs_consulting
    [authenticate] => 
    [authenticate_dsn] => 
    [map_application_identifiers] => 1
    [allow_remote_addr] => Array
        (
        )

    [deny_remote_addr] => Array
        (
        )

    [convert_unix_newlines] => 1
    [deny_concurrent_logins] => 
    [deny_concurrent_timeout] => 60
    [deny_reallyfast_logins] => 
    [deny_reallyfast_timeout] => 600
    [masking] => 1
)

 | 2021-11-17 10:47:20
|-
 | 697
 | 
 | 0
 | Incoming HTTP Headers: User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 4.0.30319.42000)
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://developer.intuit.com/serverVersion"
Host: nest.scscertified.com
Content-Length: 300
Expect: 100-continue
Connection: Keep-Alive

 | 2021-11-17 10:47:20
|-
 | 698
 | 
 | 0
 | Incoming SOAP Request: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><serverVersion xmlns="http://developer.intuit.com/" /></soap:Body></soap:Envelope>
 | 2021-11-17 10:47:20
|-
 | 699
 | 
 | 0
 | serverVersion()
 | 2021-11-17 10:47:20
|-
 | 700
 | 
 | 0
 | Outgoing SOAP Response: <?xml version="1.0" encoding="UTF-8"?>
            <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" 
             xmlns:ns1="http://developer.intuit.com/">
                <SOAP-ENV:Body><ns1:serverVersionResponse><ns1:serverVersionResult>PHP QuickBooks SOAP Server v3.0 at /quickbooks/qbwc_integrator.php?legal_entity=scs_consulting</ns1:serverVersionResult></ns1:serverVersionResponse>
            </SOAP-ENV:Body>
            </SOAP-ENV:Envelope>

我不明白的是 PHP 处理程序对 serverVersion() 的 XML 响应看起来很好(实际上与工作处理程序返回的 XML 相同,除了URL),并且此处理程序未记录任何错误,但 QBWC 拒绝它。

已解决 - XML 对 QBWC 的响应在 XML 声明之前有一个额外的换行符,这导致 QBWC 完全拒绝它。额外字符的来源是一个 PHP 配置文件,在第一个 <?php 标记之前有一个空行。呸!