public function actionGetInfo($id)
 {
     $model = GdsRequest::model()->findByPk(new MongoID($id));
     $retArr = array();
     $widget = new CTextHighlighter();
     $widget->language = 'xml';
     $retArr['methodName'] = $model->methodName;
     $retArr['requestXml'] = $widget->highlight($model->requestXml);
     if (strlen($model->responseXml) < 7500) {
         $retArr['responseXml'] = $widget->highlight($model->responseXml);
     } else {
         $retArr['responseXml'] = '<pre>' . htmlspecialchars(UtilsHelper::formatXML($model->responseXml)) . '</pre>';
     }
     $retArr['timestamp'] = date("Y-m-d H:i:s", $model->timestamp);
     $retArr['executionTime'] = Yii::app()->format->formatNumber($model->executionTime);
     $retArr['errorDescription'] = $model->errorDescription;
     //$retArr['responseXml'] = $model->responseXml;
     //echo $model->requestXml);
     echo json_encode($retArr);
     die;
 }
示例#2
0
 public function processAsyncRequests()
 {
     if ($this->multiCurl) {
         $startTime = microtime(true);
         do {
             $status = curl_multi_exec($this->multiCurl, $active);
             $info = curl_multi_info_read($this->multiCurl);
             if (false !== $info) {
                 //partial processing
                 $endTime = microtime(true);
                 foreach ($this->requests as $i => $requestInfo) {
                     if (!$requestInfo['completed']) {
                         if ($requestInfo['curlHandle'] == $info['handle']) {
                             //Process response
                             $result = curl_multi_getcontent($requestInfo['curlHandle']);
                             curl_close($requestInfo['curlHandle']);
                             $startTime1 = microtime(true);
                             $requestInfo['hotelRequestLog']->executionTime = $endTime - $startTime;
                             $requestInfo['hotelRequestLog']->responseXml = UtilsHelper::formatXML($result);
                             $requestInfo['hotelRequestLog']->save();
                             $endTime1 = microtime(true);
                             //Header('ExecutionTimeSaveToMongo:'.($endTime1 - $startTime1));
                             if ($requestInfo['cacheFilePath'] && self::$saveCache) {
                                 file_put_contents($requestInfo['cacheFilePath'], $result);
                             }
                             if (isset($requestInfo['function'])) {
                                 $params = array($result);
                                 if (isset($requestInfo['params']) and $requestInfo['params']) {
                                     foreach ($requestInfo['params'] as $param) {
                                         $params[] = $param;
                                     }
                                 }
                                 try {
                                     $this->requests[$i]['result'] = call_user_func_array($requestInfo['function'], $params);
                                 } catch (Exception $e) {
                                     echo "TryLogging" . $e->getMessage();
                                     Yii::log("HotelBookClient Return Incorrect Response:\nExeption:" . $e->getMessage() . "\nRequestInfo:" . CVarDumper::dumpAsString($requestInfo) . CVarDumper::dumpAsString($params));
                                 }
                                 unset($this->requests[$i]['function']);
                             } else {
                                 $this->requests[$i]['result'] = $result;
                             }
                             $this->requests[$i]['completed'] = true;
                         }
                     }
                 }
             }
         } while ($status === CURLM_CALL_MULTI_PERFORM || $active);
         curl_multi_close($this->multiCurl);
         $this->multiCurl = null;
     }
 }
示例#3
0
    public function __doRequest($request, $location, $action, $version, $oneWay = 0)
    {
        //echo $action;
        if (strpos($action, 'Search11') !== FALSE) {
            //echo $action.'||||';
            $request = '<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <Search xmlns="http://tempuri.org/">
        <Request>
          <Requisites>
            <Login>webdev012</Login>
            <Password>HHFJGYU3*^H</Password>
            </Requisites>
          <RequestType>U</RequestType>
          <UserID>15</UserID>
          <Search>
            <ODPairs Type="OW" Direct="false" AroundDates="0">
              <ODPair>
                <DepDate>2012-06-13T00:00:00</DepDate>
                <DepAirp>MOW</DepAirp>
                <ArrAirp>IJK</ArrAirp>
              </ODPair>
            </ODPairs>
            <Travellers>
              <Traveller Type="ADT" Count="1"/>
            </Travellers>
            <Restrictions>
              <ClassPref>All</ClassPref>
              <OnlyAvail>true</OnlyAvail>
              <AirVPrefs/>
              <IncludePrivateFare>false</IncludePrivateFare>
              <CurrencyCode>RUB</CurrencyCode>
            </Restrictions>
          </Search>
        </Request>
    </Search>
  </env:Body>
</env:Envelope>';
            //echo VarDumper::xmlDump($request);
            $sXML = $this->makeSoapRequest($request, $location, $action, $version);
            //$sXML = parent::__doRequest($request, $location, $action, $version);
            //echo VarDumper::xmlDump($sXML);
            //die();
        } elseif (strpos($action, 'bookFlight1') !== FALSE) {
            $this->gdsRequest->requestXml = UtilsHelper::formatXML($request);
            $this->gdsRequest->save();
            echo '???';
            VarDumper::dump($request);
            return "";
        } else {
            //die();
            $this->gdsRequest->requestXml = UtilsHelper::formatXML($request);
            $this->gdsRequest->save();
            //VarDumper::dump($request);
            //die();
            $startTime = microtime(true);
            $sXML = $this->makeSoapRequest($request, $location, $action, $version);
            $endTime = microtime(true);
            $this->gdsRequest->executionTime = $endTime - $startTime;
            $this->gdsRequest->responseXml = UtilsHelper::formatXML($sXML);
            $this->gdsRequest->save();
            if (!$sXML) {
                $this->gdsRequest->errorDescription = Yii::t('application', 'Error on soap request. Curl description: {curl_desc}. Last headers: {last_headers}.', array('{curl_desc}' => GDSNemoSoapClient::$lastCurlError, '{last_headers}' => GDSNemoSoapClient::$lastHeaders));
                $this->gdsRequest->save();
                throw new CException(Yii::t('application', 'Error on soap request. Curl description: {curl_desc}. Last headers: {last_headers}.', array('{curl_desc}' => GDSNemoSoapClient::$lastCurlError, '{last_headers}' => GDSNemoSoapClient::$lastHeaders)));
            }
            //$sXML = parent::__doRequest($request, $location, $action, $version);
            //echo VarDumper::xmlDump($sXML);
            //die();
        }
        return $sXML;
    }