My problem is that something that works perfectly fine on production is broken when moved to my development environment. I used tar
to package the entire web root and unpacked it in the development environment so all files are identical. I have also verified the two environments closely resemble each other. The only difference between the two is that I am using windows/xamp for the development environment and centOS/cPanel for the production environment. I have also cloned my production onto a linux development environment and it still did not work.
So what I have going on is that I am using the Consolibyes Quickbooks PHP SDK with Laravel. On the endpoint URL where the requests are handled it is supposed to output XML/SOAP but it is outputting some broken
HTML for me (example below) I have confirmed that the SDK works as intended and outputs the XML correctly if I remove it from Laravel and stick it in its own folder so that no requests are passed through Laravel.
This is the error that the Quickbooks webconnector gives back:
Client found response content type of 'text/html; charset=UTF-8', but expected 'text/xml'.
The included snippet below is, as you can see, broken HTML.
<html><head></head><body>QuickBooks PHP DevKit Server v3.0 at /quickbooks/quickbooks_endpoint
(c) "Keith Palmer" <keith@consolibyte.com>
Visit us at: http://www.ConsoliBYTE.com/
Use the QuickBooks Web Connector to access this SOAP server.
QuickBooks_WebConnector_Server::handle() parameters:
- $return = 1
- $debug = 1
Misc. information:
- Logging: 4
- Timezone: America/Chicago (Auto-set: )
- Current Date/Time: 2016-04-22 22:20:04
- Error Reporting: -1
SOAP adapter:
- QuickBooks_Adapter_Server_Builtin
Registered handler functions:
Array
(
[0] => __construct
[1] => authenticate
[2] => sendRequestXML
[3] => receiveResponseXML
[4] => connectionError
[5] => getLastError
[6] => closeConnection
[7] => serverVersion
[8] => clientVersion
)
Detected input:
Timestamp:
- 2016-04-22 22:20:04 -- process 0.11243
</keith@consolibyte.com></body></html>
This is what the output should look like even though it has HTML in it, you can see that the tags are not messed up and the output is included inside of a pre
tag:
<html><head></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">QuickBooks PHP DevKit Server v3.0 at /docs/web_connector/example_app_web_connector/qbwc.php
(c) "Keith Palmer" <keith@consolibyte.com>
Visit us at: http://www.ConsoliBYTE.com/
Use the QuickBooks Web Connector to access this SOAP server.
QuickBooks_WebConnector_Server::handle() parameters:
- $return = 1
- $debug = 1
Misc. information:
- Logging: 4
- Timezone: America/New_York (Auto-set: )
- Current Date/Time: 2016-04-22 23:42:02
- Error Reporting: 32767
SOAP adapter:
- QuickBooks_Adapter_Server_Builtin
Registered handler functions:
Array
(
[0] => __construct
[1] => authenticate
[2] => sendRequestXML
[3] => receiveResponseXML
[4] => connectionError
[5] => getLastError
[6] => closeConnection
[7] => serverVersion
[8] => clientVersion
)
Detected input:
Timestamp:
- 2016-04-22 23:42:02 -- process 0.09316
</pre></body></html>
Here are the response headers from the broken version:
Cache-Control:no-cache
Connection:Keep-Alive
Content-Length:850
Content-Type:text/html; charset=UTF-8
Date:Sat, 23 Apr 2016 03:20:04 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.19
Set-Cookie:XSRF-TOKEN=XXXXXXXX; expires=Sat, 23-Apr-2016 05:20:04 GMT; Max-Age=7200; path=/
Set-Cookie:laravel_session=XXXXXXX; expires=Sat, 23-Apr-2016 05:20:04 GMT; Max-Age=7200; path=/; httponly
X-Powered-By:PHP/5.6.19
Here are the response headers from the working version:
Connection:Keep-Alive
Content-Length:877
Content-Type:text/plain;charset=UTF-8
Date:Sat, 23 Apr 2016 03:42:02 GMT
Keep-Alive:timeout=5, max=100
Server:Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.19
X-Powered-By:PHP/5.6.19
I am not getting any errors in my log files, I know errors or warnings are what typically cause something like this to happen.
I have included a brief snippet of my route and controller even though the same code is working on production.
This would typically be just a post
route but for troubleshooting I made it any
.
route::any('quickbooks/quickbooks_endpoint', QuickbooksController@quickbooks_endpoint');
Inside my QuickbooksController
I am using the following:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use QuickBooks_WebConnector_Server;
use QuickBooks_Utilities;
use QuickBooks_WebConnector_Queue;
use QuickBooks_WebConnector_QWC;
use Carbon\Carbon;
class QuickbooksController extends Controller
{
protected $dsn = '';
protected $qbwc_user = '';
protected $qbwc_pass = '';
public function __construct() {
$dbName = config('database.connections.mysql.database');
$dbUser = config('database.connections.mysql.username');
$dbPass = config('database.connections.mysql.password');
$dbHost = config('database.connections.mysql.host');
$qbwc_user = 'quickbooks';
$qbwc_pass = 'password';
$this->setQuickbooksUser($qbwc_user, $qbwc_pass);
$this->setDSN($dbName, $dbUser, $dbPass, $dbHost);
if(!QuickBooks_Utilities::initialized($this->dsn))
{
QuickBooks_Utilities::initialize($this->dsn);
QuickBooks_Utilities::createUser($this->dsn, $qbwc_user, $qbwc_pass);
}
}
public function setDSN($dbName, $dbUser, $dbPass, $dbHost) {
$this->dsn = 'mysqli://' . $dbUser . ':' . $dbPass . '@' . $dbHost . '/' . $dbName;
}
public function setQuickbooksUser($qbwc_user, $qbwc_pass) {
$this->qbwc_user = $qbwc_user;
$this->qbwc_pass = $qbwc_pass;
}
public function quickbooks_endpoint() {
$map = array(
QUICKBOOKS_QUERY_CUSTOMER => array(
array($this, '_quickbooks_customer_query_request'),
array($this, '_quickbooks_customer_query_response')
),
QUICKBOOKS_QUERY_EMPLOYEE => array(
array($this, '_quickbooks_employee_query_request'),
array($this, '_quickbooks_employee_query_response')
),
QUICKBOOKS_ADD_TIMETRACKING => array(
array($this, '_quickbooks_add_time_request'),
array($this, '_quickbooks_add_time_response')
),
QUICKBOOKS_QUERY_SERVICEITEM => array(
array($this, '_quickbooks_item_query_request'),
array($this, '_quickbooks_item_query_response')
),
);
$errmap = array(
'*' => array($this, '_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,
);
$driver_options = array();
$callback_options = array();
$Server = new QuickBooks_WebConnector_Server($this->dsn, $map, $errmap, $hooks, $log_level, $soapserver, QUICKBOOKS_WSDL, $soap_options, $handler_options, $driver_options, $callback_options);
$response = $Server->handle(true, true);
}
}