Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

XML-RPC web service implementation classes and methods.

Copyright: 2009 Petr Skodak
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 230 lines (8 kb)
Included or required:0 times
Referenced: 2 times
Includes or requires: 0 files

Defines 2 classes

webservice_xmlrpc_server:: (8 methods):
  __construct()
  parse_request()
  fetch_input_content()
  prepare_response()
  send_response()
  send_error()
  send_headers()
  generate_error()

webservice_xmlrpc_test_client:: (1 method):
  simpletest()


Class: webservice_xmlrpc_server  - X-Ref

XML-RPC service server implementation.

__construct($authmethod)   X-Ref
Contructor

param: string $authmethod authentication method of the web service (WEBSERVICE_AUTHMETHOD_PERMANENT_TOKEN, ...)

parse_request()   X-Ref
This method parses the request input, it needs to get:
1/ user authentication - username+password or token
2/ function name
3/ function parameters


fetch_input_content()   X-Ref
Fetch content from the client.

return: string

prepare_response()   X-Ref
Prepares the response.


send_response()   X-Ref
Send the result of function call to the WS client.


send_error($ex = null)   X-Ref
Send the error information to the WS client.

param: Exception $ex

send_headers()   X-Ref
Sends the headers for the XML-RPC response.


generate_error($ex, $faultcode = 404)   X-Ref
Generate the XML-RPC fault response.

param: Exception|Throwable $ex The exception.
param: int $faultcode The faultCode to be included in the fault response
return: string The XML-RPC fault response xml containing the faultCode and faultString.

Class: webservice_xmlrpc_test_client  - X-Ref

XML-RPC test client class

simpletest($serverurl, $function, $params)   X-Ref
Execute test client WS request

param: string $serverurl server url (including token parameter or username/password parameters)
param: string $function function name
param: array $params parameters of the called function
return: mixed