19declare(strict_types=1);
46 $this->log =
$DIC->logger()->wsrv();
48 $this->use_wsdl =
true;
51 $this->connect_timeout = $timeout;
53 $this->connect_timeout = $timeout;
65 $this->connect_timeout = $a_timeout;
75 $this->response_timeout = $a_timeout;
85 $this->use_wsdl = $a_stat;
93 public function init(): bool
95 $internal_path = $this->
settings->get(
'soap_internal_wsdl_path');
98 $uri = (new \ILIAS\Data\URI($internal_path));
99 parse_str(
$uri->getQuery() ??
'', $query);
100 $this->uri = (string) (isset($query[
'wsdl']) ?
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',
'');
110 $this->log->debug(
'Using wsdl: ' . $this->
getServer());
111 $this->log->debug(
'Using connection timeout: ' . $this->
getTimeout());
115 $this->
client =
new SoapClient(
118 'exceptions' =>
true,
121 'stream_context' => $this->uri === $internal_path ? stream_context_create([
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',
''),
131 }
catch (SoapFault $ex) {
132 $this->log->warning(
'Soap init failed with message: ' . $ex->getMessage());
142 $this->stored_socket_timeout = (
int) ini_get(
'default_socket_timeout');
143 $this->log->debug(
'Default socket timeout is: ' . $this->stored_socket_timeout);
146 $this->log->debug(
'WSDL mode, using socket timeout: ' . $this->
getTimeout());
147 ini_set(
'default_socket_timeout', (
string) $this->
getTimeout());
149 $this->log->debug(
'Non WSDL mode, using socket timeout: ' . $this->
getResponseTimeout());
161 ini_set(
'default_socket_timeout', (
string) $this->stored_socket_timeout);
162 $this->log->debug(
'Restoring default socket timeout to: ' . $this->stored_socket_timeout);
171 public function call(
string $a_operation, array $a_params)
173 $this->log->debug(
'Calling webservice: ' . $a_operation);
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());
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());
Component logger with individual log levels by component id.
call(string $a_operation, array $a_params)
setSocketTimeout(bool $a_wsdl_mode)
int $stored_socket_timeout
setTimeout(int $a_timeout)
const DEFAULT_CONNECT_TIMEOUT
setResponseTimeout(int $a_timeout)
resetSocketTimeout()
Reset socket default timeout to defaults.
__construct(string $a_uri='')
const DEFAULT_RESPONSE_TIMEOUT