quickbooks 桌面 web 连接器 qbxml 添加作业 continueOnError 不工作
quickbooks desktop web connector qbxml add job continueOnError not working
我正在使用 QuickBooks Enterprise,Web 连接器版本:2.1.0.30 和在此处找到的框架:https://github.com/consolibyte/quickbooks-php。
添加作业时,有时会出现相同作业名称的情况,因此 quickbooks 会报错。我希望该过程在错误发生后继续,因此我已将 onError 属性设置为 "continueOnError",如下所述:https://developer-static.intuit.com/qbSDK-current/Common/newOSR/qbsdk/staticHtml/QBD-Attributes.html,但该过程停止并且下一个请求(添加发票)不执行.我必须重新运行才能处理下一个请求。
这是我的一部分 xml:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<CustomerAddRq requestID="...">
<CustomerAdd> ...
我做错了什么?这是要走的路还是我需要做其他事情?
提前致谢。
stopOnError
和 continueOnError
标志指示如果在 当前请求的剩余部分 中发生错误,要做什么(停止或继续)当前请求。
例如,如果您这样做:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<CustomerAddRq requestID="1">
...
</CustomerAddRq>
<InvoiceAddRq requestID="2">
...
</InvoiceAddRq>
....
你告诉 QuickBooks,如果 CustomerAddRq
部分出现错误,请忽略它并继续处理 InvoiceAddRq
部分(相对于如果你使用 stopOnError
它不会在 CustomerAddRq
部分遇到错误后,甚至尝试 InvoiceAddRq
。
但是,如果您正确使用了 Web 连接器(确实如此),那么您将发送多个单独的请求,而不是像上例中的一个批量请求。这意味着 stopOnError
和 continueOnError
不是您所需要的。
相反,您需要的是使用错误处理程序处理 PHP 代码中的错误。
添加功能:
/**
* Try to handle an error
*
* @param string $requestID
* @param string $user This is the username of the connected Web Connector user
* @param string $action The action type that experienced an error (i.e. QUICKBOOKS_ADD_CUSTOMER, or QUICKBOOKS_QUERY_CUSTOMER, or etc.)
* @param string $ID The $ID value of the record that experienced an error (usually your primary key for this record)
* @param array $extra
* @param string $err If an error occurs **within the error handler**, put an error message here (i.e. if your error handler experienced an internal error), otherwise, leave this NULL
* @param string $xml
* @param string $errnum The error number or error code which occurred
* @param string $errmsg The error message received from QuickBooks
* @return boolean Return TRUE if the error was handled and you want to continue processing records, or FALSE otherwise
*/
function my_error_handler($requestID, $user, $action, $ID, $extra, &$err, $xml, $errnum, $errmsg)
{
// ...
// return true; // return TRUE if you want the Web Connector to continue to process requests
// return false; // return FALSE if you want the Web Connector to stop processing requests and report the error
}
并确保将您的新错误处理函数告知 QuickBooks PHP 库:
$errmap = array(
// This is an array mapping the error number/code to the error handler function
3070 => 'my_error_handler',
// You can also use static method error handlers if you don't like functions...
// 3070 => 'MyStaticClass::myStaticMethod',
// ... or object instant error handlers.
// 3070 => array( $MyObjectInstance, 'myMethod' ),
// You can also register a "catch-all" error handler to catch all errors:
// '*' => 'my_catchall_error_handler',
);
更多信息:
我正在使用 QuickBooks Enterprise,Web 连接器版本:2.1.0.30 和在此处找到的框架:https://github.com/consolibyte/quickbooks-php。
添加作业时,有时会出现相同作业名称的情况,因此 quickbooks 会报错。我希望该过程在错误发生后继续,因此我已将 onError 属性设置为 "continueOnError",如下所述:https://developer-static.intuit.com/qbSDK-current/Common/newOSR/qbsdk/staticHtml/QBD-Attributes.html,但该过程停止并且下一个请求(添加发票)不执行.我必须重新运行才能处理下一个请求。
这是我的一部分 xml:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<CustomerAddRq requestID="...">
<CustomerAdd> ...
我做错了什么?这是要走的路还是我需要做其他事情?
提前致谢。
stopOnError
和 continueOnError
标志指示如果在 当前请求的剩余部分 中发生错误,要做什么(停止或继续)当前请求。
例如,如果您这样做:
<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="2.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<CustomerAddRq requestID="1">
...
</CustomerAddRq>
<InvoiceAddRq requestID="2">
...
</InvoiceAddRq>
....
你告诉 QuickBooks,如果 CustomerAddRq
部分出现错误,请忽略它并继续处理 InvoiceAddRq
部分(相对于如果你使用 stopOnError
它不会在 CustomerAddRq
部分遇到错误后,甚至尝试 InvoiceAddRq
。
但是,如果您正确使用了 Web 连接器(确实如此),那么您将发送多个单独的请求,而不是像上例中的一个批量请求。这意味着 stopOnError
和 continueOnError
不是您所需要的。
相反,您需要的是使用错误处理程序处理 PHP 代码中的错误。
添加功能:
/**
* Try to handle an error
*
* @param string $requestID
* @param string $user This is the username of the connected Web Connector user
* @param string $action The action type that experienced an error (i.e. QUICKBOOKS_ADD_CUSTOMER, or QUICKBOOKS_QUERY_CUSTOMER, or etc.)
* @param string $ID The $ID value of the record that experienced an error (usually your primary key for this record)
* @param array $extra
* @param string $err If an error occurs **within the error handler**, put an error message here (i.e. if your error handler experienced an internal error), otherwise, leave this NULL
* @param string $xml
* @param string $errnum The error number or error code which occurred
* @param string $errmsg The error message received from QuickBooks
* @return boolean Return TRUE if the error was handled and you want to continue processing records, or FALSE otherwise
*/
function my_error_handler($requestID, $user, $action, $ID, $extra, &$err, $xml, $errnum, $errmsg)
{
// ...
// return true; // return TRUE if you want the Web Connector to continue to process requests
// return false; // return FALSE if you want the Web Connector to stop processing requests and report the error
}
并确保将您的新错误处理函数告知 QuickBooks PHP 库:
$errmap = array(
// This is an array mapping the error number/code to the error handler function
3070 => 'my_error_handler',
// You can also use static method error handlers if you don't like functions...
// 3070 => 'MyStaticClass::myStaticMethod',
// ... or object instant error handlers.
// 3070 => array( $MyObjectInstance, 'myMethod' ),
// You can also register a "catch-all" error handler to catch all errors:
// '*' => 'my_catchall_error_handler',
);
更多信息: