JSONRPC 1.0.0

Server extends Server
in package
uses EncoderAware, SerializerAware

Tags
todo

implement dispatching of multicall requests, json way

todo

test system.XXX methods, with special care to multicall

todo

support 'notification' calls, i.e. if id is null, echo back nothing

todo

should we override all parent's methods related to multicall which do not work for us?

Table of Contents

Constants

OPT_DEBUG_FORMAT  = 'debug_format'

Properties

$debug  : mixed
$debug_format  : string
$encoder  : mixed
$functions_parameters_type  : mixed
$is_servicing_multicall  : null|false|array<string|int, mixed>
$is_servicing_notification  : null|bool
$phpvals_encoding_options  : array<string|int, mixed>
$responseClass  : mixed
$serializer  : mixed

Methods

getCapabilities()  : array<string|int, array<string|int, mixed>>
getCharsetEncoder()  : Charset
Reimplemented to make us use the correct parser type.
getEncoder()  : mixed
getOption()  : mixed
getParser()  : Parser
Reimplemented to make us use the correct parser type.
getSerializer()  : mixed
methodNameCallback()  : void
parseRequestHeaders()  : Response|null
Parse http headers received along with the json-rpc request. If needed, inflate request.
serializeDebug()  : mixed
service()  : Response|string
Execute the json-rpc request, printing the response.
setEncoder()  : mixed
setOption()  : mixed
setSerializer()  : mixed
execute()  : Response
Note: syntax differs from overridden method, by adding msgID and jsonrpcVersion args.
fixErrorCodeIfNeeded()  : void
generatePayload()  : string
injectDebugInfo()  : string
isSyscall()  : bool
printPayload()  : void
xml_header()  : string
No xml header generated by the server, since we are sending json.

Constants

OPT_DEBUG_FORMAT

public mixed OPT_DEBUG_FORMAT = 'debug_format'

Properties

$debug

protected mixed $debug = 0

$debug_format

protected string $debug_format = 'json5'

either 'json5' or 'extra_member'

$functions_parameters_type

protected mixed $functions_parameters_type = \PhpXmlRpc\JsonRpc\Helper\Parser::RETURN_JSONRPCVALS

$is_servicing_multicall

protected null|false|array<string|int, mixed> $is_servicing_multicall = null

$is_servicing_notification

protected null|bool $is_servicing_notification = null

This is required as checking for NULL resp. Id is not sufficient - it can happen in error cases

$phpvals_encoding_options

protected array<string|int, mixed> $phpvals_encoding_options = array()

Option used for fine-tuning the encoding the php values returned from functions registered in the dispatch map when the functions_parameters_type member is set to 'phpvals'.

Tags
see
Encoder::encode

for a list of values

$responseClass

protected static mixed $responseClass = '\PhpXmlRpc\JsonRpc\Response'

Methods

getCapabilities()

public getCapabilities() : array<string|int, array<string|int, mixed>>
Tags
todo

if building json-rpc-only webservers, you should at least undeclare the xml-rpc capability: unset($outAr['xmlrpc']);

Return values
array<string|int, array<string|int, mixed>>

getCharsetEncoder()

Reimplemented to make us use the correct parser type.

public getCharsetEncoder() : Charset
Return values
Charset

getOption()

public getOption(mixed $name) : mixed
Parameters
$name : mixed

getParser()

Reimplemented to make us use the correct parser type.

public getParser() : Parser
Return values
Parser

methodNameCallback()

public methodNameCallback(string $methodName, Parser $xmlParser[, null $parser = null ]) : void
Parameters
$methodName : string
$xmlParser : Parser
$parser : null = null
Tags
throws
NoSuchMethodException

parseRequestHeaders()

Parse http headers received along with the json-rpc request. If needed, inflate request.

public parseRequestHeaders(mixed &$data, mixed &$reqEncoding, mixed &$respEncoding, mixed &$respCompression) : Response|null
Parameters
$data : mixed
$reqEncoding : mixed
$respEncoding : mixed
$respCompression : mixed
Return values
Response|null

null on success or an error Response

serializeDebug()

public serializeDebug([mixed $charsetEncoding = '' ][, mixed $format = 'comment' ]) : mixed
Parameters
$charsetEncoding : mixed = ''
$format : mixed = 'comment'
Tags
string

$charsetEncoding

string

$format either 'comment' (will generate js comments) or 'string' (will generate a js string)

todo

allow to (optionally) send comments as top-level json element, since 99.99% of json parsers will barf on js comments...

service()

Execute the json-rpc request, printing the response.

public service([string $data = null ][, bool $returnPayload = false ]) : Response|string
Parameters
$data : string = null

the request body. If null, the http POST request will be examined

$returnPayload : bool = false

When true, return the response but do not echo it or any http header

Tags
throws
Exception

in case the executed method does throw an exception (and depending on server configuration)

Return values
Response|string

the response object (usually not used by caller...) or its json serialization

setEncoder()

public static setEncoder(mixed $encoder) : mixed
Parameters
$encoder : mixed

setOption()

public setOption(mixed $name, mixed $value) : mixed
Parameters
$name : mixed
$value : mixed

setSerializer()

public static setSerializer(mixed $serializer) : mixed
Parameters
$serializer : mixed

execute()

Note: syntax differs from overridden method, by adding msgID and jsonrpcVersion args.

protected execute(Request|string $req[, null|array<string|int, mixed> $params = null ][, null|array<string|int, string> $paramTypes = null ][, mixed $msgID = null ][, null|string $jsonrpcVersion = null ]) : Response
Parameters
$req : Request|string

either a Request obj or a method name

$params : null|array<string|int, mixed> = null

unlike the parent class, the array can have non-numeric keys

$paramTypes : null|array<string|int, string> = null

array with xml-rpc types of method parameters (only if $req is method name)

$msgID : mixed = null

to be used when $req is a string, or when it is an xml-rpc request instead of a json-rpc one

$jsonrpcVersion : null|string = null

when not set, the version from $req is used (if set), or the default one from PhpJsonRpc

Tags
throws
Exception
Return values
Response

generatePayload()

protected generatePayload(Response $resp, string $respCharset) : string
Parameters
$resp : Response
$respCharset : string
Return values
string

injectDebugInfo()

protected injectDebugInfo(string $payload, string $respCharset) : string
Parameters
$payload : string
$respCharset : string
Return values
string

isSyscall()

protected isSyscall(string $methName) : bool
Parameters
$methName : string
Return values
bool

printPayload()

protected printPayload(string $payload, string $respContentType, string $respEncoding) : void
Parameters
$payload : string
$respContentType : string
$respEncoding : string

xml_header()

No xml header generated by the server, since we are sending json.

protected xml_header([string $charsetEncoding = '' ]) : string

this method was moved to the Response class

Parameters
$charsetEncoding : string = ''
Return values
string

        
On this page

Search results