ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
ilSoapClient Class Reference
+ Collaboration diagram for ilSoapClient:

Public Member Functions

 __construct (string $a_uri='')
 
 getServer ()
 
 setTimeout (int $a_timeout)
 
 getTimeout ()
 
 setResponseTimeout (int $a_timeout)
 
 getResponseTimeout ()
 
 enableWSDL (bool $a_stat)
 
 enabledWSDL ()
 
 init ()
 
 call (string $a_operation, array $a_params)
 

Data Fields

const DEFAULT_CONNECT_TIMEOUT = 10
 
const DEFAULT_RESPONSE_TIMEOUT = 5
 

Protected Member Functions

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

Private Attributes

ilLogger $log
 
ilSetting $settings
 
SoapClient $client = null
 
string $uri
 
bool $use_wsdl = true
 
int $connect_timeout = self::DEFAULT_CONNECT_TIMEOUT
 
int $response_timeout = self::DEFAULT_RESPONSE_TIMEOUT
 
int $stored_socket_timeout = null
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

References $DIC, ILIAS\Repository\int(), and ILIAS\Repository\settings().

29  {
30  global $DIC;
31 
32  $this->settings = $DIC->settings();
33  $this->log = $DIC->logger()->wsrv();
34  $this->uri = $a_uri;
35  $this->use_wsdl = true;
36  $timeout = (int) $this->settings->get('soap_connect_timeout', (string) self::DEFAULT_CONNECT_TIMEOUT);
37  if ($timeout) {
38  $this->connect_timeout = $timeout;
39  }
40  $this->connect_timeout = $timeout;
41 
42  $this->response_timeout = (int) $this->settings->get('soap_response_timeout', (string) self::DEFAULT_RESPONSE_TIMEOUT);
43  }
global $DIC
Definition: shib_login.php:25
+ Here is the call graph for this function:

Member Function Documentation

◆ call()

ilSoapClient::call ( string  $a_operation,
array  $a_params 
)
Parameters
string$a_operation
array$a_params
Returns
false|mixed

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

References ILIAS\UI\examples\Progress\Bar\client(), resetSocketTimeout(), and setSocketTimeout().

155  {
156  $this->log->debug('Calling webservice: ' . $a_operation);
157 
158  $this->setSocketTimeout(false);
159  try {
160  return $this->client->__call($a_operation, $a_params);
161  } catch (SoapFault $exception) {
162  $this->log->error('Calling webservice failed with message: ' . $exception->getMessage());
163  $this->log->debug((string) $this->client->__getLastResponseHeaders());
164  $this->log->debug((string) $this->client->__getLastResponse());
165  return false;
166  } catch (Exception $exception) {
167  $this->log->error('Caught unknown exception with message: ' . $exception->getMessage());
168  $this->log->debug((string) $this->client->__getLastResponseHeaders());
169  $this->log->debug((string) $this->client->__getLastResponse());
170  } finally {
171  $this->resetSocketTimeout();
172  }
173 
174  return false;
175  }
resetSocketTimeout()
Reset socket default timeout to defaults.
setSocketTimeout(bool $a_wsdl_mode)
client()
description: > This example shows how a Progress Bar can be rendered and used on the client...
Definition: client.php:21
+ Here is the call graph for this function:

◆ enabledWSDL()

ilSoapClient::enabledWSDL ( )

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

References $use_wsdl.

75  : bool
76  {
77  return $this->use_wsdl;
78  }

◆ enableWSDL()

ilSoapClient::enableWSDL ( bool  $a_stat)

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

70  : void
71  {
72  $this->use_wsdl = $a_stat;
73  }

◆ getResponseTimeout()

ilSoapClient::getResponseTimeout ( )

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

References $response_timeout.

Referenced by init(), and setSocketTimeout().

65  : int
66  {
68  }
+ Here is the caller graph for this function:

◆ getServer()

ilSoapClient::getServer ( )

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

References $uri.

Referenced by init().

45  : string
46  {
47  return $this->uri;
48  }
+ Here is the caller graph for this function:

◆ getTimeout()

ilSoapClient::getTimeout ( )

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

References $connect_timeout.

Referenced by init(), and setSocketTimeout().

55  : int
56  {
58  }
+ Here is the caller graph for this function:

◆ init()

ilSoapClient::init ( )

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

References ilUtil\_getHttpPath(), ILIAS\UI\examples\Progress\Bar\client(), getResponseTimeout(), getServer(), getTimeout(), resetSocketTimeout(), setSocketTimeout(), and ILIAS\Repository\settings().

80  : bool
81  {
82  $internal_path = $this->settings->get('soap_internal_wsdl_path');
83  if (trim($this->getServer()) === '') {
84  if ($internal_path) {
85  $this->uri = $internal_path;
86  } elseif (trim($this->settings->get('soap_wsdl_path', '')) !== '') {
87  $this->uri = $this->settings->get('soap_wsdl_path', '');
88  } else {
89  $this->uri = ilUtil::_getHttpPath() . '/public/soap/server.php?wsdl';
90  }
91  }
92  try {
93  $this->log->debug('Using wsdl: ' . $this->getServer());
94  $this->log->debug('Using connection timeout: ' . $this->getTimeout());
95  $this->log->debug('Using response timeout: ' . $this->getResponseTimeout());
96 
97  $this->setSocketTimeout(true);
98  $this->client = new SoapClient(
99  $this->uri,
100  array(
101  'exceptions' => true,
102  'trace' => 1,
103  'connection_timeout' => $this->getTimeout(),
104  'stream_context' => $this->uri === $internal_path ? stream_context_create([
105  'ssl' => [
106  'verify_peer' => (bool) $this->settings->get('soap_internal_wsdl_verify_peer', '1'),
107  'verify_peer_name' => (bool) $this->settings->get('soap_internal_wsdl_verify_peer_name', '1'),
108  'allow_self_signed' => (bool) $this->settings->get('soap_internal_wsdl_allow_self_signed', ''),
109  ]
110  ]) : null
111  )
112  );
113  return true;
114  } catch (SoapFault $ex) {
115  $this->log->warning('Soap init failed with message: ' . $ex->getMessage());
116  $this->resetSocketTimeout();
117  return false;
118  } finally {
119  $this->resetSocketTimeout();
120  }
121  }
resetSocketTimeout()
Reset socket default timeout to defaults.
setSocketTimeout(bool $a_wsdl_mode)
client()
description: > This example shows how a Progress Bar can be rendered and used on the client...
Definition: client.php:21
static _getHttpPath()
+ Here is the call graph for this function:

◆ resetSocketTimeout()

ilSoapClient::resetSocketTimeout ( )
protected

Reset socket default timeout to defaults.

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

Referenced by call(), and init().

142  : bool
143  {
144  ini_set('default_socket_timeout', (string) $this->stored_socket_timeout);
145  $this->log->debug('Restoring default socket timeout to: ' . $this->stored_socket_timeout);
146  return true;
147  }
+ Here is the caller graph for this function:

◆ setResponseTimeout()

ilSoapClient::setResponseTimeout ( int  $a_timeout)

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

60  : void
61  {
62  $this->response_timeout = $a_timeout;
63  }

◆ setSocketTimeout()

ilSoapClient::setSocketTimeout ( bool  $a_wsdl_mode)
protected

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

References getResponseTimeout(), getTimeout(), and ILIAS\Repository\int().

Referenced by call(), and init().

123  : bool
124  {
125  $this->stored_socket_timeout = (int) ini_get('default_socket_timeout');
126  $this->log->debug('Default socket timeout is: ' . $this->stored_socket_timeout);
127 
128  if ($a_wsdl_mode) {
129  $this->log->debug('WSDL mode, using socket timeout: ' . $this->getTimeout());
130  ini_set('default_socket_timeout', (string) $this->getTimeout());
131  } else {
132  $this->log->debug('Non WSDL mode, using socket timeout: ' . $this->getResponseTimeout());
133  ini_set('default_socket_timeout', (string) $this->getResponseTimeout());
134  }
135 
136  return true;
137  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTimeout()

ilSoapClient::setTimeout ( int  $a_timeout)

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

50  : void
51  {
52  $this->connect_timeout = $a_timeout;
53  }

Field Documentation

◆ $client

SoapClient ilSoapClient::$client = null
private

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

◆ $connect_timeout

int ilSoapClient::$connect_timeout = self::DEFAULT_CONNECT_TIMEOUT
private

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

Referenced by getTimeout().

◆ $log

ilLogger ilSoapClient::$log
private

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

◆ $response_timeout

int ilSoapClient::$response_timeout = self::DEFAULT_RESPONSE_TIMEOUT
private

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

Referenced by getResponseTimeout().

◆ $settings

ilSetting ilSoapClient::$settings
private

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

◆ $stored_socket_timeout

int ilSoapClient::$stored_socket_timeout = null
private

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

◆ $uri

string ilSoapClient::$uri
private

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

Referenced by getServer().

◆ $use_wsdl

bool ilSoapClient::$use_wsdl = true
private

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

Referenced by enabledWSDL().

◆ DEFAULT_CONNECT_TIMEOUT

const ilSoapClient::DEFAULT_CONNECT_TIMEOUT = 10

◆ DEFAULT_RESPONSE_TIMEOUT

const ilSoapClient::DEFAULT_RESPONSE_TIMEOUT = 5

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