dongsui4658 2016-04-23 04:08
浏览 59

Laravel在普通/文本页面上搞乱了输出

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] =&gt; __construct
    [1] =&gt; authenticate
    [2] =&gt; sendRequestXML
    [3] =&gt; receiveResponseXML
    [4] =&gt; connectionError
    [5] =&gt; getLastError
    [6] =&gt; closeConnection
    [7] =&gt; serverVersion
    [8] =&gt; 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" &lt;keith@consolibyte.com&gt; 
   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] =&gt; __construct
    [1] =&gt; authenticate
    [2] =&gt; sendRequestXML
    [3] =&gt; receiveResponseXML
    [4] =&gt; connectionError
    [5] =&gt; getLastError
    [6] =&gt; closeConnection
    [7] =&gt; serverVersion
    [8] =&gt; 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);
    }
}
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 本题的答案是不是有问题
    • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
    • ¥15 C++使用Gunplot
    • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
    • ¥15 matlab数字图像处理频率域滤波
    • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
    • ¥15 ELGamal和paillier计算效率谁快?
    • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
    • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
    • ¥15 Arcgis相交分析无法绘制一个或多个图形