Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/webservice/xmlrpc/locallib.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00026 require_once("$CFG->dirroot/webservice/lib.php");
00027 require_once 'Zend/XmlRpc/Server.php';
00028 
00032 class moodle_zend_xmlrpc_server extends Zend_XmlRpc_Server {
00033 
00044     public function fault($fault = null, $code = 404)
00045     {
00046         //intercept any exceptions with debug info and transform it in Moodle exception
00047         if ($fault instanceof Exception) {
00048             //add the debuginfo to the exception message if debuginfo must be returned
00049             if (debugging() and isset($fault->debuginfo)) {
00050                 $fault = new Exception($fault->getMessage() . ' | DEBUG INFO: ' . $fault->debuginfo, 0);
00051             }
00052         }
00053 
00054         return parent::fault($fault, $code);
00055     }
00056 }
00057 
00062 class webservice_xmlrpc_server extends webservice_zend_server {
00067     public function __construct($authmethod) {
00068         require_once 'Zend/XmlRpc/Server.php';
00069         parent::__construct($authmethod, 'moodle_zend_xmlrpc_server');
00070         $this->wsname = 'xmlrpc';
00071     }
00072 
00077     protected function init_zend_server() {
00078         parent::init_zend_server();
00079         // this exception indicates request failed
00080         Zend_XmlRpc_Server_Fault::attachFaultException('moodle_exception');
00081         //when DEBUG >= NORMAL then the thrown exceptions are "casted" into a plain PHP Exception class
00082         //in order to display the $debuginfo (see moodle_zend_xmlrpc_server class - MDL-29435)
00083         if (debugging()) {
00084             Zend_XmlRpc_Server_Fault::attachFaultException('Exception');
00085         }
00086     }
00087 
00088 }
00089 
00093 class webservice_xmlrpc_test_client implements webservice_test_client_interface {
00101     public function simpletest($serverurl, $function, $params) {
00102         //zend expects 0 based array with numeric indexes
00103         $params = array_values($params);
00104 
00105         require_once 'Zend/XmlRpc/Client.php';
00106         $client = new Zend_XmlRpc_Client($serverurl);
00107         return $client->call($function, $params);
00108     }
00109 }
 All Data Structures Namespaces Files Functions Variables Enumerations