ILIAS  eassessment Revision 61809
 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  global $ilSetting;
56 
57  if(strlen($a_server))
58  {
59  return $this->server = $a_server;
60  }
61 
62  if(strlen(trim($ilSetting->get('soap_wsdl_path'))))
63  {
64  return $this->server = trim($ilSetting->get('soap_wsdl_path'));
65  }
66 
67  $this->server = ILIAS_HTTP_PATH.'/webservice/soap/server.php?wsdl';
68  }
69 
70  function getServer()
71  {
72  return $this->server;
73  }
74 
75  function setTimeout($a_timeout)
76  {
77  $this->timeout = $a_timeout;
78  }
79  function getTimeout()
80  {
81  return $this->timeout ? $this->timeout : DEFAULT_TIMEOUT;
82  }
83 
84  function setResponseTimeout($a_timeout)
85  {
86  $this->response_timeout = $a_timeout;
87  }
88  function getResponseTimeout()
89  {
91  }
92 
93  function enableWSDL($a_status)
94  {
95  $this->use_wsdl = (bool) $a_status;
96  }
97  function enabledWSDL()
98  {
99  return (bool) $this->use_wsdl;
100  }
101 
102  function init()
103  {
104  $this->client = new nusoap_client($this->getServer(),
105  $this->enabledWSDL(),
106  false, // no proxy support in the moment
107  false,
108  false,
109  false,
110  $this->getTimeout(),
111  $this->getResponseTimeout());
112 
113  if($error = $this->client->getError())
114  {
115  $this->log->write('Error calling soap server: '.$this->getServer().' Error: '.$error);
116  return false;
117  }
118  return true;
119  }
120 
121  function &call($a_operation,$a_params)
122  {
123  $res = $this->client->call($a_operation,$a_params);
124  if($error = $this->client->getError())
125  {
126  $this->log->write('Error calling soap server: '.$this->getServer().' Error: '.$error);
127  }
128 
129  return $res;
130  // Todo cannot check errors here since it's not possible to distinguish between 'timeout' and other errors.
131  }
132 }
133 
134 ?>