ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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)
 
 getResponseTimeout ()
 
 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  $timeout = self::DEFAULT_CONNECT_TIMEOUT;
52  }
53  $this->connect_timeout = $timeout;
54 
55  $this->response_timeout = self::DEFAULT_RESPONSE_TIMEOUT;
56  }
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 193 of file class.ilSoapClient.php.

References resetSocketTimeout(), and setSocketTimeout().

194  {
195  $this->log->debug('Calling webservice: ' . $a_operation);
196 
197  $this->setSocketTimeout(false);
198  try {
199  return $this->client->__call($a_operation, $a_params);
200  } catch (SoapFault $exception) {
201  $this->log->error('Calling webservice failed with message: ' . $exception->getMessage());
202  $this->log->debug($this->client->__getLastResponseHeaders());
203  $this->log->debug($this->client->__getLastResponse());
204  return false;
205  } catch (Exception $exception) {
206  $this->log->error('Caught unknown exception with message: ' . $exception->getMessage());
207  $this->log->debug($this->client->__getLastResponseHeaders());
208  $this->log->debug($this->client->__getLastResponse());
209  } finally {
210  $this->resetSocketTimeout();
211  }
212  }
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 114 of file class.ilSoapClient.php.

115  {
116  return $this->use_wsdl;
117  }

◆ enableWSDL()

ilSoapClient::enableWSDL (   $a_stat)

enable wsdl mode

Parameters
type$a_stat

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

106  {
107  $this->use_wsdl = $a_stat;
108  }

◆ getResponseTimeout()

ilSoapClient::getResponseTimeout ( )
Returns
int Response Timeout

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

References $response_timeout.

Referenced by init(), and setSocketTimeout().

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

◆ getServer()

ilSoapClient::getServer ( )

Get server uri.

Returns
string

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

References $uri.

Referenced by init().

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

◆ getTimeout()

ilSoapClient::getTimeout ( )

Get connect timeout.

Returns
int

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

References $connect_timeout.

Referenced by init(), and setSocketTimeout().

81  {
83  }
+ Here is the caller graph for this function:

◆ init()

ilSoapClient::init ( )

Init soap client.

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

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

124  {
125  global $ilSetting;
126 
127  if (!strlen(trim($this->getServer()))) {
128  if (strlen(trim($ilSetting->get('soap_wsdl_path', '')))) {
129  $this->uri = $ilSetting->get('soap_wsdl_path', '');
130  } else {
131  $this->uri = ilUtil::_getHttpPath() . '/webservice/soap/server.php?wsdl';
132  }
133  }
134  try {
135  $this->log->debug('Using wsdl: ' . $this->getServer());
136  $this->log->debug('Using connection timeout: ' . $this->getTimeout());
137  $this->log->debug('Using response timeout: ' . $this->getResponseTimeout());
138 
139  $this->setSocketTimeout(true);
140  $this->client = new SoapClient(
141  $this->uri,
142  array(
143  'exceptions' => true,
144  'trace' => 1,
145  'connection_timeout' => (int) $this->getTimeout()
146  )
147  );
148  return true;
149  } catch (SoapFault $ex) {
150  $this->log->warning('Soap init failed with message: ' . $ex->getMessage());
151  $this->resetSocketTimeout();
152  return false;
153  } finally {
154  $this->resetSocketTimeout();
155  }
156  }
resetSocketTimeout()
Reset socket default timeout to defaults.
setSocketTimeout($a_wsdl_mode)
Set socket 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 181 of file class.ilSoapClient.php.

Referenced by call(), and init().

182  {
183  ini_set('default_socket_timeout', $this->stored_socket_timeout);
184  $this->log->debug('Restoring default socket timeout to: ' . $this->stored_socket_timeout);
185  return true;
186  }
+ Here is the caller graph for this function:

◆ setResponseTimeout()

ilSoapClient::setResponseTimeout (   $a_timeout)
Parameters
int$a_timeoutResponse Timeout

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

89  {
90  $this->response_timeout = (int) $a_timeout;
91  }

◆ setSocketTimeout()

ilSoapClient::setSocketTimeout (   $a_wsdl_mode)
protected

Set socket timeout.

Returns
boolean

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

References getResponseTimeout(), and getTimeout().

Referenced by call(), and init().

163  {
164  $this->stored_socket_timeout = ini_get('default_socket_timeout');
165  $this->log->debug('Default socket timeout is: ' . $this->stored_socket_timeout);
166 
167  if ($a_wsdl_mode) {
168  $this->log->debug('WSDL mode, using socket timeout: ' . $this->getTimeout());
169  ini_set('default_socket_timeout', $this->getTimeout());
170  } else {
171  $this->log->debug('Non WSDL mode, using socket timeout: ' . $this->getResponseTimeout());
172  ini_set('default_socket_timeout', $this->getResponseTimeout());
173  }
174  return true;
175  }
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 71 of file class.ilSoapClient.php.

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

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: