当我在consolibytes网站上检查时,我在网络连接器中收到“QBWC1041:SendRequestXML因错误消息而失败”我发现了这个
http://www.consolibyte.com/docs/index.php/QuickBooks_Web_Connector_-_SendRequestXML_failed
我检查了php错误日志文件,我收到以下错误
[25-Apr-2014 04:41:15 America/Denver] PHP Fatal error: require_once() [<a href='function.require'>function.require</a>]: Failed opening required '/home/wholecab/public_html/store/qbsdkm/QuickBooks/Driver/.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/home/wholecab/public_html/store/qbsdkm') in /home/wholecab/public_html/store/qbsdkm/QuickBooks/Loader.php on line 56
为什么我收到此错误?
这是代码 的config.php
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
if (function_exists('date_default_timezone_set')){
date_default_timezone_set('America/New_York');
}
require_once '../QuickBooks.php';
$user = 'quickbooks';
$pass = 'password';
// Map QuickBooks actions to handler functions
$map = array(
QUICKBOOKS_QUERY_CUSTOMER => array( '_quickbooks_customer_query_request', '_quickbooks_customer_query_response', '_quickbooks_error_handler' ),
QUICKBOOKS_ADD_CUSTOMER => array( '_quickbooks_customer_add_request', '_quickbooks_customer_add_response' ),
QUICKBOOKS_ADD_INVOICE => array( '_quickbooks_invoice_add_request', '_quickbooks_invoice_add_response' ),
QUICKBOOKS_ADD_SALESORDER => array( '_quickbooks_salesorder_add_request', '_quickbooks_salesorder_add_response' ),
);
$errmap = array(
3070 => '_quickbooks_error_stringtoolong',
3140 => '_quickbooks_reference_error',
'*' => '_quickbooks_error_handler',
);
$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,
);
$soap_options = array();
$driver_options = array();
$callback_options = array();
$dsn = 'mysql://wholecab_user3:Sehar123#@localhost/wholecab_clickdb3';
QuickBooks_WebConnector_Queue_Singleton::initialize($dsn);
if (!QuickBooks_Utilities::initialized($dsn)){
// Initialize creates the neccessary database schema for queueing up requests and logging
QuickBooks_Utilities::initialize($dsn);
// This creates a username and password which is used by the Web Connector to authenticate
QuickBooks_Utilities::createUser($dsn, $user, $pass);
}
// Create a new server and tell it to handle the requests
// __construct($dsn_or_conn, $map, $errmap = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL, $soap = QUICKBOOKS_SOAPSERVER_PHP, $wsdl = QUICKBOOKS_WSDL, $soap_options = array(), $handler_options = array(), $driver_options = array(), $callback_options = array()
$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_salesorder_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale){
// We're just testing, so we'll just use a static test request:
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="5.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<SalesOrderAddRq requestID="'.$requestID.'">
<SalesOrderAdd>
<CustomerRef>
<FullName>Muralidhar, LLC (1249573828)</FullName>
</CustomerRef>
<TxnDate>2014-04-25</TxnDate>
<RefNumber>23112628110</RefNumber>
<BillAddress>
<Addr1>Pam Barker</Addr1>
<Addr2>500 Kirts Boulevard</Addr2>
<Addr3/>
<City>Troy</City>
<State>Mi</State>
<PostalCode>48084</PostalCode>
<Country>US</Country>
</BillAddress>
<ShipAddress>
<Addr1/>
<Addr2>7322 Southwest Freeway</Addr2>
<Addr3>Ste, 170</Addr3>
<City>Houston</City>
<State>TX</State>
<PostalCode>77074</PostalCode>
<Country>US</Country>
</ShipAddress>
<Memo>Shipping to Pinnacle Senior Care Houston</Memo>
<SalesOrderLineAdd>
<ItemRef>
<FullName>ARCTIC WHITE SHAKER:AWS-1530MD</FullName>
</ItemRef>
<Desc>MULLION DOOR FOR W1530 - ARCTIC WHITE SHAKER</Desc>
<Quantity>1</Quantity>
<Amount>59.25</Amount>
</SalesOrderLineAdd>
<SalesOrderLineAdd>
<ItemRef>
<FullName>ARCTIC WHITE SHAKER:AWS-1536MD</FullName>
</ItemRef>
<Desc>MULLION DOOR FOR W1536 - ARCTIC WHITE SHAKER</Desc>
<Quantity>1</Quantity>
<Amount>59.25</Amount>
</SalesOrderLineAdd>
</SalesOrderAdd>
</SalesOrderAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
function _quickbooks_salesorder_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents){
$content = "##########################################################";
$content .= $idents;
$content .= "##########################################################";
$content .= $xml;
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/store/qbsdkm/docs/myText.txt","wb");
fwrite($fp,$content);
fclose($fp);
return;
}
function _quickbooks_invoice_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale){
// We're just testing, so we'll just use a static test request:
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="5.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<InvoiceAddRq requestID="'.$requestID.'">
<InvoiceAdd>
<CustomerRef>
<FullName>Muralidhar, LLC (1249573828)</FullName>
</CustomerRef>
<TxnDate>2014-04-23</TxnDate>
<RefNumber>9668</RefNumber>
<BillAddress>
<Addr1>56 Cowles Road</Addr1>
<City>Willington</City>
<State>CT</State>
<PostalCode>06279</PostalCode>
<Country>United States</Country>
</BillAddress>
<PONumber></PONumber>
<Memo></Memo>
<InvoiceLineAdd>
<ItemRef>
<FullName>Test Item</FullName>
</ItemRef>
<Desc>Item 1 Description Goes Here</Desc>
<Quantity>1</Quantity>
<Rate>295</Rate>
</InvoiceLineAdd>
<InvoiceLineAdd>
<ItemRef>
<FullName>Test Item</FullName>
</ItemRef>
<Desc>Item 2 Description Goes Here</Desc>
<Quantity>3</Quantity>
<Rate>25</Rate>
</InvoiceLineAdd>
</InvoiceAdd>
</InvoiceAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
function _quickbooks_invoice_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents){
$content = "##########################################################";
$content .= $idents;
$content .= "##########################################################";
$content .= $xml;
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/store/qbsdkm/docs/myText.txt","wb");
fwrite($fp,$content);
fclose($fp);
return;
}
function _quickbooks_customer_add_request($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale){
// We're just testing, so we'll just use a static test request:
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="5.0"?>
<QBXML>
<QBXMLMsgsRq onError="stopOnError">
<CustomerAddRq requestID="' . $requestID . '">
<CustomerAdd>
<Name>Muralidhar, LLC (' . mt_rand() . ')</Name>
<CompanyName>Muralidhar, LLC</CompanyName>
<FirstName>Murali</FirstName>
<LastName>Developer</LastName>
<BillAddress>
<Addr1>Muralidhar, LLC</Addr1>
<Addr2>134 Stonemill Road</Addr2>
<City>NewYork</City>
<State>NY</State>
<PostalCode>10001</PostalCode>
<Country>United States</Country>
</BillAddress>
<Phone>860-634-1602</Phone>
<AltPhone>860-429-0021</AltPhone>
<Fax>860-429-5183</Fax>
<Email>Murali@Muralidhar.com</Email>
<Contact>Murali Developer</Contact>
</CustomerAdd>
</CustomerAddRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
/**
* Receive a response from QuickBooks
*/
function _quickbooks_customer_add_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents){
$content = $xml;
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/store/qbsdkm/docs/myText.txt","wb");
fwrite($fp,$content);
fclose($fp);
return;
}
function _quickbooks_customer_query_request($requestID , $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $version, $locale){
/*$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="5.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<CustomerQueryRq>
<MaxReturned>5</MaxReturned>
<FromModifiedDate>1984-01-29T22:03:19</FromModifiedDate>
<OwnerID>0</OwnerID>
</CustomerQueryRq>
</QBXMLMsgsRq>
</QBXML>';*/
$xml = '<?xml version="1.0" encoding="utf-8"?>
<?qbxml version="5.0"?>
<QBXML>
<QBXMLMsgsRq onError="continueOnError">
<CustomerQueryRq requestID="' . $requestID . '" iterator="Start">
<MaxReturned>10</MaxReturned>
<FromModifiedDate>1984-01-29T22:03:19</FromModifiedDate>
<OwnerID>0</OwnerID>
</CustomerQueryRq>
</QBXMLMsgsRq>
</QBXML>';
return $xml;
}
function _quickbooks_customer_query_response($requestID, $user, $action, $ID, $extra, &$err, $last_action_time, $last_actionident_time, $xml, $idents){
$content = $xml;
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/store/qbsdkm/docs/myText.txt","wb");
fwrite($fp,$content);
fclose($fp);
}
function _quickbooks_error_handler($requestID, $user, $action, $ID, $extra, &$err, $xml, $errnum, $errmsg){
$content = "##########################################################";
$content .= $idents;
$content .= "##########################################################";
$content .= $xml;
$content .= "##########################################################";
$content .= $errmsg;
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/store/qbsdkm/docs/myText.txt","a");
fwrite($fp,$content);
fclose($fp);
}
function _quickbooks_reference_error($requestID, $user, $action, $ID, $extra, &$err, $xml, $errnum, $errmsg){
$content = "##########################################################";
$content .= $idents;
$content .= "##########################################################";
$content .= $xml;
$content .= "##########################################################";
$content .= $errmsg;
$fp = fopen($_SERVER['DOCUMENT_ROOT'] . "/store/qbsdkm/docs/myText.txt","a");
fwrite($fp,$content);
fclose($fp);
}
和另一个文件wholeqb.php
<?php
require_once 'config.php';
$Queue = QuickBooks_WebConnector_Queue_Singleton::getInstance();
$Queue->enqueue(QUICKBOOKS_ADD_CUSTOMER, mt_rand());
$Queue->enqueue(QUICKBOOKS_QUERY_CUSTOMER,mt_rand());
$Queue->enqueue(QUICKBOOKS_ADD_SALESORDER, mt_rand());
谢谢,
穆拉利
答案 0 :(得分:3)
$ 10表示您的代码中有一个$ dsn变量为空。
但你没有发布你的代码,所以很难说肯定。发布你的代码? 击>
现在您已发布代码更新了答案 -
在wholeqb.php
文件中,您需要先初始化单例:
QuickBooks_WebConnector_Queue_Singleton::initialize($dsn);
或者只是创建对象而不是使用单例:
$Queue = new QuickBooks_WebConnector_Queue($dsn);
确保将wholeqb.php文件中的$ dsn变量 设置为有效的SQL连接字符串。