Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML is incorrect #305

Open
jfreak53 opened this issue Jun 2, 2021 · 5 comments
Open

XML is incorrect #305

jfreak53 opened this issue Jun 2, 2021 · 5 comments

Comments

@jfreak53
Copy link

jfreak53 commented Jun 2, 2021

I'm trying to use this system to sync my database from postgresql to quickbooks web connector https://github.com/consolibyte/quickbooks-php, but it's giving me all sorts of XML issues.
Here is my QWC file:

<?xml version="1.0"?>
<QBWCXML>
	<AppName>QuickBooks PostgreSQL Mirror</AppName>
	<AppID></AppID>
	<AppURL>https://myserver.com/admin/qbwc/pgsql_server.php</AppURL>
	<AppDescription>QuickBooks PostgreSQL Mirror</AppDescription>
	<AppSupport>https://myserver.com/admin/qbwc/pgsql_server.php?support=1</AppSupport>
	<UserName>quickbooks</UserName>
	<OwnerID>{fb0c8866-7719-e4a4-e9bb-c81c30cd1045}</OwnerID>
	<FileID>{788e593c-0b38-4824-3d7d-5b9a793316df}</FileID>
	<QBType>QBFS</QBType>
	<Notify>true</Notify>
	<Scheduler>
		<RunEveryNMinutes>1</RunEveryNMinutes>
	</Scheduler>
	<IsReadOnly>false</IsReadOnly>
</QBWCXML>

Here is my PHP connector app, copied from the example file for PostgreSQL syncing, but modified with my info:

<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 0);

require_once '../libraries/vendor/consolibyte/quickbooks/QuickBooks.php';

if (function_exists('date_default_timezone_set'))
{
	date_default_timezone_set('America/Detroit');
}

$username = 'quickbooks';
$password = 'password';

$dsn = 'pgsql://postgres:password@localhost/quickbooks';

if (!QuickBooks_Utilities::initialized($dsn))
{
	header('Content-Type: text/plain');
	
	set_time_limit(0);
	
	$driver_options = array(
		);
		
	$init_options = array(
		'quickbooks_sql_enabled' => true, 
		);
		
	QuickBooks_Utilities::initialize($dsn, $driver_options, $init_options);
	QuickBooks_Utilities::createUser($dsn, $username, $password);
	
	exit;
}

$mode = QuickBooks_WebConnector_Server_SQL::MODE_READWRITE;

$conflicts = QuickBooks_WebConnector_Server_SQL::CONFLICT_LOG;

$delete = QUICKBOOKS_SERVER_SQL_DELETE_FLAG;

$hooks = array();

$soap_options = array();

$handler_options = array(
	'deny_concurrent_logins' => false, 
	'deny_reallyfast_logins' => false,
);

$driver_options = array();

$sql_options = array(
	'only_import' => array( 
		QUICKBOOKS_OBJECT_CUSTOMER, 
	),
	'only_add' => array( 
		QUICKBOOKS_OBJECT_CUSTOMER, 
	),
	'only_modify' => array( 
		QUICKBOOKS_OBJECT_CUSTOMER, 
	), 
);

$callback_options = array();

$Server = new QuickBooks_WebConnector_Server_SQL(
	$dsn, 
	'1 minute', 
	$mode, 
	$conflicts, 
	$delete,
	$username, 
	array(), 
	array(), 
	$hooks, 
	QUICKBOOKS_LOG_DEVELOP, 
	QUICKBOOKS_SOAPSERVER_BUILTIN, 
	QUICKBOOKS_WSDL,
	$soap_options, 
	$handler_options, 
	$driver_options,
	$sql_options, 
	$callback_options);

header('Content-Type: text/xml');
ob_start();
$Server->handle(true, true);
print(ob_get_clean());

exit;

I know it runs and connects to my DB, since I have all the qb_ tables added, but no data is syncing back and forth. I also get this error whenever I run it:

enter image description here

Here are my logs:

20210526.15:53:01 UTC	: QBWebConnector.WebServiceManager.DoUpdateSelected() : updateWS() for application = 'QuickBooks PostgreSQL Mirror - myserver.com' has STARTED
20210526.15:53:01 UTC	: QBWebConnector.RegistryManager.getUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock = FALSE
20210526.15:53:01 UTC	: QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to True
20210526.15:53:01 UTC	: QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session locked *********************
20210526.15:53:01 UTC	: QBWebConnector.SOAPWebService.instantiateWebService() : Initiated connection to the following application.
20210526.15:53:01 UTC	: QBWebConnector.SOAPWebService.instantiateWebService() : AppName: QuickBooks PostgreSQL Mirror - myserver.com
20210526.15:53:01 UTC	: QBWebConnector.SOAPWebService.instantiateWebService() : AppUniqueName (if available): QuickBooks PostgreSQL Mirror - myserver.com
20210526.15:53:01 UTC	: QBWebConnector.SOAPWebService.instantiateWebService() : AppURL: https://myserver.com/admin/qbwc/pgsql_server.php
20210526.15:53:01 UTC	: QBWebConnector.SOAPWebService.do_serverVersion() : *** Calling serverVersion().
20210526.15:53:02 UTC	: QBWebConnector.SOAPWebService.do_serverVersion() : Received from serverVersion() following parameter:<serverVersionRet="PHP QuickBooks SOAP Server v3.0 at /admin/qbwc/pgsql_server.php">
20210526.15:53:02 UTC	: QBWebConnector.SOAPWebService.do_clientVersion() : *** Calling clientVersion() with following parameter:<productVersion="2.3.0.198">
20210526.15:53:02 UTC	: QBWebConnector.SOAPWebService.do_clientVersion() : Received from clientVersion() following parameter:<clientVersionRet="">
20210526.15:53:02 UTC	: QBWebConnector.SOAPWebService.do_clientVersion() : This application agrees with the current version of QBWebConnector. Allowing update operation.
20210526.15:53:02 UTC	: QBWebConnector.SOAPWebService.do_authenticate() : Authenticating to application 'QuickBooks PostgreSQL Mirror - myserver.com', username = 'quickbooks'
20210526.15:53:02 UTC	: QBWebConnector.SOAPWebService.do_authenticate() : *** Calling authenticate() with following parameters:<userName="quickbooks"><password=<MaskedForSecurity>
20210526.15:53:02 UTC	: QBWebConnector.SOAPWebService.do_authenticate() : QBWC1012: Authentication failed due to following error message.
Client found response content type of 'text/xml;charset=UTF-8', but expected 'text/xml'.
The request failed with an empty response.
More info:
StackTrace =    at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at QBWebConnector.localhost.WCWebServiceDoc.authenticate(String strUserName, String strPassword)
   at QBWebConnector.localhost.WCWebService.authenticate(String strUserName, String strPassword)
   at QBWebConnector.SOAPWebService.authenticate(String UserName, String Password)
   at QBWebConnector.WebService.do_authenticate(String& ticket, String& companyFileName)
Source = System.Web.Services
20210526.15:53:02 UTC	: QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to False
20210526.15:53:02 UTC	: QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session unlocked *********************
20210526.15:53:02 UTC	: QBWebConnector.WebServiceManager.DoUpdateSelected() : Update completed with errors. See log (QWClog.txt) for details.
@jfreak53
Copy link
Author

jfreak53 commented Jun 8, 2021

Anyone??

@tvaughan73
Copy link
Contributor

I would try enabling verbose logging on the web connector to see exactly what is being sent back and forth.
https://help.developer.intuit.com/s/article/QBWC-Logging

@tvaughan73
Copy link
Contributor

Also, the code you posted has some extra things that may be causing the problem. I would try replacing

$Server = new QuickBooks_WebConnector_Server_SQL(
	$dsn, 
	'1 minute', 
	$mode, 
	$conflicts, 
	$delete,
	$username, 
	array(), 
	array(), 
	$hooks, 
	QUICKBOOKS_LOG_DEVELOP, 
	QUICKBOOKS_SOAPSERVER_BUILTIN, 
	QUICKBOOKS_WSDL,
	$soap_options, 
	$handler_options, 
	$driver_options,
	$sql_options, 
	$callback_options);

header('Content-Type: text/xml');
ob_start();
$Server->handle(true, true);
print(ob_get_clean());

exit;

with

$Server = new QuickBooks_WebConnector_Server_SQL(
	$dsn, 
	'1 minute', 
	$mode, 
	$conflicts, 
	$delete,
	$username, 
	array(), 
	array(), 
	$hooks, 
	QUICKBOOKS_LOG_DEVELOP, 
	QUICKBOOKS_SOAPSERVER_BUILTIN, 
	QUICKBOOKS_WSDL,
	$soap_options, 
	$handler_options, 
	$driver_options,
	$sql_options, 
	$callback_options);

$Server->handle(true, true);

@jfreak53
Copy link
Author

jfreak53 commented Jun 8, 2021

I had that code originally, wasn't working, thought I might be able to force the headers so I tried the new code. Same error.

I enabled verbose and this is what I got:

20210608.19:53:33 UTC	: QBWebConnector.WebServiceManager.DoUpdateSelected() : updateWS() for application = 'QuickBooks PostgreSQL Mirror - server.domain.com' has STARTED
20210608.19:53:33 UTC	: QBWebConnector.RegistryManager.getUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock = FALSE
20210608.19:53:33 UTC	: QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to True
20210608.19:53:33 UTC	: QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session locked *********************
20210608.19:53:33 UTC	: QBWebConnector.SOAPWebService.instantiateWebService() : Initiated connection to the following application.
20210608.19:53:33 UTC	: QBWebConnector.SOAPWebService.instantiateWebService() : AppName: QuickBooks PostgreSQL Mirror - server.domain.com
20210608.19:53:33 UTC	: QBWebConnector.SOAPWebService.instantiateWebService() : AppUniqueName (if available): QuickBooks PostgreSQL Mirror - server.domain.com
20210608.19:53:33 UTC	: QBWebConnector.SOAPWebService.instantiateWebService() : AppURL: https://server.domain.com/admin/qbwc/pgsql_server.php
20210608.19:53:33 UTC	: QBWebConnector.SOAPWebService.do_serverVersion() : *** Calling serverVersion().
20210608.19:53:34 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.
20210608.19:53:34 UTC	: QBWebConnector.SOAPWebService.do_serverVersion() : This application does not contain support for serverVersion. Allowing update operation for backward compatibility.
20210608.19:53:34 UTC	: QBWebConnector.SOAPWebService.do_clientVersion() : *** Calling clientVersion() with following parameter:<productVersion="2.3.0.198">
20210608.19:53:35 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.
20210608.19:53:35 UTC	: QBWebConnector.SOAPWebService.do_clientVersion() : This application does not contain support for clientVersion. Allowing update operation for backward compatibility.
20210608.19:53:35 UTC	: QBWebConnector.SOAPWebService.do_authenticate() : Authenticating to application 'QuickBooks PostgreSQL Mirror - server.shepherdmechanical.com', username = 'quickbooks'
20210608.19:53:35 UTC	: QBWebConnector.SOAPWebService.do_authenticate() : *** Calling authenticate() with following parameters:<userName="quickbooks"><password=<MaskedForSecurity>
20210608.19:53:35 UTC	: QBWebConnector.SOAPWebService.do_authenticate() : QBWC1012: Authentication failed due to following error message.
Response is not well-formed XML.
More info:
StackTrace =    at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at QBWebConnector.localhost.WCWebServiceDoc.authenticate(String strUserName, String strPassword)
   at QBWebConnector.localhost.WCWebService.authenticate(String strUserName, String strPassword)
   at QBWebConnector.SOAPWebService.authenticate(String UserName, String Password)
   at QBWebConnector.WebService.do_authenticate(String& ticket, String& companyFileName)
Source = System.Web.Services
20210608.19:53:35 UTC	: QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to False
20210608.19:53:35 UTC	: QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session unlocked *********************
20210608.19:53:35 UTC	: QBWebConnector.WebServiceManager.DoUpdateSelected() : Update completed with errors. See log (QWClog.txt) for details.

@jfreak53
Copy link
Author

jfreak53 commented Jun 8, 2021

Seems to be a big bug somewhere. I checked the PHP logs and this is what it gave me:

PHP Fatal error:  PostgreSQL Error: ERROR:  column "parent_fullname" does not exist\nLINE 4:       qbsql_last_errnum , Parent_FullName\n                                  ^\nHINT:  Perhaps you meant to reference the column "qb_customer.Parent_FullName"., SQL: \n\t\t\t\t\tSELECT \n\t\t\t\t\t\tqbsql_id, \n\t\t\t\t\t\tqbsql_last_errnum , Parent_FullName\n\t\t\t\t\tFROM \n\t\t\t\t\t\tqb_customer \n\t\t\t\t\tWHERE \n\t\t\t\t\t\tqbsql_modify_timestamp IS NOT NULL AND \n\t\t\t\t\t\tqbsql_resync_datetime IS NULL AND \n\t\t\t\t\t\t qbsql_to_skip <> TRUE  AND \n\t\t\t\t\t\t qbsql_to_delete <> TRUE  AND \n\t\t\t\t\t\t qbsql_flag_deleted <> TRUE  AND \n\t\t\t\t\t\tqbsql_modify_timestamp <= '2021-06-08 15:56:22'  in /var/www/html/admin/libraries/vendor/consolibyte/quickbooks/QuickBooks/Driver/Sql/Pgsql.php on line 504

So I went into the postgreSQL database and changed that field in qb_customer to lowercase, same with listid since it gave me the same error after that. Then it worked!

Problem is, the customer I have in QB is copied to the PGSQL database, but, only it's ID #1, the information about the customer isn't copied, even though the XML log in web connector shows data:

https://cdn.microtronix-tech.com/imgs/Screenshot_at_2021-06-08_16-08-11.jpg

So there is definitely something up with the code that isn't liking the database. I'm using Quickbooks Pro 2021.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants