Exemple #1
0
 /**
  * @param $params
  * @param bool $fullReponse
  * @return bool|OIntegrate_Response
  */
 function performRequest($params, $fullReponse = false)
 {
     global $soaplib, $prefs;
     $built = $this->url;
     $builtBody = $this->body;
     $map = $this->getParameterMap($params);
     if ($built) {
         switch ($this->wstype) {
             case 'SOAP':
                 if (!empty($this->operation)) {
                     $options = array('encoding' => 'UTF-8');
                     if ($prefs['use_proxy'] == 'y' && !strpos($built, 'localhost')) {
                         $options['proxy_host'] = $prefs['proxy_host'];
                         $options['proxy_port'] = $prefs['proxy_port'];
                     }
                     $response = new OIntegrate_Response();
                     $soaplib->allowCookies = $this->allowCookies;
                     try {
                         $response->data = $soaplib->performRequest($built, $this->operation, $map, $options, $fullReponse);
                     } catch (Exception $e) {
                         TikiLib::lib('errorreport')->report(tr('Webservice error on %0 request "%1"', $this->wstype, $this->url) . '<br>' . $e->getMessage());
                     }
                     return $response;
                 }
                 return false;
             case 'REST':
             default:
                 foreach ($map as $name => $value) {
                     $built = str_replace("%{$name}%", urlencode($value), $built);
                     $builtBody = str_replace("%{$name}%", urlencode($value), $builtBody);
                 }
                 $ointegrate = new OIntegrate();
                 $ointegrate->addAcceptTemplate('smarty', 'tikiwiki');
                 $ointegrate->addAcceptTemplate('smarty', 'html');
                 $ointegrate->addAcceptTemplate('javascript', 'html');
                 if ($this->schemaVersion) {
                     $ointegrate->addSchemaVersion($this->schemaVersion);
                 }
                 try {
                     $response = $ointegrate->performRequest($built, $builtBody);
                 } catch (Exception $e) {
                     TikiLib::lib('errorreport')->report(tr('Webservice error on %0 request "%1"', $this->wstype, $this->url) . '<br>' . $e->getMessage());
                 }
                 return $response;
         }
     }
 }