private function parseResponse($xmlString) { try { $xml = new SimpleXMLElement($xmlString); } catch (Exception $e) { throw new SXmlRpcClientException('Failed to parse response'); } if (!empty($xml->fault)) { if (empty($xml->fault->value)) { throw new SXmlRpcClientException('Invalid fault response : no <value> tag'); } try { $fault = SXmlRpcValue::typecast($xml->fault->value->asXML()); } catch (SXmlRpcValueException $e) { throw new SXmlRpcClientException('Invalid fault response'); } throw new SXmlRpcClientException('Request failed, ' . $fault['faultCode'] . ': ' . $fault['faultString']); } elseif (empty($xml->params)) { throw new SXmlRpcClientException('Invalid fault response : no <params> tag'); } elseif (empty($xml->params->param)) { throw new SXmlRpcClientException('Invalid fault response : no <param> tag'); } elseif (empty($xml->params->param->value)) { throw new SXmlRpcClientException('Invalid fault response : no <value> tag'); } return SXmlRpcValue::typecast($xml->params->param->value->asXML()); }
public function parseRequest($xmlString) { try { $xml = new SimpleXMLElement($xmlString); } catch (Exception $e) { throw new SXmlRpcServerException('Failed to parse request'); } if (empty($xml->methodName)) { throw new SXmlRpcServerException('No method name provided'); } $method = $xml->methodName; $params = array(); if (!empty($xml->params)) { foreach ($xml->params->param as $param) { if (!$param instanceof SimpleXMLElement) { throw new SXmlRpcServerException('Invalid request parameter'); } if (empty($param->value)) { throw new SXmlRpcServerException('Invalid request parameter : no <value> tag'); } $params[] = SXmlRpcValue::typecast($param->value->asXML()); } } return array($method, $params); }