我的问题是,当移动到我的开发环境时,生产完全正常的东西会被破坏。我使用tar
打包整个Web根目录并在开发环境中将其解压缩,因此所有文件都是相同的。我还验证了两个环境非常相似。两者之间的唯一区别是我使用windows / xamp作为开发环境,使用centOS / cPanel作为生产环境。我还将我的作品克隆到了Linux开发环境中,但它仍然没有用。
所以我发现的是我正在使用Consolibyes Quickbooks PHP SDK和Laravel。在处理请求的端点URL上,它应该输出XML / SOAP但它正在为我输出一些broken
HTML(下面的示例)我已经确认SDK按预期工作并且如果我正确输出XML将它从Laravel中删除并将其粘贴在自己的文件夹中,这样就不会通过Laravel传递任何请求。
这是Quickbooks网络连接器提供的错误:
Client found response content type of 'text/html; charset=UTF-8', but expected 'text/xml'.
正如您所见,下面包含的代码段是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>
即使输出中包含HTML,输出应该是这样的,您可以看到标记没有搞砸,输出包含在pre
标记内:
<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>
以下是破碎版本的响应标题:
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
以下是工作版本的响应标头:
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
我的日志文件中没有出现任何错误,我知道错误或警告通常会导致这样的事情发生。
我已经包含了我的路线和控制器的简短片段,即使相同的代码正在制作。
这通常只是一个post
路线,但为了排查问题,我将其设为any
。
route::any('quickbooks/quickbooks_endpoint', QuickbooksController@quickbooks_endpoint');
在QuickbooksController
内我使用以下内容:
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);
}
}