ILIAS  release_8 Revision v8.23
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: feed.php:28
+ 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 144 of file class.ilSoapClient.php.

References resetSocketTimeout(), and setSocketTimeout().

145  {
146  $this->log->debug('Calling webservice: ' . $a_operation);
147 
148  $this->setSocketTimeout(false);
149  try {
150  return $this->client->__call($a_operation, $a_params);
151  } catch (SoapFault $exception) {
152  $this->log->error('Calling webservice failed with message: ' . $exception->getMessage());
153  $this->log->debug((string) $this->client->__getLastResponseHeaders());
154  $this->log->debug((string) $this->client->__getLastResponse());
155  return false;
156  } catch (Exception $exception) {
157  $this->log->error('Caught unknown exception with message: ' . $exception->getMessage());
158  $this->log->debug((string) $this->client->__getLastResponseHeaders());
159  $this->log->debug((string) $this->client->__getLastResponse());
160  } finally {
161  $this->resetSocketTimeout();
162  }
163 
164  return false;
165  }
resetSocketTimeout()
Reset socket default timeout to defaults.
setSocketTimeout(bool $a_wsdl_mode)
+ 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(), getResponseTimeout(), getServer(), getTimeout(), resetSocketTimeout(), setSocketTimeout(), and ILIAS\Repository\settings().

80  : bool
81  {
82  if (trim($this->getServer()) === '') {
83  if (trim($this->settings->get('soap_wsdl_path', '')) !== '') {
84  $this->uri = $this->settings->get('soap_wsdl_path', '');
85  } else {
86  $this->uri = ilUtil::_getHttpPath() . '/webservice/soap/server.php?wsdl';
87  }
88  }
89  try {
90  $this->log->debug('Using wsdl: ' . $this->getServer());
91  $this->log->debug('Using connection timeout: ' . $this->getTimeout());
92  $this->log->debug('Using response timeout: ' . $this->getResponseTimeout());
93 
94  $this->setSocketTimeout(true);
95  $this->client = new SoapClient(
96  $this->uri,
97  array(
98  'exceptions' => true,
99  'trace' => 1,
100  'connection_timeout' => $this->getTimeout()
101  )
102  );
103  return true;
104  } catch (SoapFault $ex) {
105  $this->log->warning('Soap init failed with message: ' . $ex->getMessage());
106  $this->resetSocketTimeout();
107  return false;
108  } finally {
109  $this->resetSocketTimeout();
110  }
111  }
resetSocketTimeout()
Reset socket default timeout to defaults.
setSocketTimeout(bool $a_wsdl_mode)
static _getHttpPath()
+ Here is the call graph for this function:

◆ resetSocketTimeout()

ilSoapClient::resetSocketTimeout ( )
protected

Reset socket default timeout to defaults.

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

Referenced by call(), and init().

132  : bool
133  {
134  ini_set('default_socket_timeout', (string) $this->stored_socket_timeout);
135  $this->log->debug('Restoring default socket timeout to: ' . $this->stored_socket_timeout);
136  return true;
137  }
+ 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 113 of file class.ilSoapClient.php.

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

Referenced by call(), and init().

113  : bool
114  {
115  $this->stored_socket_timeout = (int) ini_get('default_socket_timeout');
116  $this->log->debug('Default socket timeout is: ' . $this->stored_socket_timeout);
117 
118  if ($a_wsdl_mode) {
119  $this->log->debug('WSDL mode, using socket timeout: ' . $this->getTimeout());
120  ini_set('default_socket_timeout', (string) $this->getTimeout());
121  } else {
122  $this->log->debug('Non WSDL mode, using socket timeout: ' . $this->getResponseTimeout());
123  ini_set('default_socket_timeout', (string) $this->getResponseTimeout());
124  }
125 
126  return true;
127  }
+ 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: