ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $DIC, $ilSetting, and ilLoggerFactory\getLogger().

41  {
42  global $DIC;
43 
44  $ilSetting = $DIC['ilSetting'];
45 
46  $this->log = ilLoggerFactory::getLogger('wsrv');
47 
48  $this->uri = $a_uri;
49 
50  $this->use_wsdl = true;
51  $timeout = $ilSetting->get('soap_connect_timeout', self::DEFAULT_CONNECT_TIMEOUT);
52  if (!$timeout) {
53  $timeout = self::DEFAULT_CONNECT_TIMEOUT;
54  }
55  $this->connect_timeout = $timeout;
56 
57  $this->response_timeout = self::DEFAULT_RESPONSE_TIMEOUT;
58  }
global $DIC
Definition: saml.php:7
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 197 of file class.ilSoapClient.php.

References resetSocketTimeout(), and setSocketTimeout().

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

References $uri.

Referenced by init().

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

◆ getTimeout()

ilSoapClient::getTimeout ( )

Get connect timeout.

Returns
int

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

References $connect_timeout.

Referenced by init(), and setSocketTimeout().

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

◆ init()

ilSoapClient::init ( )

Init soap client.

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

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

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

Referenced by call(), and init().

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

◆ setResponseTimeout()

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

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

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

◆ setSocketTimeout()

ilSoapClient::setSocketTimeout (   $a_wsdl_mode)
protected

Set socket timeout.

Returns
boolean

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

References getResponseTimeout(), and getTimeout().

Referenced by call(), and init().

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

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

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: