ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

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

172 {
173 $this->log->debug('Calling webservice: ' . $a_operation);
174
175 $this->setSocketTimeout(false);
176 try {
177 return $this->client->__call($a_operation, $a_params);
178 } catch (SoapFault $exception) {
179 $this->log->error('Calling webservice failed with message: ' . $exception->getMessage());
180 $this->log->debug((string) $this->client->__getLastResponseHeaders());
181 $this->log->debug((string) $this->client->__getLastResponse());
182 return false;
183 } catch (Exception $exception) {
184 $this->log->error('Caught unknown exception with message: ' . $exception->getMessage());
185 $this->log->debug((string) $this->client->__getLastResponseHeaders());
186 $this->log->debug((string) $this->client->__getLastResponse());
187 } finally {
188 $this->resetSocketTimeout();
189 }
190
191 return false;
192 }
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 88 of file class.ilSoapClient.php.

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

References $use_wsdl.

◆ 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.

78 : int
79 {
81 }

References $response_timeout.

Referenced by init(), and setSocketTimeout().

+ Here is the caller graph for this function:

◆ getServer()

ilSoapClient::getServer ( )

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

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

References $uri.

Referenced by init().

+ Here is the caller graph for this function:

◆ getTimeout()

ilSoapClient::getTimeout ( )

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

68 : int
69 {
71 }

References $connect_timeout.

Referenced by init(), and setSocketTimeout().

+ Here is the caller graph for this function:

◆ init()

ilSoapClient::init ( )

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

93 : bool
94 {
95 $internal_path = $this->settings->get('soap_internal_wsdl_path');
96 if (trim($this->getServer()) === '') {
97 if ($internal_path) {
98 $uri = (new \ILIAS\Data\URI($internal_path));
99 parse_str($uri->getQuery() ?? '', $query);
100 $this->uri = (string) (isset($query['wsdl']) ?
101 $uri :
102 $uri->withQuery(http_build_query(array_merge($query, ['wsdl' => '']))));
103 } elseif (trim($this->settings->get('soap_wsdl_path', '')) !== '') {
104 $this->uri = $this->settings->get('soap_wsdl_path', '');
105 } else {
106 $this->uri = ilUtil::_getHttpPath() . '/public/soap/server.php?wsdl';
107 }
108 }
109 try {
110 $this->log->debug('Using wsdl: ' . $this->getServer());
111 $this->log->debug('Using connection timeout: ' . $this->getTimeout());
112 $this->log->debug('Using response timeout: ' . $this->getResponseTimeout());
113
114 $this->setSocketTimeout(true);
115 $this->client = new SoapClient(
116 $this->uri,
117 array(
118 'exceptions' => true,
119 'trace' => 1,
120 'connection_timeout' => $this->getTimeout(),
121 'stream_context' => $this->uri === $internal_path ? stream_context_create([
122 'ssl' => [
123 'verify_peer' => (bool) $this->settings->get('soap_internal_wsdl_verify_peer', '1'),
124 'verify_peer_name' => (bool) $this->settings->get('soap_internal_wsdl_verify_peer_name', '1'),
125 'allow_self_signed' => (bool) $this->settings->get('soap_internal_wsdl_allow_self_signed', ''),
126 ]
127 ]) : null
128 )
129 );
130 return true;
131 } catch (SoapFault $ex) {
132 $this->log->warning('Soap init failed with message: ' . $ex->getMessage());
133 $this->resetSocketTimeout();
134 return false;
135 } finally {
136 $this->resetSocketTimeout();
137 }
138 }
static _getHttpPath()

References $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 159 of file class.ilSoapClient.php.

159 : bool
160 {
161 ini_set('default_socket_timeout', (string) $this->stored_socket_timeout);
162 $this->log->debug('Restoring default socket timeout to: ' . $this->stored_socket_timeout);
163 return true;
164 }

Referenced by call(), and init().

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

140 : bool
141 {
142 $this->stored_socket_timeout = (int) ini_get('default_socket_timeout');
143 $this->log->debug('Default socket timeout is: ' . $this->stored_socket_timeout);
144
145 if ($a_wsdl_mode) {
146 $this->log->debug('WSDL mode, using socket timeout: ' . $this->getTimeout());
147 ini_set('default_socket_timeout', (string) $this->getTimeout());
148 } else {
149 $this->log->debug('Non WSDL mode, using socket timeout: ' . $this->getResponseTimeout());
150 ini_set('default_socket_timeout', (string) $this->getResponseTimeout());
151 }
152
153 return true;
154 }

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 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(), and init().

◆ $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: