/** * Send an XML-RPC request to the service (for a specific method) * * @param string $method Name of the method we want to call * @param array $params Array of parameters for the method * @return mixed * @throws Zend\XmlRpc\Client\FaultException */ public function call($method, $params = array()) { if (!$this->skipSystemLookup() && 'system.' != substr($method, 0, 7)) { // Ensure empty array/struct params are cast correctly // If system.* methods are not available, bypass. (ZF-2978) $success = true; try { $signatures = $this->getIntrospector()->getMethodSignature($method); } catch (\Zend\XmlRpc\Exception\ExceptionInterface $e) { $success = false; } if ($success) { $validTypes = array(AbstractValue::XMLRPC_TYPE_ARRAY, AbstractValue::XMLRPC_TYPE_BASE64, AbstractValue::XMLRPC_TYPE_BOOLEAN, AbstractValue::XMLRPC_TYPE_DATETIME, AbstractValue::XMLRPC_TYPE_DOUBLE, AbstractValue::XMLRPC_TYPE_I4, AbstractValue::XMLRPC_TYPE_INTEGER, AbstractValue::XMLRPC_TYPE_NIL, AbstractValue::XMLRPC_TYPE_STRING, AbstractValue::XMLRPC_TYPE_STRUCT); if (!is_array($params)) { $params = array($params); } foreach ($params as $key => $param) { if ($param instanceof AbstractValue) { continue; } if (count($signatures) > 1) { $type = AbstractValue::getXmlRpcTypeByValue($param); foreach ($signatures as $signature) { if (!is_array($signature)) { continue; } if (isset($signature['parameters'][$key])) { if ($signature['parameters'][$key] == $type) { break; } } } } elseif (isset($signatures[0]['parameters'][$key])) { $type = $signatures[0]['parameters'][$key]; } else { $type = null; } if (empty($type) || !in_array($type, $validTypes)) { $type = AbstractValue::AUTO_DETECT_TYPE; } $params[$key] = AbstractValue::getXmlRpcValue($param, $type); } } } $request = $this->_createRequest($method, $params); $this->doRequest($request); if ($this->_lastResponse->isFault()) { $fault = $this->_lastResponse->getFault(); /** * Exception thrown when an XML-RPC fault is returned */ throw new Client\Exception\FaultException($fault->getMessage(), $fault->getCode()); } return $this->_lastResponse->getReturnValue(); }