QUICKBOOKS_ADD_CUSTOMER函数没有触发(“无数据交换”)

时间:2016-02-03 02:33:06

标签: php quickbooks qbxml

我试图将我的OpenCart与QB Desktop同步。 但它不起作用。 QB Web Connector说"没有数据交换"。

这是我的代码:

// Map QuickBooks actions to handler functions
$map = array(
    QUICKBOOKS_ADD_CUSTOMER => array( '_quickbooks_customer_add_request', '_quickbooks_customer_add_response' ),
);

$errmap = array(
    '*' => '_quickbooks_error_catchall',
);

$hooks = array();

$log_level = QUICKBOOKS_LOG_DEVELOP;

$soapserver = QUICKBOOKS_SOAPSERVER_BUILTIN
$soap_options = array();

$handler_options = array(
    'deny_concurrent_logins' => false,
    'deny_reallyfast_logins' => false,
);      // See the comments in the QuickBooks/Server/Handlers.php file

$driver_options = array(        // See the comments in the QuickBooks/Driver/<YOUR DRIVER HERE>.php file ( i.e. 'Mysql.php', etc. )
    'max_log_history' => 32000, // Limit the number of quickbooks_log entries  to 1024
    'max_queue_history' => 1024,    // Limit the number of *successfully processed* quickbooks_queue entries to 64
);

$callback_options = array();

// Set up our queue singleton
QuickBooks_WebConnector_Queue_Singleton::initialize($dsn);

$Server = new QuickBooks_WebConnector_Server($dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
$response = $Server->handle(true, true);

function _quickbooks_customer_add_request($requestID, $user, $action, $ID,  $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale)
{
// Grab the data from our MySQL database
$arr = array(
    'name' => 'opencart' . date('ymdhis'),
    'fname' => 'opencart'. date('ymdhis'),
    'lname' => 'opencart'. date('ymdhis'),
);

$xml = '<?xml version="1.0" encoding="utf-8"?>
    <?qbxml version="2.0"?>
    <QBXML>
        <QBXMLMsgsRq onError="stopOnError">
            <CustomerAddRq requestID="' . $requestID . '">
                <CustomerAdd>
                    <Name>' . $arr['name'] . '</Name>
                    <CompanyName>' . $arr['name'] . '</CompanyName>
                    <FirstName>' . $arr['fname'] . '</FirstName>
                    <LastName>' . $arr['lname'] . '</LastName>
                </CustomerAdd>
            </CustomerAddRq>
        </QBXMLMsgsRq>
    </QBXML>';

return $xml;
}

这是我的测试handle.php代码,它为新客户排队:

if (isset($_GET['customer_id']))
{
    $id = intval($_GET['customer_id']);

    // Queue up the customer add

    $Queue = new QuickBooks_WebConnector_Queue($dsn);
    $Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, $id);

    die('Great, queued up a customer!');
}

它向数据库添加了一条新记录:

quickbooks_queue_id = 609
quickbooks_ticket_id = null
qb_username = someuser
qb_action = CustomerAdd
ident = 123456
extra = empty
qbxml = empty
priority = 0
qb_status = q
enqueue_datetime = 2016-02-02 20:58:50
dequeue_datetime = null

Web连接器日志:

20160204.06:45:32 UTC   : QBWebConnector.WebServiceManager.DoUpdateSelected() : updateWS() for application = 'QuickBooks Bridge for OpenCart' has STARTED
20160204.06:45:32 UTC   : QBWebConnector.RegistryManager.getUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock = FALSE
20160204.06:45:32 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to True
20160204.06:45:32 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session locked *********************
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : Initiated connection to the following application.
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppName: QuickBooks Bridge for OpenCart
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppUniqueName (if available): QuickBooks Bridge for OpenCart
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppURL: https://example.com/qbwc.php
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.do_serverVersion() : *** Calling serverVersion().
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.do_serverVersion() : Received from serverVersion() following parameter:<serverVersionRet="PHP QuickBooks SOAP Server v3.0 at /wce/qbwc.php">
20160204.06:45:32 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : *** Calling clientVersion() with following parameter:<productVersion="2.2.0.34">
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : Received from clientVersion() following parameter:<clientVersionRet="">
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : This application agrees with the current version of QBWebConnector. Allowing update operation.
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : Authenticating to application 'QuickBooks Bridge for OpenCart', username = 'someuser'
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : *** Calling authenticate() with following parameters:<userName="someuser"><password=<MaskedForSecurity>
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.updateWS() : Received from authenticate() following parameters:<authRet[0]="1c44d47f-1542-1854-3d22-0d9569718c76"><authRet[1]="13355f1b-4b26-4a7b-b182-15c6dd1246f9"><authRet[2]="1"><authRet[3]="">
20160204.06:45:33 UTC   : QBWebConnector.RegistryManager.setCurrentWebServiceName() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\CurrentWebServiceName has been set to QuickBooks Bridge for OpenCart
20160204.06:45:33 UTC   : QBWebConnector.RegistryManager.setCurrentWebServiceSessionTicket() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\CurrentWebServiceSessionTicket has been set to 1c44d47f-1542-1854-3d22-0d9569718c76
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.CheckCFNResponse() : User authenticated.
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.HandleDelayRequest() : Update has been postponed at 2/3/2016 10:45:33 PM by 'QuickBooks Bridge for OpenCart' for next 60 seconds
20160204.06:45:33 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : Done.
20160204.06:45:33 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to False
20160204.06:45:33 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session unlocked *********************
20160204.06:45:33 UTC   : QBWebConnector.WebServiceManager.DoUpdateSelected() : No data to exchange for the application:  QuickBooks Bridge for OpenCart

我已将die()添加到_quickbooks_customer_add_request,但忽略了此功能。

有谁知道如何解决这个问题?谢谢。

1 个答案:

答案 0 :(得分:1)

随时获得“无需数据交换”。这意味着队列中没有任何内容可供Web连接器处理,或者您有严重错误配置的内容。

由于你quickbooks_queue表中有记录,我的第一个猜测是Web连接器作为不同的用户连接而不是队列表。

您能否确认您使用的.QWC文件使用此用户名?

someuser

除此之外,你有一些错误的配置。根据您的日志,您看起来有错误配置的内容。具体来说:

qb_company_file: 13355f1b-4b26-4a7b-b182-15c6dd1246f9;

这应该是指向QuickBooks公司文件的文件路径(在QuickBooks中点击F2查看)或者它应该为空。该值绝对不是有效的Windows文件路径。

另外,这个:

qwbc_min_run_every_n_seconds: 60

删除它。你不应该有这个设置,除非你有一个非常好的,非常具体的理由这样做。它与Web连接器的多个版本不兼容。

您是否按照快速入门指南进行操作?如果你有......,你就不会遇到这些问题。