ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSoapClient.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
33 define('DEFAULT_TIMEOUT',5);
34 define('DEFAULT_RESPONSE_TIMEOUT',30);
35 
36 include_once './webservice/soap/lib/nusoap.php';
37 
39 {
40  var $server = '';
41  var $timeout = null;
42  var $response_timeout = null;
43  var $use_wsdl = true;
44 
45  function ilSoapClient($a_server = '')
46  {
47  global $ilLog;
48 
49  $this->log =& $ilLog;
50  $this->__setServer($a_server);
51  }
52 
53  function __setServer($a_server)
54  {
55  if(strlen($a_server))
56  {
57  return $this->server = $a_server;
58  }
59  $this->server = ILIAS_HTTP_PATH.'/webservice/soap/server.php?wsdl';
60  }
61 
62  function getServer()
63  {
64  return $this->server;
65  }
66 
67  function setTimeout($a_timeout)
68  {
69  $this->timeout = $a_timeout;
70  }
71  function getTimeout()
72  {
73  return $this->timeout ? $this->timeout : DEFAULT_TIMEOUT;
74  }
75 
76  function setResponseTimeout($a_timeout)
77  {
78  $this->response_timeout = $a_timeout;
79  }
80  function getResponseTimeout()
81  {
83  }
84 
85  function enableWSDL($a_status)
86  {
87  $this->use_wsdl = (bool) $a_status;
88  }
89  function enabledWSDL()
90  {
91  return (bool) $this->use_wsdl;
92  }
93 
94  function init()
95  {
96  $this->client = new soap_client($this->getServer(),
97  $this->enabledWSDL(),
98  false, // no proxy support in the moment
99  false,
100  false,
101  false,
102  $this->getTimeout(),
103  $this->getResponseTimeout());
104 
105  if($error = $this->client->getError())
106  {
107  $this->log->write('Error calling soap server: '.$this->getServer().' Error: '.$error);
108  return false;
109  }
110  return true;
111  }
112 
113  function &call($a_operation,$a_params)
114  {
115  $res = $this->client->call($a_operation,$a_params);
116  if($error = $this->client->getError())
117  {
118  #$this->log->write('Error calling soap server: '.$this->getServer().' Error: '.$error);
119  }
120 
121  return $res;
122  // Todo cannot check errors here since it's not possible to distinguish between 'timeout' and other errors.
123  }
124 }
125 
126 ?>