Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

(no description)

File Size: 1199 lines (49 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes


Class: Server  - X-Ref

Allows effortless implementation of XML-RPC servers

getLogger()   X-Ref
No description

setLogger($logger)   X-Ref
No description

getParser()   X-Ref
No description

setParser($parser)   X-Ref
No description

getCharsetEncoder()   X-Ref
No description

setCharsetEncoder($charsetEncoder)   X-Ref
No description

__construct($dispatchMap = null, $serviceNow = true)   X-Ref

param: array[] $dispatchMap the dispatch map with definition of exposed services
param: boolean $serviceNow set to false to prevent the server from running upon construction

Class: add_to_map  - X-Ref

setDebug($level)   X-Ref
Set debug level of server.

param: integer $level debug lvl: determines info added to xmlrpc responses (as xml comments)

xmlrpc_debugmsg($msg)   X-Ref
Add a string to the debug info that can be later serialized by the server as part of the response message.
Note that for best compatibility, the debug string should be encoded using the PhpXmlRpc::$xmlrpc_internalencoding
character set.

param: string $msg

error_occurred($msg)   X-Ref
Add a string to the debug info that will be later serialized by the server as part of the response message
(base64 encoded, only when debug level >= 2)

character set.
param: string $msg

serializeDebug($charsetEncoding = '')   X-Ref
Return a string with the serialized representation of all debug info.

param: string $charsetEncoding the target charset encoding for the serialization
return: string an XML comment (or two)

service($data = null, $returnPayload = false)   X-Ref
Execute the xmlrpc request, printing the response.

param: string $data the request body. If null, the http POST request will be examined
param: bool $returnPayload When true, return the response but do not echo it or any http header
return: Response|string the response object (usually not used by caller...) or its xml serialization

add_to_map($methodName, $function, $sig = null, $doc = false, $sigDoc = false)   X-Ref
Add a method to the dispatch map.

param: string $methodName the name with which the method will be made available
param: callable $function the php function that will get invoked
param: array[] $sig the array of valid method signatures.
param: string $doc method documentation
param: array[] $sigDoc the array of valid method signatures docs, following the format of $sig but with

verifySignature($in, $sigs)   X-Ref
Verify type and number of parameters received against a list of known signatures.

param: array|Request $in array of either xmlrpc value objects or xmlrpc type definitions
param: array $sigs array of known signatures to match against
return: array int, string

parseRequestHeaders(&$data, &$reqEncoding, &$respEncoding, &$respCompression)   X-Ref
Parse http headers received along with xmlrpc request. If needed, inflate request.

return: Response|null null on success or an error Response

parseRequest($data, $reqEncoding = '')   X-Ref
Parse an xml chunk containing an xmlrpc request and execute the corresponding
php function registered with the server.

param: string $data the xml request
param: string $reqEncoding (optional) the charset encoding of the xml request
return: Response

execute($req, $params = null, $paramTypes = null)   X-Ref
Execute a method invoked by the client, checking parameters used.

param: Request|string $req either a Request obj or a method name
param: mixed[] $params array with method parameters as php types (only if m is method name)
param: string[] $paramTypes array with xmlrpc types of method parameters (only if m is method name)
return: Response

debugmsg($string)   X-Ref
Add a string to the 'internal debug message' (separate from 'user debug message').

param: string $string

xml_header($charsetEncoding = '')   X-Ref

param: string $charsetEncoding
return: string

isSyscall($methName)   X-Ref

param: string $methName
return: bool

getDispatchMap()   X-Ref

return: array[]

getSystemDispatchMap()   X-Ref

return: array[]

getCapabilities()   X-Ref

return: array[]

_xmlrpcs_getCapabilities($server, $req = null)   X-Ref

param: Server $server
param: Request $req
return: Response

_xmlrpcs_listMethods($server, $req = null)   X-Ref

param: Server $server
param: Request $req if called in plain php values mode, second param is missing
return: Response

_xmlrpcs_methodSignature($server, $req)   X-Ref

param: Server $server
param: Request $req
return: Response

_xmlrpcs_methodHelp($server, $req)   X-Ref

param: Server $server
param: Request $req
return: Response

_xmlrpcs_multicall_error($err)   X-Ref
No description

_xmlrpcs_multicall_do_call($server, $call)   X-Ref

param: Server $server
param: Value $call
return: Value

_xmlrpcs_multicall_do_call_phpvals($server, $call)   X-Ref

param: Server $server
param: Value $call
return: Value

_xmlrpcs_multicall($server, $req)   X-Ref

param: Server $server
param: Request|array $req
return: Response

_xmlrpcs_errorHandler($errCode, $errString, $filename = null, $lineNo = null, $context = null)   X-Ref
Error handler used to track errors that occur during server-side execution of PHP code.
This allows to report back to the client whether an internal error has occurred or not
using an xmlrpc response object, instead of letting the client deal with the html junk
that a PHP execution error on the server generally entails.

NB: in fact a user defined error handler can only handle WARNING, NOTICE and USER_* errors.