ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 27 of file class.ilSoapClient.php.

Constructor & Destructor Documentation

◆ __construct()

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

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

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

42  {
43  global $DIC;
44 
45  $this->settings = $DIC->settings();
46  $this->log = $DIC->logger()->wsrv();
47  $this->uri = $a_uri;
48  $this->use_wsdl = true;
49  $timeout = (int) $this->settings->get('soap_connect_timeout', (string) self::DEFAULT_CONNECT_TIMEOUT);
50  if ($timeout) {
51  $this->connect_timeout = $timeout;
52  }
53  $this->connect_timeout = $timeout;
54 
55  $this->response_timeout = (int) $this->settings->get('soap_response_timeout', (string) self::DEFAULT_RESPONSE_TIMEOUT);
56  }
global $DIC
Definition: shib_login.php:22
+ 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 167 of file class.ilSoapClient.php.

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

168  {
169  $this->log->debug('Calling webservice: ' . $a_operation);
170 
171  $this->setSocketTimeout(false);
172  try {
173  return $this->client->__call($a_operation, $a_params);
174  } catch (SoapFault $exception) {
175  $this->log->error('Calling webservice failed with message: ' . $exception->getMessage());
176  $this->log->debug((string) $this->client->__getLastResponseHeaders());
177  $this->log->debug((string) $this->client->__getLastResponse());
178  return false;
179  } catch (Exception $exception) {
180  $this->log->error('Caught unknown exception with message: ' . $exception->getMessage());
181  $this->log->debug((string) $this->client->__getLastResponseHeaders());
182  $this->log->debug((string) $this->client->__getLastResponse());
183  } finally {
184  $this->resetSocketTimeout();
185  }
186 
187  return false;
188  }
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:37
+ Here is the call graph for this function:

◆ enabledWSDL()

ilSoapClient::enabledWSDL ( )

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

References $use_wsdl.

88  : bool
89  {
90  return $this->use_wsdl;
91  }

◆ enableWSDL()

ilSoapClient::enableWSDL ( bool  $a_stat)

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

83  : void
84  {
85  $this->use_wsdl = $a_stat;
86  }

◆ getResponseTimeout()

ilSoapClient::getResponseTimeout ( )

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

References $response_timeout.

Referenced by init(), and setSocketTimeout().

78  : int
79  {
81  }
+ Here is the caller graph for this function:

◆ getServer()

ilSoapClient::getServer ( )

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

References $uri.

Referenced by init().

58  : string
59  {
60  return $this->uri;
61  }
+ Here is the caller graph for this function:

◆ getTimeout()

ilSoapClient::getTimeout ( )

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

References $connect_timeout.

Referenced by init(), and setSocketTimeout().

68  : int
69  {
71  }
+ Here is the caller graph for this function:

◆ init()

ilSoapClient::init ( )

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

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

93  : bool
94  {
95  $internal_path = $this->settings->get('soap_internal_wsdl_path');
96  if (trim($this->getServer()) === '') {
97  if ($internal_path) {
98  $this->uri = $internal_path;
99  } elseif (trim($this->settings->get('soap_wsdl_path', '')) !== '') {
100  $this->uri = $this->settings->get('soap_wsdl_path', '');
101  } else {
102  $this->uri = ilUtil::_getHttpPath() . '/public/soap/server.php?wsdl';
103  }
104  }
105  try {
106  $this->log->debug('Using wsdl: ' . $this->getServer());
107  $this->log->debug('Using connection timeout: ' . $this->getTimeout());
108  $this->log->debug('Using response timeout: ' . $this->getResponseTimeout());
109 
110  $this->setSocketTimeout(true);
111  $this->client = new SoapClient(
112  $this->uri,
113  array(
114  'exceptions' => true,
115  'trace' => 1,
116  'connection_timeout' => $this->getTimeout(),
117  'stream_context' => $this->uri === $internal_path ? stream_context_create([
118  'ssl' => [
119  'verify_peer' => (bool) $this->settings->get('soap_internal_wsdl_verify_peer', '1'),
120  'verify_peer_name' => (bool) $this->settings->get('soap_internal_wsdl_verify_peer_name', '1'),
121  'allow_self_signed' => (bool) $this->settings->get('soap_internal_wsdl_allow_self_signed', ''),
122  ]
123  ]) : null
124  )
125  );
126  return true;
127  } catch (SoapFault $ex) {
128  $this->log->warning('Soap init failed with message: ' . $ex->getMessage());
129  $this->resetSocketTimeout();
130  return false;
131  } finally {
132  $this->resetSocketTimeout();
133  }
134  }
resetSocketTimeout()
Reset socket default timeout to defaults.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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:37
static _getHttpPath()
+ Here is the call graph for this function:

◆ resetSocketTimeout()

ilSoapClient::resetSocketTimeout ( )
protected

Reset socket default timeout to defaults.

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

Referenced by call(), and init().

155  : bool
156  {
157  ini_set('default_socket_timeout', (string) $this->stored_socket_timeout);
158  $this->log->debug('Restoring default socket timeout to: ' . $this->stored_socket_timeout);
159  return true;
160  }
+ Here is the caller graph for this function:

◆ setResponseTimeout()

ilSoapClient::setResponseTimeout ( int  $a_timeout)

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

73  : void
74  {
75  $this->response_timeout = $a_timeout;
76  }

◆ setSocketTimeout()

ilSoapClient::setSocketTimeout ( bool  $a_wsdl_mode)
protected

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

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

Referenced by call(), and init().

136  : bool
137  {
138  $this->stored_socket_timeout = (int) ini_get('default_socket_timeout');
139  $this->log->debug('Default socket timeout is: ' . $this->stored_socket_timeout);
140 
141  if ($a_wsdl_mode) {
142  $this->log->debug('WSDL mode, using socket timeout: ' . $this->getTimeout());
143  ini_set('default_socket_timeout', (string) $this->getTimeout());
144  } else {
145  $this->log->debug('Non WSDL mode, using socket timeout: ' . $this->getResponseTimeout());
146  ini_set('default_socket_timeout', (string) $this->getResponseTimeout());
147  }
148 
149  return true;
150  }
+ 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 63 of file class.ilSoapClient.php.

63  : void
64  {
65  $this->connect_timeout = $a_timeout;
66  }

Field Documentation

◆ $client

SoapClient ilSoapClient::$client = null
private

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

◆ $connect_timeout

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

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

Referenced by getTimeout().

◆ $log

ilLogger ilSoapClient::$log
private

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

◆ $response_timeout

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

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

Referenced by getResponseTimeout().

◆ $settings

ilSetting ilSoapClient::$settings
private

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

◆ $stored_socket_timeout

int ilSoapClient::$stored_socket_timeout = null
private

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

◆ $uri

string ilSoapClient::$uri
private

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

Referenced by getServer().

◆ $use_wsdl

bool ilSoapClient::$use_wsdl = true
private

Definition at line 36 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: