1

Minha loja virtual esta apresentando o seguinte problema quando envio rest:

exception 'Zend_Http_Client_Exception' with message 'Unable to read response, or response is empty' in D:\wamp\www\santaines\lib\Zend\Http\Client.php:1081 Stack trace: #0 D:\wamp\www\santaines\lib\Varien\Http\Client.php(61): Zend_Http_Client->request(NULL) #1 D:\wamp\www\santaines\app\code\local\Envato\Custompaymentmethod\controllers\PaymentController.php(56): Varien_Http_Client->request() #2 D:\wamp\www\santaines\app\code\core\Mage\Core\Controller\Varien\Action.php(418): Envato_Custompaymentmethod_PaymentController->gatewayAction() #3 D:\wamp\www\santaines\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('gateway') #4 D:\wamp\www\santaines\app\code\core\Mage\Core\Controller\Varien\Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http)) #5 D:\wamp\www\santaines\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch() #6 D:\wamp\www\santaines\app\Mage.php(684): Mage_Core_Model_App->run(Array) #7 D:\wamp\www\santaines\index.php(87): Mage::run('', 'store') #8 {main}

Código da requisição:

    $arr_querystring = array(

    'numero' =>  $orderId, 
    'nome' => Mage::helper('customer')->getCustomerName(),
    'valor' =>  $totalPedido,
    'cpf' => $cpfComprador,
    'email' => Mage::helper('customer')->getCustomer()->getData('email'),
    'celular' => $celularComprador,
    'dtNascimento' =>  $dataNascimentoComprador,  
    'envioSMS' => 'N' );

$jsonData = Mage::helper('core')->jsonEncode( $arr_querystring );
$headers = array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($jsonData),
    'lgn:xxx',
    'pwd:xxx');

$client = new Varien_Http_Client();

$client->setUri('https://nameOfServerRest')
         ->setMethod('POST')
         ->setHeaders($headers)
         ->setRawData($jsonData);
try{

  $response = $client->request();

  if ($response->isSuccessful()){

    $statusJson = $response->getBody();

    $json = Mage::helper('core')->jsonDecode($statusJson);

    if ($json['Status'] == "001"){  

        $link = $json['Message'];
        $this->_redirectUrl($link);
        Mage_Core_Controller_Varien_Action::_redirect('custompaymentmethod/payment/response', array('_secure' => false, '_query'=> $arr_querystring));


        }else{
          Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/error', array('_secure'=> false));
        }
    }

}catch (Exception $e){
    echo $e;
}  

Fiz o teste com outra loja e o servidor para onde envio está funcionando normalmente. O que pode estar acontecendo?

0

Você deve fazer log-in para responder a esta pergunta.

Pesquise outras perguntas com a tag .