Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00033 define("RPC_TIMEOUT",10);
00034
00035 include_once('Services/WebServices/RPC/classes/class.ilRPCServerSettings.php');
00036
00037 class ilRPCServerAdapter
00038 {
00039 var $log = null;
00040 var $db = null;
00041 var $err = null;
00042
00043 var $settings_obj = null;
00044
00045 var $rpc_client = null;
00046 var $rpc_message = null;
00047
00048 function ilRPCServerAdapter()
00049 {
00050 global $ilLog,$ilDB,$ilError;
00051
00052 $this->log =& $ilLog;
00053 $this->db =& $ilDB;
00054 $this->err =& $ilError;
00055
00056 $this->__checkPear();
00057
00058 $this->settings_obj =& new ilRPCServerSettings();
00059 }
00060
00068 function &send()
00069 {
00070 include_once 'XML/RPC.php';
00071 if(!$response =& $this->rpc_client->send($this->rpc_message))
00072 {
00073 $this->log->write("ilRPCServerAdapter: Communication error");
00074 return null;
00075 }
00076 if($response->faultCode())
00077 {
00078 $this->log->write("ilRPCServerAdapter: Communication error: ". $response->faultString());
00079 return null;
00080 }
00081 return XML_RPC_decode($response->value());
00082 }
00083
00084 function __checkPear()
00085 {
00086 if(!include_once('XML/RPC.php'))
00087 {
00088 $this->log->write('ilLuceneRPCAdapter(): Cannot find pear library XML_RPC. Aborting');
00089 $this->err->raiseError("Cannot find pear package 'XML_RPC'. Aborting ",$this->err->MESSAGE);
00090 }
00091 return true;
00092 }
00093
00101 function __initClient()
00102 {
00103 include_once 'XML/RPC.php';
00104
00105 $this->rpc_client =& new XML_RPC_Client($this->settings_obj->getPath(),
00106 $this->settings_obj->getHost(),
00107 $this->settings_obj->getPort());
00108 #$this->rpc_client->setDebug(1);
00109
00110 return true;
00111 }
00112
00113
00123 function __initMessage($a_message_name,$params)
00124 {
00125 include_once 'XML/RPC.php';
00126
00127 $this->rpc_message =& new XML_RPC_Message($a_message_name,$params);
00128
00129 return true;
00130 }
00131 }
00132 ?>