ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilRPCServerAdapter.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +-----------------------------------------------------------------------------+
22*/
23
24
33define("RPC_TIMEOUT",0);
34
35include_once('Services/WebServices/RPC/classes/class.ilRPCServerSettings.php');
36
38{
40 var $log = null;
41 var $db = null;
42 var $err = null;
43
44 var $settings_obj = null;
45
46 var $rpc_client = null;
47 var $rpc_message = null;
48
50 {
51 global $ilLog,$ilDB,$ilErr;
52
53 $this->log =& $ilLog;
54 $this->db =& $ilDB;
55 $this->err =& $ilErr;
56
57 $this->__checkPear();
58
59 $this->settings_obj = ilRPCServerSettings::getInstance();
60 }
61
62 function setResponseTimeout($a_response_timeout)
63 {
64 $this->response_timeout = $a_response_timeout;
65 }
66
74 function &send()
75 {
76 include_once 'XML/RPC.php';
77 if(!$response =& $this->rpc_client->send($this->rpc_message,$this->response_timeout))
78 {
79 $this->log->write("ilRPCServerAdapter: Communication error");
80 return null;
81 }
82 if($response->faultCode())
83 {
84 $this->log->write("ilRPCServerAdapter: Communication error: ". $response->faultString());
85 return null;
86 }
87 return XML_RPC_decode($response->value());
88 }
89 // PRIVATE
90 function __checkPear()
91 {
92 if(!include_once('XML/RPC.php'))
93 {
94 $this->log->write('ilLuceneRPCAdapter(): Cannot find pear library XML_RPC. Aborting');
95 $this->err->raiseError("Cannot find pear package 'XML_RPC'. Aborting ",$this->err->MESSAGE);
96 }
97 return true;
98 }
99
107 function __initClient()
108 {
109 include_once 'XML/RPC.php';
110
111 $this->rpc_client =& new XML_RPC_Client($this->settings_obj->getPath(),
112 $this->settings_obj->getHost(),
113 $this->settings_obj->getPort());
114 #$this->rpc_client->setDebug(1);
115
116 return true;
117 }
118
119
129 function __initMessage($a_message_name,$params)
130 {
131 include_once 'XML/RPC.php';
132
133 $this->rpc_message =& new XML_RPC_Message($a_message_name,$params);
134
135 // We create the payload here since it might be quite time consuming
136 // and this could cause a socket read exception on the server side.
137 $this->rpc_message->createPayload();
138
139 return true;
140 }
141}
142?>
const RPC_TIMEOUT
__initClient()
Create RPC client object.
__initMessage($a_message_name, $params)
Create RPC message object.
setResponseTimeout($a_response_timeout)
& send()
Send message to remote rpc server and get response.
static getInstance()
Get singelton instance.
$params
Definition: example_049.php:96
global $ilDB