ILIAS  Release_4_2_x_branch Revision 61807
 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 // @deprecated
25 define('DEFAULT_TIMEOUT',5);
26 // @deprecated
27 define('DEFAULT_RESPONSE_TIMEOUT',30);
28 
29 include_once './webservice/soap/lib/nusoap.php';
30 
31 
41 {
44 
45  var $server = '';
46  var $timeout = null;
47  var $response_timeout = null;
48  var $use_wsdl = true;
49 
50  function ilSoapClient($a_server = '')
51  {
52  global $ilLog;
53 
54  $this->log =& $ilLog;
55  $this->__setServer($a_server);
56  }
57 
58  function __setServer($a_server)
59  {
60  global $ilSetting;
61 
62  if(strlen($a_server))
63  {
64  return $this->server = $a_server;
65  }
66 
67  if(strlen(trim($ilSetting->get('soap_wsdl_path'))))
68  {
69  return $this->server = trim($ilSetting->get('soap_wsdl_path'));
70  }
71 
72  $this->setTimeout($ilSetting->get('soap_connect_timeout'), self::DEFAULT_CONNECT_TIMEOUT);
73 
74  $this->server = ILIAS_HTTP_PATH.'/webservice/soap/server.php?wsdl';
75  }
76 
77  function getServer()
78  {
79  return $this->server;
80  }
81 
82  function setTimeout($a_timeout)
83  {
84  $this->timeout = $a_timeout;
85  }
86  function getTimeout()
87  {
88  return $this->timeout ? $this->timeout : self::DEFAULT_CONNECT_TIMEOUT;
89  }
90 
91  function setResponseTimeout($a_timeout)
92  {
93  $this->response_timeout = $a_timeout;
94  }
95  function getResponseTimeout()
96  {
98  }
99 
100  function enableWSDL($a_status)
101  {
102  $this->use_wsdl = (bool) $a_status;
103  }
104  function enabledWSDL()
105  {
106  return (bool) $this->use_wsdl;
107  }
108 
109  function init()
110  {
111  $this->client = new nusoap_client($this->getServer(),
112  $this->enabledWSDL(),
113  false, // no proxy support in the moment
114  false,
115  false,
116  false,
117  $this->getTimeout(),
118  $this->getResponseTimeout());
119 
120  if($error = $this->client->getError())
121  {
122  $this->log->write('Error calling soap server: '.$this->getServer().' Error: '.$error);
123  return false;
124  }
125  return true;
126  }
127 
128  function &call($a_operation,$a_params)
129  {
130  $res = $this->client->call($a_operation,$a_params);
131  if($error = $this->client->getError())
132  {
133  $this->log->write('Error calling soap server: '.$this->getServer().' Error: '.$error);
134  }
135 
136  return $res;
137  // Todo cannot check errors here since it's not possible to distinguish between 'timeout' and other errors.
138  }
139 }
140 
141 ?>