Ejemplo n.º 1
0
 public function connect()
 {
     $this->open();
     $sendData = $this->serializeParams($this->getParameters());
     curl_setopt($this->curl, CURLOPT_URL, "{$this->url}?{$sendData}");
     //curl_setopt($this->curl, CURLOPT_POST, true); // HTTP POST
     //curl_setopt($this->curl, CURLOPT_POSTFIELDS, $sendData);
     $response = curl_exec($this->curl);
     if ($response === false) {
         $errno = @curl_errno($this->curl);
         $error = @curl_strerror($errno);
         $this->close();
         throw TransferException::couldNotTransferData($this->url . ($this->isProxy() ? ' (usando proxy)' : ''), "[{$errno}] {$error}");
     }
     list($response_headers_str, $response) = explode("\r\n\r\n", $response);
     /*$response_headers = $this->_readHeaders($response_headers_str);
       if (!$this->checkResponseToken($response_headers['X-FW-Response'])) {
           throw new WrongDataTransferException('Resposta inv�lida do servidor, entre em contato com a Furac�o');
       }*/
     $this->close();
     if (empty($response)) {
         throw TransferException::emptyDataReturned();
     }
     return $response;
 }
Ejemplo n.º 2
0
 public function connect()
 {
     $this->open();
     try {
         if (!$this->getFunction()) {
             throw TransferException::functionMandatory();
         }
         $response = $this->soapClient->__call($this->getFunction(), $this->getParameters());
         /*$response_headers_str = $this->pointer->__getLastResponseHeaders();
           $response_headers = $this->_readHeaders($response_headers_str);
           if (!$this->checkResponseToken($response_headers['X-FW-Response'])) {
               throw new WrongDataTransferException('Resposta inv�lida do servidor, entre em contato com a Furac�o');
           }*/
     } catch (TransferException $e) {
         throw $e;
         // se for exception de transfer, lançar do jeito que está
     } catch (\Exception $e) {
         throw TransferException::couldNotTransferData($this->url . ($this->isProxy() ? ' (usando proxy)' : ''), $e->getMessage());
     }
     $this->soapClient = null;
     if (empty($response)) {
         throw TransferException::emptyDataReturned();
     }
     return $response;
 }