consolibyte / quickbooks-php

QuickBooks Integration for PHP
Eclipse Public License 1.0
456 stars 337 forks source link

Web Connector: "The connection was closed unexpectedly"? #240

Closed anaxmedia closed 5 years ago

anaxmedia commented 5 years ago

I've got everything setup and installed. When accessing the URL via my browser I get this output:

QuickBooks PHP DevKit Server v3.0 at /qbwc (c) "Keith Palmer" 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: UTC (Auto-set: ) - Current Date/Time: 2019-01-22 20:43:05 - 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: - 2019-01-22 20:43:05 -- process 1.1596

However when I add my QWC file to the Web Connector and run, I receive the following error message in the QWCLog:

QBWC1012: Authentication failed due to following error message. The request was aborted: The connection was closed unexpectedly.

I've double checked my username and password are correct. Any other ideas what could be causing this? It looks like it's unable to even connect to my URL?

consolibyte commented 5 years ago

Web server problem? Put your Web Connector in VERBOSE mode, clear the log, run it, and then post the log file.

It should give you a pretty clear reason if you look at the logs.

anaxmedia commented 5 years ago

I fixed that one issue, but found another. I'm returning 200 status for the request coming from the Web Connector now, however I'm receiving the following errors now:

QBWC1012: Authentication failed due to the following error message. Client found response content type of 'text/html; charset=UTF-8', but expected 'text/xml'.

I'm using Laravel so I'm not sure how to set the content type without using their response facade. I've tried:

$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); return response($response) ->header('Content-Type', 'text/xml');

But then I get: "Response is not well-formed XML"

Any ideas? Thanks for the fast response, I really appreciate it!!

anaxmedia commented 5 years ago

I figured it out!

For anyone trying to use this library with Laravel, here's what I used for my Response:

ob_start(); $Server->handle(true, true); return response(ob_get_clean()) ->header('Content-Type', 'text/xml; charset=utf-8');