ILIAS  release_7 Revision v7.30-3-g800a261c036
ilSoapClient Class Reference
+ Collaboration diagram for ilSoapClient:

Public Member Functions

 __construct ($a_uri='')
 
 getServer ()
 Get server uri. More...
 
 setTimeout ($a_timeout)
 Set connect timeout. More...
 
 getTimeout ()
 Get connect timeout. More...
 
 setResponseTimeout ($a_timeout)
 
 getResponseTimeout ()
 
 enableWSDL ($a_stat)
 enable wsdl mode More...
 
 enabledWSDL ()
 Check if wsdl is enabled. More...
 
 init ()
 Init soap client. More...
 
 call ($a_operation, $a_params)
 Call webservice method. More...
 

Data Fields

const DEFAULT_CONNECT_TIMEOUT = 10
 
const DEFAULT_RESPONSE_TIMEOUT = 5
 

Protected Member Functions

 setSocketTimeout ($a_wsdl_mode)
 Set socket timeout. More...
 
 resetSocketTimeout ()
 Reset socket default timeout to defaults. More...
 

Private Attributes

 $log = null
 
 $client = null
 
 $uri
 
 $connect_timeout = 10
 
 $response_timeout = 10
 
 $stored_socket_timeout = null
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

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

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

41 {
42 global $DIC;
43
44 $ilSetting = $DIC['ilSetting'];
45
46 $this->log = ilLoggerFactory::getLogger('wsrv');
47
48 $this->uri = $a_uri;
49
50 $this->use_wsdl = true;
51 $timeout = $ilSetting->get('soap_connect_timeout', self::DEFAULT_CONNECT_TIMEOUT);
52 if (!$timeout) {
54 }
55 $this->connect_timeout = $timeout;
56
57 $this->response_timeout = (int) $ilSetting->get('soap_response_timeout', self::DEFAULT_RESPONSE_TIMEOUT);
58 }
static getLogger($a_component_id)
Get component logger.
const DEFAULT_CONNECT_TIMEOUT
global $DIC
Definition: goto.php:24
global $ilSetting
Definition: privfeed.php:17

References $DIC, $ilSetting, DEFAULT_CONNECT_TIMEOUT, and ilLoggerFactory\getLogger().

+ Here is the call graph for this function:

Member Function Documentation

◆ call()

ilSoapClient::call (   $a_operation,
  $a_params 
)

Call webservice method.

Parameters
string$a_operation
array$a_params

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

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

References resetSocketTimeout(), and setSocketTimeout().

+ Here is the call graph for this function:

◆ enabledWSDL()

ilSoapClient::enabledWSDL ( )

Check if wsdl is enabled.

Returns
type

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

117 {
118 return $this->use_wsdl;
119 }

◆ enableWSDL()

ilSoapClient::enableWSDL (   $a_stat)

enable wsdl mode

Parameters
type$a_stat

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

108 {
109 $this->use_wsdl = $a_stat;
110 }

◆ getResponseTimeout()

ilSoapClient::getResponseTimeout ( )
Returns
int Response Timeout

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

99 {
101 }

References $response_timeout.

Referenced by init(), and setSocketTimeout().

+ Here is the caller graph for this function:

◆ getServer()

ilSoapClient::getServer ( )

Get server uri.

Returns
string

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

65 {
66 return $this->uri;
67 }

References $uri.

Referenced by init().

+ Here is the caller graph for this function:

◆ getTimeout()

ilSoapClient::getTimeout ( )

Get connect timeout.

Returns
int

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

83 {
85 }

References $connect_timeout.

Referenced by init(), and setSocketTimeout().

+ Here is the caller graph for this function:

◆ init()

ilSoapClient::init ( )

Init soap client.

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

126 {
127 global $DIC;
128
129 $ilSetting = $DIC['ilSetting'];
130
131 if (!strlen(trim($this->getServer()))) {
132 if (strlen(trim($ilSetting->get('soap_wsdl_path', '')))) {
133 $this->uri = $ilSetting->get('soap_wsdl_path', '');
134 } else {
135 $this->uri = ilUtil::_getHttpPath() . '/webservice/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' => (int) $this->getTimeout()
150 )
151 );
152 return true;
153 } catch (SoapFault $ex) {
154 $this->log->warning('Soap init failed with message: ' . $ex->getMessage());
155 $this->resetSocketTimeout();
156 return false;
157 } finally {
158 $this->resetSocketTimeout();
159 }
160 }
getTimeout()
Get connect timeout.
getServer()
Get server uri.
static _getHttpPath()

References $DIC, $ilSetting, ilUtil\_getHttpPath(), getResponseTimeout(), getServer(), getTimeout(), resetSocketTimeout(), and setSocketTimeout().

+ Here is the call graph for this function:

◆ resetSocketTimeout()

ilSoapClient::resetSocketTimeout ( )
protected

Reset socket default timeout to defaults.

Returns
boolean

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

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

Referenced by call(), and init().

+ Here is the caller graph for this function:

◆ setResponseTimeout()

ilSoapClient::setResponseTimeout (   $a_timeout)
Parameters
int$a_timeoutResponse Timeout

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

91 {
92 $this->response_timeout = (int) $a_timeout;
93 }

◆ setSocketTimeout()

ilSoapClient::setSocketTimeout (   $a_wsdl_mode)
protected

Set socket timeout.

Returns
boolean

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

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

References getResponseTimeout(), and getTimeout().

Referenced by call(), and init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTimeout()

ilSoapClient::setTimeout (   $a_timeout)

Set connect timeout.

Parameters
int$a_timeout

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

74 {
75 $this->connect_timeout = $a_timeout;
76 }

Field Documentation

◆ $client

ilSoapClient::$client = null
private

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

◆ $connect_timeout

ilSoapClient::$connect_timeout = 10
private

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

Referenced by getTimeout().

◆ $log

ilSoapClient::$log = null
private

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

◆ $response_timeout

ilSoapClient::$response_timeout = 10
private

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

Referenced by getResponseTimeout().

◆ $stored_socket_timeout

ilSoapClient::$stored_socket_timeout = null
private

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

◆ $uri

ilSoapClient::$uri
private

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

Referenced by getServer().

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