ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilSoapClient Class Reference
+ Collaboration diagram for ilSoapClient:

Public Member Functions

 __construct ($a_uri='')
 
 getServer ()
 Get server uri. More...
 
 setTimeout ($a_timeout)
 Set connect timeout. More...
 
 getTimeout ()
 Get connect timeout. More...
 
 setResponseTimeout ($a_timeout)
 Set response timeout. More...
 
 getResponseTimeout ()
 Get response timeout. More...
 
 enableWSDL ($a_stat)
 enable wsdl mode More...
 
 enabledWSDL ()
 Check if wsdl is enabled. More...
 
 init ()
 Init soap client. More...
 
 call ($a_operation, $a_params)
 Call webservice method. More...
 

Data Fields

const DEFAULT_CONNECT_TIMEOUT = 10
 
const DEFAULT_RESPONSE_TIMEOUT = 5
 

Protected Member Functions

 setSocketTimeout ($a_wsdl_mode)
 Set socket timeout. More...
 
 resetSocketTimeout ()
 Reset socket default timeout to defaults. More...
 

Private Attributes

 $log = null
 
 $client = null
 
 $uri
 
 $connect_timeout = 10
 
 $response_timeout = 10
 
 $stored_socket_timeout = null
 

Detailed Description

Definition at line 14 of file class.ilSoapClient.php.

Constructor & Destructor Documentation

◆ __construct()

ilSoapClient::__construct (   $a_uri = '')
Parameters
string$a_uri

Definition at line 40 of file class.ilSoapClient.php.

References $ilSetting, and ilLoggerFactory\getLogger().

41  {
42  global $ilSetting;
43 
44  $this->log = ilLoggerFactory::getLogger('wsrv');
45 
46  $this->uri = $a_uri;
47 
48  $this->use_wsdl = true;
49  $timeout = $ilSetting->get('soap_connect_timeout',self::DEFAULT_CONNECT_TIMEOUT);
50  if(!$timeout)
51  {
52  $timeout = self::DEFAULT_CONNECT_TIMEOUT;
53  }
54  $this->connect_timeout = $timeout;
55 
56  $this->response_timeout = self::DEFAULT_RESPONSE_TIMEOUT;
57  }
global $ilSetting
Definition: privfeed.php:17
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ call()

ilSoapClient::call (   $a_operation,
  $a_params 
)

Call webservice method.

Parameters
string$a_operation
array$a_params

Definition at line 206 of file class.ilSoapClient.php.

References resetSocketTimeout(), and setSocketTimeout().

207  {
208  $this->log->debug('Calling webseervice: ' . $a_operations);
209 
210  $this->setSocketTimeout(false);
211  try {
212  return $this->client->__call($a_operation, $a_params);
213  }
214  catch(SoapFault $exception) {
215  $this->log->error('Calling webservice failed with message: ' . $exception->getMessage());
216  $this->log->debug($this->client->__getLastResponseHeaders());
217  $this->log->debug($this->client->__getLastResponse());
218  return false;
219  }
220  catch(Exception $exception)
221  {
222  $this->log->error('Caught unknown exception with message: '. $exception->getMessage());
223  $this->log->debug($this->client->__getLastResponseHeaders());
224  $this->log->debug($this->client->__getLastResponse());
225  }
226  finally {
227  $this->resetSocketTimeout();
228  }
229  }
resetSocketTimeout()
Reset socket default timeout to defaults.
setSocketTimeout($a_wsdl_mode)
Set socket timeout.
+ Here is the call graph for this function:

◆ enabledWSDL()

ilSoapClient::enabledWSDL ( )

Check if wsdl is enabled.

Returns
type

Definition at line 116 of file class.ilSoapClient.php.

117  {
118  return $this->use_wsdl;
119  }

◆ enableWSDL()

ilSoapClient::enableWSDL (   $a_stat)

enable wsdl mode

Parameters
type$a_stat

Definition at line 107 of file class.ilSoapClient.php.

108  {
109  $this->use_wsdl = $a_stat;
110  }

◆ getResponseTimeout()

ilSoapClient::getResponseTimeout ( )

Get response timeout.

Definition at line 98 of file class.ilSoapClient.php.

References $response_timeout.

Referenced by init(), and setSocketTimeout().

99  {
101  }
+ Here is the caller graph for this function:

◆ getServer()

ilSoapClient::getServer ( )

Get server uri.

Returns
string

Definition at line 63 of file class.ilSoapClient.php.

References $uri.

Referenced by init().

64  {
65  return $this->uri;
66  }
+ Here is the caller graph for this function:

◆ getTimeout()

ilSoapClient::getTimeout ( )

Get connect timeout.

Returns
int

Definition at line 81 of file class.ilSoapClient.php.

References $connect_timeout.

Referenced by init(), and setSocketTimeout().

82  {
84  }
+ Here is the caller graph for this function:

◆ init()

ilSoapClient::init ( )

Init soap client.

Definition at line 125 of file class.ilSoapClient.php.

References $ilSetting, ilUtil\_getHttpPath(), array, getResponseTimeout(), getServer(), getTimeout(), resetSocketTimeout(), and setSocketTimeout().

126  {
127  global $ilSetting;
128 
129  if(!strlen(trim($this->getServer())))
130  {
131  if(strlen(trim($ilSetting->get('soap_wsdl_path',''))))
132  {
133  $this->uri = $ilSetting->get('soap_wsdl_path','');
134  }
135  else
136  {
137  $this->uri = ilUtil::_getHttpPath().'/webservice/soap/server.php?wsdl';
138  }
139  }
140  try {
141 
142  $this->log->debug('Using wsdl: ' . $this->getServer());
143  $this->log->debug('Using connection timeout: ' . $this->getTimeout());
144  $this->log->debug('Using response timeout: ' . $this->getResponseTimeout());
145 
146  $this->setSocketTimeout(true);
147  $this->client = new SoapClient(
148  $this->uri,
149  array(
150  'exceptions' => true,
151  'trace' => 1,
152  'connection_timeout' => (int) $this->getTimeout()
153  )
154  );
155  return true;
156  }
157  catch (SoapFault $ex) {
158 
159  $this->log->warning('Soap init failed with message: ' . $ex->getMessage());
160  $this->resetSocketTimeout();
161  return false;
162  }
163  finally {
164  $this->resetSocketTimeout();
165  }
166  }
resetSocketTimeout()
Reset socket default timeout to defaults.
setSocketTimeout($a_wsdl_mode)
Set socket timeout.
getResponseTimeout()
Get response timeout.
Create styles array
The data for the language used.
static _getHttpPath()
global $ilSetting
Definition: privfeed.php:17
getServer()
Get server uri.
getTimeout()
Get connect timeout.
+ Here is the call graph for this function:

◆ resetSocketTimeout()

ilSoapClient::resetSocketTimeout ( )
protected

Reset socket default timeout to defaults.

Returns
boolean

Definition at line 194 of file class.ilSoapClient.php.

Referenced by call(), and init().

195  {
196  ini_set('default_socket_timeout', $this->stored_socket_timeout);
197  $this->log->debug('Restoring default socket timeout to: ' . $this->stored_socket_timeout);
198  return true;
199  }
+ Here is the caller graph for this function:

◆ setResponseTimeout()

ilSoapClient::setResponseTimeout (   $a_timeout)

Set response timeout.

Parameters
type$a_timeout

Definition at line 90 of file class.ilSoapClient.php.

91  {
92  $this->response_timeout = $a_timeout;
93  }

◆ setSocketTimeout()

ilSoapClient::setSocketTimeout (   $a_wsdl_mode)
protected

Set socket timeout.

Returns
boolean

Definition at line 172 of file class.ilSoapClient.php.

References getResponseTimeout(), and getTimeout().

Referenced by call(), and init().

173  {
174  $this->stored_socket_timeout = ini_get('default_socket_timeout');
175  $this->log->debug('Default socket timeout is: ' . $this->stored_socket_timeout);
176 
177  if($a_wsdl_mode)
178  {
179  $this->log->debug('WSDL mode, using socket timeout: ' . $this->getTimeout());
180  ini_set('default_socket_timeout', $this->getTimeout());
181  }
182  else
183  {
184  $this->log->debug('Non WSDL mode, using socket timeout: ' . $this->getResponseTimeout());
185  ini_set('default_socket_timeout', $this->getResponseTimeout());
186  }
187  return true;
188  }
getResponseTimeout()
Get response timeout.
getTimeout()
Get connect timeout.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTimeout()

ilSoapClient::setTimeout (   $a_timeout)

Set connect timeout.

Parameters
int$a_timeout

Definition at line 72 of file class.ilSoapClient.php.

73  {
74  $this->connect_timeout = $a_timeout;
75  }

Field Documentation

◆ $client

ilSoapClient::$client = null
private

Definition at line 27 of file class.ilSoapClient.php.

◆ $connect_timeout

ilSoapClient::$connect_timeout = 10
private

Definition at line 31 of file class.ilSoapClient.php.

Referenced by getTimeout().

◆ $log

ilSoapClient::$log = null
private

Definition at line 22 of file class.ilSoapClient.php.

◆ $response_timeout

ilSoapClient::$response_timeout = 10
private

Definition at line 32 of file class.ilSoapClient.php.

Referenced by getResponseTimeout().

◆ $stored_socket_timeout

ilSoapClient::$stored_socket_timeout = null
private

Definition at line 34 of file class.ilSoapClient.php.

◆ $uri

ilSoapClient::$uri
private

Definition at line 29 of file class.ilSoapClient.php.

Referenced by getServer().

◆ DEFAULT_CONNECT_TIMEOUT

const ilSoapClient::DEFAULT_CONNECT_TIMEOUT = 10

Definition at line 16 of file class.ilSoapClient.php.

Referenced by ilObjSystemFolderGUI\initWebServicesForm().

◆ DEFAULT_RESPONSE_TIMEOUT

const ilSoapClient::DEFAULT_RESPONSE_TIMEOUT = 5

Definition at line 17 of file class.ilSoapClient.php.


The documentation for this class was generated from the following file: