ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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
 
const MAX_DIRECTORY_SEARCH_DEPTH = 20
 

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 42 of file class.ilSoapClient.php.

43 {
44 global $DIC;
45
46 $this->settings = $DIC->settings();
47 $this->log = $DIC->logger()->wsrv();
48 $this->uri = $a_uri;
49 $this->use_wsdl = true;
50 $timeout = (int) $this->settings->get('soap_connect_timeout', (string) self::DEFAULT_CONNECT_TIMEOUT);
51 if ($timeout) {
52 $this->connect_timeout = $timeout;
53 }
54 $this->connect_timeout = $timeout;
55
56 $this->response_timeout = (int) $this->settings->get('soap_response_timeout', (string) self::DEFAULT_RESPONSE_TIMEOUT);
57 }
const DEFAULT_CONNECT_TIMEOUT
const DEFAULT_RESPONSE_TIMEOUT
global $DIC
Definition: shib_login.php:26

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

+ 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 200 of file class.ilSoapClient.php.

201 {
202 $this->log->debug('Calling webservice: ' . $a_operation);
203
204 $this->setSocketTimeout(false);
205 try {
206 return $this->client->__call($a_operation, $a_params);
207 } catch (SoapFault $exception) {
208 $this->log->error('Calling webservice failed with message: ' . $exception->getMessage());
209 $this->log->debug((string) $this->client->__getLastResponseHeaders());
210 $this->log->debug((string) $this->client->__getLastResponse());
211 return false;
212 } catch (Exception $exception) {
213 $this->log->error('Caught unknown exception with message: ' . $exception->getMessage());
214 $this->log->debug((string) $this->client->__getLastResponseHeaders());
215 $this->log->debug((string) $this->client->__getLastResponse());
216 } finally {
217 $this->resetSocketTimeout();
218 }
219
220 return false;
221 }
setSocketTimeout(bool $a_wsdl_mode)
resetSocketTimeout()
Reset socket default timeout to defaults.

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

+ Here is the call graph for this function:

◆ enabledWSDL()

ilSoapClient::enabledWSDL ( )

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

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

References $use_wsdl.

◆ enableWSDL()

ilSoapClient::enableWSDL ( bool  $a_stat)

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

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

◆ getResponseTimeout()

ilSoapClient::getResponseTimeout ( )

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

79 : int
80 {
82 }

References $response_timeout.

Referenced by init(), and setSocketTimeout().

+ Here is the caller graph for this function:

◆ getServer()

ilSoapClient::getServer ( )

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

59 : string
60 {
61 return $this->uri;
62 }

References $uri.

Referenced by init().

+ Here is the caller graph for this function:

◆ getTimeout()

ilSoapClient::getTimeout ( )

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

69 : int
70 {
72 }

References $connect_timeout.

Referenced by init(), and setSocketTimeout().

+ Here is the caller graph for this function:

◆ init()

ilSoapClient::init ( )

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

94 : bool
95 {
96 $internal_path = $this->settings->get('soap_internal_wsdl_path');
97 if (trim($this->getServer()) === '') {
98 if ($internal_path) {
99 $uri = (new \ILIAS\Data\URI($internal_path));
100 parse_str($uri->getQuery() ?? '', $query);
101 $this->uri = (string) (isset($query['wsdl']) ?
102 $uri :
103 $uri->withQuery(http_build_query(array_merge($query, ['wsdl' => '']))));
104 } elseif (trim($this->settings->get('soap_wsdl_path', '')) !== '') {
105 $this->uri = $this->settings->get('soap_wsdl_path', '');
106 } else {
107 $request_path = ilUtil::_getHttpPath();
108 $depth = 0;
109 if (PHP_SAPI !== 'cli') {
110 $script_path = dirname($_SERVER['SCRIPT_FILENAME']);
111 while ($depth < self::MAX_DIRECTORY_SEARCH_DEPTH && !is_file($script_path . '/ilias.php')) {
112 $parent = dirname($script_path);
113 if ($parent === $script_path) {
114 break;
115 }
116 $script_path = $parent;
117 $depth++;
118 }
119 }
120
121 if ($depth > 0 && is_file($script_path . '/ilias.php')) {
122 $url_parts = parse_url($request_path);
123 $path = $url_parts['path'] ?? '';
124 $path_parts = explode('/', rtrim($path, '/'));
125 $path_parts = array_slice($path_parts, 0, -$depth);
126 $new_path = implode('/', $path_parts);
127
128 $request_path = $url_parts['scheme'] . '://' . $url_parts['host'];
129 if (isset($url_parts['port'])) {
130 $request_path .= ':' . $url_parts['port'];
131 }
132 $request_path .= $new_path;
133 }
134
135 $this->uri = rtrim($request_path, '/') . '/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' => $this->getTimeout(),
150 'stream_context' => $this->uri === $internal_path ? stream_context_create([
151 'ssl' => [
152 'verify_peer' => (bool) $this->settings->get('soap_internal_wsdl_verify_peer', '1'),
153 'verify_peer_name' => (bool) $this->settings->get('soap_internal_wsdl_verify_peer_name', '1'),
154 'allow_self_signed' => (bool) $this->settings->get('soap_internal_wsdl_allow_self_signed', ''),
155 ]
156 ]) : null
157 )
158 );
159 return true;
160 } catch (SoapFault $ex) {
161 $this->log->warning('Soap init failed with message: ' . $ex->getMessage());
162 $this->resetSocketTimeout();
163 return false;
164 } finally {
165 $this->resetSocketTimeout();
166 }
167 }
static _getHttpPath()
$path
Definition: ltiservices.php:30
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26

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

+ Here is the call graph for this function:

◆ resetSocketTimeout()

ilSoapClient::resetSocketTimeout ( )
protected

Reset socket default timeout to defaults.

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

188 : bool
189 {
190 ini_set('default_socket_timeout', (string) $this->stored_socket_timeout);
191 $this->log->debug('Restoring default socket timeout to: ' . $this->stored_socket_timeout);
192 return true;
193 }

Referenced by call(), and init().

+ Here is the caller graph for this function:

◆ setResponseTimeout()

ilSoapClient::setResponseTimeout ( int  $a_timeout)

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

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

◆ setSocketTimeout()

ilSoapClient::setSocketTimeout ( bool  $a_wsdl_mode)
protected

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

169 : bool
170 {
171 $this->stored_socket_timeout = (int) ini_get('default_socket_timeout');
172 $this->log->debug('Default socket timeout is: ' . $this->stored_socket_timeout);
173
174 if ($a_wsdl_mode) {
175 $this->log->debug('WSDL mode, using socket timeout: ' . $this->getTimeout());
176 ini_set('default_socket_timeout', (string) $this->getTimeout());
177 } else {
178 $this->log->debug('Non WSDL mode, using socket timeout: ' . $this->getResponseTimeout());
179 ini_set('default_socket_timeout', (string) $this->getResponseTimeout());
180 }
181
182 return true;
183 }

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

Referenced by call(), and init().

+ 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 64 of file class.ilSoapClient.php.

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

Field Documentation

◆ $client

SoapClient ilSoapClient::$client = null
private

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

◆ $connect_timeout

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

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

Referenced by getTimeout().

◆ $log

ilLogger ilSoapClient::$log
private

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

◆ $response_timeout

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

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

Referenced by getResponseTimeout().

◆ $settings

ilSetting ilSoapClient::$settings
private

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

◆ $stored_socket_timeout

int ilSoapClient::$stored_socket_timeout = null
private

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

◆ $uri

string ilSoapClient::$uri
private

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

Referenced by getServer(), and init().

◆ $use_wsdl

bool ilSoapClient::$use_wsdl = true
private

Definition at line 37 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

◆ MAX_DIRECTORY_SEARCH_DEPTH

const ilSoapClient::MAX_DIRECTORY_SEARCH_DEPTH = 20

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


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