• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Services/WebServices/SOAP/classes/class.ilSoapClient.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00033 define('DEFAULT_TIMEOUT',5);
00034 define('DEFAULT_RESPONSE_TIMEOUT',30);
00035 
00036 include_once './webservice/soap/lib/nusoap.php';
00037 
00038 class ilSoapClient
00039 {
00040         var $server = '';
00041         var $timeout = null;
00042         var $response_timeout = null;
00043         var $use_wsdl = true;
00044 
00045         function ilSoapClient($a_server = '')
00046         {
00047                 global $ilLog;
00048 
00049                 $this->log =& $ilLog;
00050                 $this->__setServer($a_server);
00051         }
00052 
00053         function __setServer($a_server)
00054         {
00055                 if(strlen($a_server))
00056                 {
00057                         return $this->server = $a_server;
00058                 }
00059                 $this->server = ILIAS_HTTP_PATH.'/webservice/soap/server.php?wsdl';
00060         }
00061 
00062         function getServer()
00063         {
00064                 return $this->server;
00065         }
00066         
00067         function setTimeout($a_timeout)
00068         {
00069                 $this->timeout = $a_timeout;
00070         }
00071         function getTimeout()
00072         {
00073                 return $this->timeout ? $this->timeout : DEFAULT_TIMEOUT;
00074         }
00075 
00076         function setResponseTimeout($a_timeout)
00077         {
00078                 $this->response_timeout = $a_timeout;
00079         }
00080         function getResponseTimeout()
00081         {
00082                 return $this->response_timeout;
00083         }
00084 
00085         function enableWSDL($a_status)
00086         {
00087                 $this->use_wsdl = (bool) $a_status;
00088         }
00089         function enabledWSDL()
00090         {
00091                 return (bool) $this->use_wsdl;
00092         }
00093 
00094         function init()
00095         {
00096                 $this->client = new soap_client($this->getServer(),
00097                                                                                 $this->enabledWSDL(),
00098                                                                                 false, // no proxy support in the moment
00099                                                                                 false,
00100                                                                                 false,
00101                                                                                 false,
00102                                                                                 $this->getTimeout(),
00103                                                                                 $this->getResponseTimeout());
00104                 
00105                 if($error = $this->client->getError())
00106                 {
00107                         $this->log->write('Error calling soap server: '.$this->getServer().' Error: '.$error);
00108                         return false;
00109                 }
00110                 return true;
00111         }
00112 
00113         function &call($a_operation,$a_params)
00114         {
00115                 $res = $this->client->call($a_operation,$a_params);
00116                 if($error = $this->client->getError())
00117                 {
00118                         #$this->log->write('Error calling soap server: '.$this->getServer().' Error: '.$error);
00119                 }
00120 
00121                 return $res;
00122                 // Todo cannot check errors here since it's not possible to distinguish between 'timeout' and other errors.
00123         }
00124 }
00125                 
00126 ?>

Generated on Fri Dec 13 2013 17:57:02 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1