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",0);
00034
00035 include_once('Services/WebServices/RPC/classes/class.ilRPCServerSettings.php');
00036
00037 class ilRPCServerAdapter
00038 {
00039 var $response_timeout = RPC_TIMEOUT;
00040 var $log = null;
00041 var $db = null;
00042 var $err = null;
00043
00044 var $settings_obj = null;
00045
00046 var $rpc_client = null;
00047 var $rpc_message = null;
00048
00049 function ilRPCServerAdapter()
00050 {
00051 global $ilLog,$ilDB,$ilError;
00052
00053 $this->log =& $ilLog;
00054 $this->db =& $ilDB;
00055 $this->err =& $ilError;
00056
00057 $this->__checkPear();
00058
00059 $this->settings_obj =& new ilRPCServerSettings();
00060 }
00061
00062 function setResponseTimeout($a_response_timeout)
00063 {
00064 $this->response_timeout = $a_response_timeout;
00065 }
00066
00074 function &send()
00075 {
00076 include_once 'XML/RPC.php';
00077 if(!$response =& $this->rpc_client->send($this->rpc_message,$this->response_timeout))
00078 {
00079 $this->log->write("ilRPCServerAdapter: Communication error");
00080 return null;
00081 }
00082 if($response->faultCode())
00083 {
00084 $this->log->write("ilRPCServerAdapter: Communication error: ". $response->faultString());
00085 return null;
00086 }
00087 return XML_RPC_decode($response->value());
00088 }
00089
00090 function __checkPear()
00091 {
00092 if(!include_once('XML/RPC.php'))
00093 {
00094 $this->log->write('ilLuceneRPCAdapter(): Cannot find pear library XML_RPC. Aborting');
00095 $this->err->raiseError("Cannot find pear package 'XML_RPC'. Aborting ",$this->err->MESSAGE);
00096 }
00097 return true;
00098 }
00099
00107 function __initClient()
00108 {
00109 include_once 'XML/RPC.php';
00110
00111 $this->rpc_client =& new XML_RPC_Client($this->settings_obj->getPath(),
00112 $this->settings_obj->getHost(),
00113 $this->settings_obj->getPort());
00114 #$this->rpc_client->setDebug(1);
00115
00116 return true;
00117 }
00118
00119
00129 function __initMessage($a_message_name,$params)
00130 {
00131 include_once 'XML/RPC.php';
00132
00133 $this->rpc_message =& new XML_RPC_Message($a_message_name,$params);
00134
00135
00136
00137 $this->rpc_message->createPayload();
00138
00139 return true;
00140 }
00141 }
00142 ?>