*/
public $__encoding = "iso-8859-1";
+ /**
+ * RPC options
+ *
+ * @var array
+ */
+ public $__options;
+
/**
* Constructor
*
* @param string $namespace RPC namespace
* @param array $options HttpRequest options
*/
- public function __construct($url, $namespace = '', array $options = array())
+ public function __construct($url, $namespace = '', array $options = null)
{
- $this->__request = new HttpRequest($url, HttpRequest::METH_POST, $options);
+ $this->__request = new HttpRequest($url, HttpRequest::METH_POST, (array) $options);
$this->__namespace = $namespace;
}
$this->__request->setContentType("text/xml");
$this->__request->setRawPostData(
xmlrpc_encode_request($method, $params,
- array("encoding" => $this->__encoding)));
+ array("encoding" => $this->__encoding) + (array) $this->__options));
$response = $this->__request->send();
if ($response->getResponseCode() != 200) {
throw new Exception(
*
* @param string $method
* @param array $params
- * @param array $options
+ * @param array $request_options
+ * @param array $response_options
*/
- public static function test($method, array $params, array $options = null)
+ public static function test($method, array $params, array $request_options = null, array $response_options = null)
{
- self::$xmlreq = xmlrpc_encode_request($method, $params);
- self::run();
+ self::$xmlreq = xmlrpc_encode_request($method, $params, $request_options);
+ self::run($response_options);
}
/**
* @param int $code
* @param string $msg
*/
- public static function error($code, $msg)
+ public static function error($code, $msg, array $options = null)
{
- echo xmlrpc_encode(array("faultCode" => $code, "faultString" => $msg));
+ echo xmlrpc_encode(array("faultCode" => $code, "faultString" => $msg),
+ array("encoding" => self::$encoding) + (array) $options);
}
/**