быстрые книги magento 2.3 QBWC1012 - PullRequest
0 голосов
/ 14 февраля 2019

Я перевожу магазин из magento 1 в magento 2, и он интегрирован с Quickbooks Desktop на удаленном рабочем столе MQC.

Я использую consolibyte для m1 и m2.И это работало на м2, а также.Затем мне пришлось отложить эту задачу и обновить magento до 2.3.0.

Теперь, когда я пытаюсь обновить приложение magneto 2 в веб-коннекторе на удаленном рабочем столе, оно выдает следующую ошибку:

"Version:
Not provided by service

Message:
Authentication failed

Description:
QBWC1012: Authentication failed due to following error message.
The request failed with an empty response. See QWCLog for more details. Remember to turn logging on."

Журнал выглядит следующим образом:

"20190213.06:57:36 UTC  : QBWebConnector.WebServiceManager.DoUpdateSelected() : updateWS() for application = 'Sansha 2 France 1.0' has STARTED
20190213.06:57:36 UTC   : QBWebConnector.RegistryManager.getUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock = FALSE
20190213.06:57:36 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to True
20190213.06:57:36 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session locked *********************
20190213.06:57:36 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : Initiated connection to the following application.
20190213.06:57:36 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppName: Sansha 2 France 1.0
20190213.06:57:36 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppUniqueName (if available): Sansha 2 France 1.0
20190213.06:57:36 UTC   : QBWebConnector.SOAPWebService.instantiateWebService() : AppURL: https://eurostore.magento2.sansha.com/quickbooks/api
20190213.06:57:36 UTC   : QBWebConnector.SOAPWebService.do_serverVersion() : *** Calling serverVersion().
20190213.06:57:36 UTC   : QBWebConnector.SOAPWebService.do_serverVersion() : Actual error received from web service for serverVersion call: <The request failed with an empty response.>. For backward compatibility of all webservers, QBWC will catch all errors under app-not-supporting-serverVersion.
20190213.06:57:36 UTC   : QBWebConnector.SOAPWebService.do_serverVersion() : This application does not contain support for serverVersion. Allowing update operation for backward compatibility.
20190213.06:57:36 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : *** Calling clientVersion() with following parameter:<productVersion="2.2.0.71">
20190213.06:57:37 UTC   : QBWebConnector.SOAPWebService.updateWS() : Actual error received from web service for clientVersion call: <The request failed with an empty response.>. For backward compatibility of all webservers, QBWC will catch all errors under app-not-supporting-clientVersion.
20190213.06:57:37 UTC   : QBWebConnector.SOAPWebService.do_clientVersion() : This application does not contain support for clientVersion. Allowing update operation for backward compatibility.
20190213.06:57:37 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : Authenticating to application 'Sansha 2 France 1.0', username = 'sansha'
20190213.06:57:37 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : *** Calling authenticate() with following parameters:<userName="sansha"><password=<MaskedForSecurity>
20190213.06:57:37 UTC   : QBWebConnector.SOAPWebService.do_authenticate() : QBWC1012: Authentication failed due to following error message.
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
20190213.06:57:37 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to False
20190213.06:57:37 UTC   : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session unlocked *********************
20190213.06:57:37 UTC   : QBWebConnector.WebServiceManager.DoUpdateSelected() : Update completed with errors. See log (QWClog.txt) for details.
"

Я пытался найти решение, но все еще не повезло.

Сервер SOAP, похоже, работает:

"QuickBooks PHP DevKit Server v3.0 at /quickbooks/api/
   (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: 1
 - Timezone: Europe/Paris (Auto-set: )
 - Current Date/Time: 2019-02-14 08:09:29
 - 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: 
 - 2019-02-14 08:09:29 -- process 0.27981"

И вот как это инициируется:

if(!\QuickBooks_Utilities::initialized($dsn)) {
    \QuickBooks_Utilities::initialize($dsn);
    \QuickBooks_Utilities::createUser($dsn, $qb_username, $qb_password);
}

$server = new \QuickBooks_WebConnector_Server($dsn, $this->_map, $this->_errmap, $this->_hooks);
$response = $server->handle(true, true);

Кто-нибудь сталкивался с этой проблемой?Кто-нибудь знает, как это можно решить.

С уважением

1 Ответ

0 голосов
/ 12 марта 2019

Наконец-то обнаружена проблема.

Дело в том, что обновление до magento 2.3 прерывает HTTP-запрос POST или, по крайней мере, способ, которым они работали до обновления, см. https://magento.stackexchange.com/questions/253414/magento-2-3-upgrade-breaks-http-post-requests-to-custom-module-endpoint.

Iдля проверки запроса использовался https://github.com/consolibyte/quickbooks-php/blob/master/dev/dev_qbwc_tester.php, а ключ формы был недействительным.Чтобы это исправить, ваш контроллер должен реализовать CsrfAwareActionInterface.

И чтобы magento не пытался устанавливать куки и перезаписывать заголовки после инициализации вашего сервера QBWC, вам придется заблокировать ваш код сразу после инициализации сервера SOAP.Я поставил die () после, не уверен, что это лучшее решение, но аутентификация работает (это была моя основная проблема).

Окончательный код в контроллере выглядит так:

<?php


namespace Sansha\Quickbooks\Controller\Api;

use Magento\Framework\App\CsrfAwareActionInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\App\Request\InvalidRequestException;

class Index extends \Magento\Framework\App\Action\Action implements CsrfAwareActionInterface
{

    protected $resultPageFactory;

    protected $_map = array();

    protected $_hooks = array();

    protected $_errmap = array();

    protected $_helper_config;

    protected $_helper_data;

    protected $_helper_api;

    protected $_logger;

    /**
     * Constructor
     *
     * @param \Magento\Framework\App\Action\Context  $context
     * @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
     */
    public function __construct(
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory,
        \Sansha\Quickbooks\Helper\QbConfig $helperConfig,
        \Sansha\Quickbooks\Helper\QbData $helperData,
        \Sansha\Quickbooks\Helper\QbApi $helperApi,
        \Sansha\Quickbooks\Logger\Logger $logger
    ) {
        $this->resultPageFactory = $resultPageFactory;
        $this->_helper_config = $helperConfig;
        $this->_helper_data = $helperData;
        $this->_helper_api = $helperApi;
        $this->_logger = $logger;

        parent::__construct($context);
    }

    /**
     * Execute view action
     *
     * @return \Magento\Framework\Controller\ResultInterface
     */
    public function execute()
    {
        if (function_exists('date_default_timezone_set'))
        {
            date_default_timezone_set('Europe/Paris');
        }

        $store_id = $this->_helper_data->getStoreId();
        $dsn = $this->_helper_config->getDsn($store_id);
        $qb_username = $this->_helper_config->getQbLogin($store_id)['username'];
        $qb_password = $this->_helper_config->getQbLogin($store_id)['password'];

        if(!\QuickBooks_Utilities::initialized($dsn)) {
            \QuickBooks_Utilities::initialize($dsn);
            \QuickBooks_Utilities::createUser($dsn, $qb_username, $qb_password);
        }

        $server = new \QuickBooks_WebConnector_Server($dsn, $this->_map, $this->_errmap, $this->_hooks);
        $response = $server->handle(true, true); 
        die(); // stop code exectuon after server initialization
    }

    // below 2 functions will avoid breaking HTTP POST request
    public function createCsrfValidationException(RequestInterface $request): ?InvalidRequestException
    {
        return null;
    }

    public function validateForCsrf(RequestInterface $request): ?bool
    {
        return true;
    }       
...