2 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientException.php';
49 public function __construct($a_url, $a_prefix =
'', $a_timeout = 0, $a_encoding =
'utf-8')
51 if (!extension_loaded(
'xmlrpc')) {
56 $this->url = (string) $a_url;
57 $this->prefix = (string) $a_prefix;
58 $this->timeout = (int) $a_timeout;
59 $this->encoding = (string) $a_encoding;
70 public function __call($a_method, $a_params)
73 $method_name = str_replace(
'_',
'.', $this->prefix . $a_method);
75 'verbosity' =>
'newlines_only',
76 'escaping' =>
'markup' 79 if ($this->encoding) {
83 $post_data = xmlrpc_encode_request($method_name, $a_params, $rpc_options);
87 include_once
'./Services/WebServices/Curl/classes/class.ilCurlConnection.php';
90 $curl->setOpt(CURLOPT_HEADER,
'Content-Type: text/xml');
91 $curl->setOpt(CURLOPT_POST, (strlen($post_data) > 0));
92 $curl->setOpt(CURLOPT_POSTFIELDS, $post_data);
93 $curl->setOpt(CURLOPT_RETURNTRANSFER, 1);
95 if ($this->timeout > 0) {
96 $curl->setOpt(CURLOPT_TIMEOUT, $this->timeout);
99 $xml_resp = $curl->exec();
101 ilLoggerFactory::getLogger(
'wsrv')->error(
'RpcClient could not connect to ' . $this->url .
' Reason ' . $e->getCode() .
': ' . $e->getMessage());
106 $resp = xmlrpc_decode($xml_resp, $this->encoding);
109 if (is_array($resp) && xmlrpc_is_fault($resp)) {
111 include_once
'./Services/WebServices/RPC/classes/class.ilRpcClientException.php';
112 throw new ilRpcClientException(
'RPC-Server returned fault message: ' . $resp[
'faultString'], $resp[
'faultCode']);
Class ilRpcClientException.
__call($a_method, $a_params)
Magic caller to all RPC functions.
__construct($a_url, $a_prefix='', $a_timeout=0, $a_encoding='utf-8')
ilRpcClient constructor.
static getLogger($a_component_id)
Get component logger.