Skip to content

Commit

Permalink
MDL-12886 rewritten xmlrpc client, not finished yet - need to solve e…
Browse files Browse the repository at this point in the history
…rror sending when exception occures outside of the executed method; the test client needs a lot of refactoring too
  • Loading branch information
skodak committed Oct 19, 2009
1 parent de61c75 commit d4e764a
Show file tree
Hide file tree
Showing 9 changed files with 253 additions and 223 deletions.
11 changes: 9 additions & 2 deletions webservice/lib.php
Expand Up @@ -112,10 +112,16 @@ public function run($simple) {
// make a list of all functions user is allowed to excecute
$this->init_service_class();

// TODO: solve debugging level somehow
Zend_XmlRpc_Server_Fault::attachFaultException('moodle_exception');

// start the server
$this->zend_server->setClass($this->service_class);
$response = $this->zend_server->handle();

//$grrr = ob_get_clean();
//error_log($grrr);

// session cleanup
$this->session_cleanup();

Expand Down Expand Up @@ -213,7 +219,6 @@ class '.$classname.' {
';
// load the virtual class definition into memory
eval($code);
echo "<xmp>".$code."</xmp>";
$this->service_class = $classname;
}

Expand Down Expand Up @@ -305,7 +310,7 @@ protected function get_virtual_method_code($function) {
}
$return = ' * @return '.$type.' '.$function->returns_desc->desc;
}

// now crate a virtual method that calls the ext implemenation
// TODO: add PHP docs and all missing info here

Expand Down Expand Up @@ -365,10 +370,12 @@ protected function authenticate_user() {
$this->restricted_context = get_context_instance(CONTEXT_SYSTEM);

if (!is_enabled_auth('webservice')) {
error_log('WS auth not enabled');
die('WS auth not enabled');
}

if (!$auth = get_auth_plugin('webservice')) {
error_log('WS auth missing');
die('WS auth missing');
}

Expand Down
12 changes: 12 additions & 0 deletions webservice/xmlrpc/db/access.php
@@ -0,0 +1,12 @@
<?php

$webservice_xmlrpc_capabilities = array(

'webservice/xmlrpc:use' => array(
'captype' => 'read', // in fact this may be considered read and write at the same time
'contextlevel' => CONTEXT_COURSE, // the context level should be probably CONTEXT_MODULE
'legacy' => array(
),
),

);
116 changes: 0 additions & 116 deletions webservice/xmlrpc/lib.php

This file was deleted.

43 changes: 43 additions & 0 deletions webservice/xmlrpc/locallib.php
@@ -0,0 +1,43 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* XML-RPC web service implementation classes and methods.
*
* @package webservice
* @copyright 2009 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once("$CFG->dirroot/webservice/lib.php");

/**
* XML-RPC service server implementation.
* @author Petr Skoda (skodak)
*/
class webservice_xmlrpc_server extends webservice_zend_server {
/**
* Contructor
*/
public function __construct() {
parent::__construct('Zend_XmlRpc_Server');
$this->wsname = 'xmlrpc';
}


}

62 changes: 27 additions & 35 deletions webservice/xmlrpc/server.php
@@ -1,46 +1,38 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Moodle - Modular Object-Oriented Dynamic Learning Environment
* http://moodle.com
*
* LICENSE
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* http://www.gnu.org/copyleft/gpl.html
* XML-RPC web service entry point. The authentication is done via tokens.
*
* @category Moodle
* @package webservice
* @copyright Copyright (c) 1999 onwards Martin Dougiamas http://dougiamas.com
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL License
*/
/**
* Main script - XML-RPC server
*
* @author Jerome Mouneyrac <jerome@moodle.com>
* @version 1.0
* @package webservices
* @copyright 2009 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

/*
* Zend XML-RPC server
*/
require_once(dirname(__FILE__) . '/../../config.php');
require_once('lib.php');
define('NO_MOODLE_COOKIES', true);

require('../../config.php');
require_once("$CFG->dirroot/webservice/xmlrpc/locallib.php");

if (empty($CFG->enablewebservices)) {
if (!webservice_protocol_is_enabled('xmlrpc')) {
die;
}

$server = new xmlrpc_server();
$server->run();
$server = new webservice_xmlrpc_server();
$server->run(false);
die;

?>
50 changes: 50 additions & 0 deletions webservice/xmlrpc/simpleserver.php
@@ -0,0 +1,50 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* XML-RPC web service entry point. The authentication is done via tokens.
*
* @package webservice
* @copyright 2009 Moodle Pty Ltd (http://moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

define('NO_MOODLE_COOKIES', true);

require('../../config.php');
require_once("$CFG->dirroot/webservice/xmlrpc/locallib.php");

//ob_start();

//TODO: for now disable all mess in xml
ini_set('display_errors', '0');
ini_set('log_errors', '1');
$CFG->debug = 0;
$CFG->debugdisplay = false;

//error_log('yy');
//error_log(var_export($_SERVER, true));

if (!webservice_protocol_is_enabled('xmlrpc')) {
die;
}

$server = new webservice_xmlrpc_server();
$server->run(true);
die;


0 comments on commit d4e764a

Please sign in to comment.