}
if (is_array($req)) {
- // $msg is an array of Requests
+ // $req is an array of Requests
$r = $this->multicall($req, $timeout, $method);
return $r;
* Requires curl to be built into PHP
* NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers!
*
- * @param Request $msg
+ * @param Request $req
* @param string $server
* @param int $port
* @param int $timeout
* @param int $sslVersion
* @return Response
*/
- protected function sendPayloadCURL($msg, $server, $port, $timeout = 0, $username = '',
+ protected function sendPayloadCURL($req, $server, $port, $timeout = 0, $username = '',
$password = '', $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '',
$proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method = 'https',
$keepAlive = false, $key = '', $keyPass = '', $sslVersion = 0)
}
// Only create the payload if it was not created previously
- if (empty($msg->payload)) {
- $msg->createPayload($this->request_charset_encoding);
+ if (empty($req->payload)) {
+ $req->createPayload($this->request_charset_encoding);
}
// Deflate request body and set appropriate request headers
- $payload = $msg->payload;
+ $payload = $req->payload;
if (function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) {
if ($this->request_compression == 'gzip') {
$a = @gzencode($payload);
}
}
// extra headers
- $headers = array('Content-Type: ' . $msg->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
+ $headers = array('Content-Type: ' . $req->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
// if no keepalive is wanted, let the server know it in advance
if (!$keepAlive) {
$headers[] = 'Connection: close';
if (!$keepAlive) {
curl_close($curl);
}
- $resp = $msg->parseResponse($result, true, $this->return_type);
+ $resp = $req->parseResponse($result, true, $this->return_type);
// if we got back a 302, we can not reuse the curl handle for later calls
if ($resp->faultCode() == PhpXmlRpc::$xmlrpcerr['http_error'] && $keepAlive) {
curl_close($curl);
*/
protected $dmap = array();
/**
- * Defines how functions in dmap will be invoked: either using an xmlrpc msg object
+ * Defines how functions in dmap will be invoked: either using an xmlrpc request object
* or plain php values.
- * valid strings are 'xmlrpcvals', 'phpvals' or 'epivals'
+ * Valid strings are 'xmlrpcvals', 'phpvals' or 'epivals'
*/
public $functions_parameters_type = 'xmlrpcvals';
/**
* Option used for fine-tuning the encoding the php values returned from
* functions registered in the dispatch map when the functions_parameters_types
* member is set to 'phpvals'
- * @see php_xmlrpc_encode for a list of values
+ * @see Encoder::encode for a list of values
*/
public $phpvals_encoding_options = array('auto_dates');
/**
*/
public $debug = 1;
/**
- * Controls behaviour of server when invoked user function throws an exception:
+ * Controls behaviour of server when the invoked user function throws an exception:
* 0 = catch it and return an 'internal error' xmlrpc response (default)
* 1 = catch it and return an xmlrpc response with the error corresponding to the exception
* 2 = allow the exception to float to the upper layers
/**
* When set to true, it will enable HTTP compression of the response, in case
* the client has declared its support for compression in the request.
+ * Set at constructor time.
*/
public $compress_response = false;
/**
- * List of http compression methods accepted by the server for requests.
+ * List of http compression methods accepted by the server for requests. Set at constructor time.
* NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib
*/
public $accepted_compression = array();
/// shall we serve calls to system.* methods?
public $allow_system_funcs = true;
- /// list of charset encodings natively accepted for requests
+ /**
+ * List of charset encodings natively accepted for requests.
+ * Set at constructor time.
+ */
public $accepted_charset_encodings = array();
/**
* charset encoding to be used for response.
/**
* @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
+ * @param boolean $serviceNow set to false to prevent the server from running upon construction
*/
public function __construct($dispatchMap = null, $serviceNow = true)
{
// by default the xml parser can support these 3 charset encodings
$this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII');
- // dispMap is a dispatch array of methods
- // mapped to function names and signatures
- // if a method
- // doesn't appear in the map then an unknown
- // method error is generated
+ // dispMap is a dispatch array of methods mapped to function names and signatures.
+ // If a method doesn't appear in the map then an unknown method error is generated
/* milosch - changed to make passing dispMap optional.
- * instead, you can use the class add_to_map() function
- * to add functions manually (borrowed from SOAPX4)
- */
+ * instead, you can use the class add_to_map() function
+ * to add functions manually (borrowed from SOAPX4)
+ */
if ($dispatchMap) {
$this->dmap = $dispatchMap;
if ($serviceNow) {
/**
* Verify type and number of parameters received against a list of known signatures.
*
- * @param array $in array of either xmlrpc value objects or xmlrpc type definitions
- * @param array $sig array of known signatures to match against
+ * @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
*/
- protected function verifySignature($in, $sig)
+ protected function verifySignature($in, $sigs)
{
// check each possible signature in turn
if (is_object($in)) {
} else {
$numParams = count($in);
}
- foreach ($sig as $cursig) {
- if (count($cursig) == $numParams + 1) {
+ foreach ($sigs as $curSig) {
+ if (count($curSig) == $numParams + 1) {
$itsOK = 1;
for ($n = 0; $n < $numParams; $n++) {
if (is_object($in)) {
}
// param index is $n+1, as first member of sig is return type
- if ($pt != $cursig[$n + 1] && $cursig[$n + 1] != Value::$xmlrpcValue) {
+ if ($pt != $curSig[$n + 1] && $curSig[$n + 1] != Value::$xmlrpcValue) {
$itsOK = 0;
$pno = $n + 1;
- $wanted = $cursig[$n + 1];
+ $wanted = $curSig[$n + 1];
$got = $pt;
break;
}
if (isset($dmap[$methName]['signature'])) {
$sigs = array();
foreach ($dmap[$methName]['signature'] as $inSig) {
- $cursig = array();
+ $curSig = array();
foreach ($inSig as $sig) {
- $cursig[] = new Value($sig, 'string');
+ $curSig[] = new Value($sig, 'string');
}
- $sigs[] = new Value($cursig, 'array');
+ $sigs[] = new Value($curSig, 'array');
}
$r = new Response(new Value($sigs, 'array'));
} else {
}
$numParams = $params->arraysize();
- $msg = new Request($methName->scalarval());
+ $req = new Request($methName->scalarval());
for ($i = 0; $i < $numParams; $i++) {
- if (!$msg->addParam($params->arraymem($i))) {
+ if (!$req->addParam($params->arraymem($i))) {
$i++;
return static::_xmlrpcs_multicall_error(new Response(0,
}
}
- $result = $server->execute($msg);
+ $result = $server->execute($req);
if ($result->faultCode() != 0) {
return static::_xmlrpcs_multicall_error($result); // Method returned fault.
}
$debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0;
- $msgClass = $namespace . 'Request';
+ $reqClass = $namespace . 'Request';
$valClass = $namespace . 'Value';
$decoderClass = $namespace . 'Encoder';
- $msg = new $msgClass('system.methodSignature');
- $msg->addparam(new $valClass($methodName));
+ $req = new $reqClass('system.methodSignature');
+ $req->addparam(new $valClass($methodName));
$client->setDebug($debug);
- $response = $client->send($msg, $timeout, $protocol);
+ $response = $client->send($req, $timeout, $protocol);
if ($response->faultCode()) {
error_log('XML-RPC: could not retrieve method signature from remote server for method ' . $methodName);
// if in 'offline' mode, get method description too.
// in online mode, favour speed of operation
if (!$buildIt) {
- $msg = new $msgClass('system.methodHelp');
- $msg->addparam(new $valClass($methodName));
- $response = $client->send($msg, $timeout, $protocol);
+ $req = new $reqClass('system.methodHelp');
+ $req->addparam(new $valClass($methodName));
+ $response = $client->send($req, $timeout, $protocol);
if (!$response->faultCode()) {
$mDesc = $response->value();
if ($client->return_type != 'phpvals') {
$prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc';
$namespace = '\\PhpXmlRpc\\';
- $msgClass = $namespace . 'Request';
+ $reqClass = $namespace . 'Request';
//$valClass = $prefix.'val';
$decoderClass = $namespace . 'Encoder';
- $msg = new $msgClass('system.listMethods');
- $response = $client->send($msg, $timeout, $protocol);
+ $req = new $reqClass('system.listMethods');
+ $response = $client->send($req, $timeout, $protocol);
if ($response->faultCode()) {
error_log('XML-RPC: could not retrieve method list from remote server');