当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_XmlRpc_Value::getValue方法代码示例

本文整理汇总了PHP中Zend_XmlRpc_Value::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_XmlRpc_Value::getValue方法的具体用法?PHP Zend_XmlRpc_Value::getValue怎么用?PHP Zend_XmlRpc_Value::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_XmlRpc_Value的用法示例。


在下文中一共展示了Zend_XmlRpc_Value::getValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _parseResponse

 /**
  * Parse the response from a XML-RPC method call, hold the response as a Zend_XmlRpc_Value object
  * The response parameter must be a valid XML string
  *
  * @param string $response XML string to parse
  */
 protected function _parseResponse($response)
 {
     if (!$response) {
         // The response is empty
         throw new Zend_XmlRpc_Client_Exception('Received empty response');
     }
     // Using simple XML to parse the response
     try {
         $simple_xml = @new SimpleXMLElement($response);
     } catch (Exception $e) {
         // The response is not a valid XML
         throw new Zend_XmlRpc_Client_Exception('Failed to parse response: ' . $e->getMessage(), $e->getCode());
     }
     // We check if this is a Fault response
     if (!empty($simple_xml->fault)) {
         // The fault tag exists and not empty, the request failed and returned a fault response
         if (empty($simple_xml->fault->value)) {
             // Invalid fault response, fault tag must contain a value tag
             throw new Zend_XmlRpc_Client_Exception('Invalid fault response, FAULT tag must contain a VALUE tag');
         }
         // Parse the fault response into a Zend_XmlRpc_Value object
         try {
             $this->_response = Zend_XmlRpc_Value::getXmlRpcValue($simple_xml->fault->value, Zend_XmlRpc_Value::XML_STRING);
         } catch (Zend_XmlRpc_Value_Exception $e) {
             // Failed to create a Zend_XmlRpc_Value object from the fault
             throw new Zend_XmlRpc_Client_Exception('Invalid fault response, ' . $e->getMessage());
         }
         $fault = $this->_response->getValue();
         throw new Zend_XmlRpc_Client_Exception('Request failed, ' . $fault['faultString'], $fault['faultCode']);
     } elseif (empty($simple_xml->params)) {
         // Invalid response, no params tag
         throw new Zend_XmlRpc_Client_Exception('Invalid response, method response must contain a PARAMS tag');
     } elseif (empty($simple_xml->params->param)) {
         // Invalid response, params tag must contain a param tag
         throw new Zend_XmlRpc_Client_Exception('Invalid response, PARAMS tag must contain a PARAM tag');
     } elseif (empty($simple_xml->params->param->value)) {
         // Invalid response, param tag must contain a value tag
         throw new Zend_XmlRpc_Client_Exception('Invalid response, PARAM tag must contain a VALUE tag');
     }
     // Parse the success response into a Zend_XmlRpc_Value object
     $this->_response = Zend_XmlRpc_Value::getXmlRpcValue($simple_xml->params->param->value, Zend_XmlRpc_Value::XML_STRING);
     return $this->__getResponse(self::RESPONSE_PHP_NATIVE);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:49,代码来源:Client.php


注:本文中的Zend_XmlRpc_Value::getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。