Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.

Differences Between: [Versions 401 and 403]

(no description)

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

Defines 1 class


Class: Server  - X-Ref

Allows effortless implementation of XML-RPC servers

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

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

setOption($name, $value)   X-Ref

param: string $name see all the OPT_ constants
param: mixed $value
return: $this

getOption($name)   X-Ref

param: string $name see all the OPT_ constants
return: mixed

getOptions()   X-Ref
Returns the complete list of Server options.

return: array

setOptions($options)   X-Ref

param: array $options key:  see all the OPT_ constants
return: $this

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

param: integer $level debug lvl: determines info added to xml-rpc responses (as xml comments)
return: $this

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
return: void

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) when debug level >= 2

param: string $msg
return: void

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 xml-rpc 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

addToMap($methodName, $function, $sig = null, $doc = false, $sigDoc = false, $parametersType = false,$exceptionHandling = 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
param: string $parametersType to allow single method handlers to receive php values instead of a Request, or vice-versa
param: int $exceptionHandling @see $this->exception_handling
return: void

add_to_map($methodName, $function, $sig = null, $doc = false, $sigDoc = false, $parametersType = false,$exceptionHandling = 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
param: string $parametersType to allow single method handlers to receive php values instead of a Request, or vice-versa
param: int $exceptionHandling @see $this->exception_handling
return: void

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 xml-rpc value objects or xml-rpc 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 xml-rpc 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 xml-rpc 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 $req is method name)
param: string[] $paramTypes array with xml-rpc types of method parameters (only if $req is method name)
return: Response

methodNameCallback($methodName, $xmlParser, $parser)   X-Ref
Registered as callback for when the XMLParser has found the name of the method to execute.
Handling that early allows to 1. stop parsing the rest of the xml if there is no such method registered, and
2. tweak the type of data that the parser will return, in case the server uses mixed-calling-convention

param: $methodName
param: XMLParser $xmlParser
param: resource $parser
return: void

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

param: string $string
return: void

isSyscall($methName)   X-Ref

param: string $methName
return: bool

setDispatchMap($dmap)   X-Ref

param: array $dmap
return: $this

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

param: $err
return: Value

_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 xml-rpc 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.


xml_header($charsetEncoding = '')   X-Ref

param: string $charsetEncoding
return: string

__get($name)   X-Ref
No description

__set($name, $value)   X-Ref
No description

__isset($name)   X-Ref
No description

__unset($name)   X-Ref
No description