當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_XmlRpc_Response類代碼示例

本文整理匯總了PHP中Zend_XmlRpc_Response的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_XmlRpc_Response類的具體用法?PHP Zend_XmlRpc_Response怎麽用?PHP Zend_XmlRpc_Response使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Zend_XmlRpc_Response類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parse

 /**
  * {@inheritdoc}
  */
 public function parse($xmlString)
 {
     $response = new \Zend_XmlRpc_Response();
     try {
         $response->loadXml($xmlString);
     } catch (\Exception $e) {
         throw new ParserException($e->getMessage(), $e->getCode(), $e);
     }
     if ($response->isFault()) {
         $fault = $response->getFault();
         throw new FaultException($fault->getMessage(), $fault->getCode());
     }
     $result = $response->getReturnValue();
     $toBeVisited = [&$result];
     while (isset($toBeVisited[0]) && ($value =& $toBeVisited[0])) {
         $type = gettype($value);
         if ($type === 'array') {
             foreach ($value as &$element) {
                 $toBeVisited[] =& $element;
             }
             reset($value);
             // Reset all array pointers
         }
         array_shift($toBeVisited);
     }
     return $result;
 }
開發者ID:fxmlrpc,項目名稱:serialization,代碼行數:30,代碼來源:Zend1Parser.php

示例2: getServerResponseFor

 public function getServerResponseFor($nativeVars)
 {
     $response = new Zend_XmlRpc_Response();
     $response->setReturnValue($nativeVars);
     $xml = $response->saveXml();
     $response = $this->makeHttpResponseFrom($xml);
     return $response;
 }
開發者ID:SustainableCoastlines,項目名稱:loveyourwater,代碼行數:8,代碼來源:ClientTest.php

示例3: __toString

 /**
  * Override __toString() to send HTTP Content-Type header
  *
  * @return string
  */
 public function __toString()
 {
     if (!headers_sent()) {
         header('Content-Type: text/xml; charset=' . strtolower($this->getEncoding()));
     }
     return parent::__toString();
 }
開發者ID:fredcido,項目名稱:cenbrap,代碼行數:12,代碼來源:Http.php

示例4: call

 /**
  * 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
  * @throws Zend_Http_Client_FaultException
  */
 public function call($method, $params = array())
 {
     //        if ('system.' != substr($method, 0, 7)) {
     //
     //            // Ensure empty array/struct params are cast correctly
     //
     //            $signatures = $this->getIntrospector()->getMethodSignature($method);
     //            foreach ($params as $key => $param) {
     //                if (is_array($param) && empty($param)) {
     //                    $type = 'array';
     //                    foreach ($signatures as $signature) {
     //                        if (!is_array($signature)) {
     //                            continue;
     //                        }
     //                        if (array_key_exists($key + 1, $signature)) {
     //                            $type = $signature[$key + 1];
     //                            $type = (in_array($type, array('array', 'struct'))) ? $type : 'array';
     //                            break;
     //                        }
     //                    }
     //                    $params[$key] = array(
     //                        'type'  => $type,
     //                        'value' => $param
     //                    );
     //                }
     //            }
     //        }
     $request = new Zend_XmlRpc_Request($method, $params);
     $this->doRequest($request);
     if ($this->_lastResponse->isFault()) {
         $fault = $this->_lastResponse->getFault();
         throw new Zend_XmlRpc_Client_FaultException($fault->getMessage(), $fault->getCode());
     }
     return $this->_lastResponse->getReturnValue();
 }
開發者ID:villos,項目名稱:tree_admin,代碼行數:42,代碼來源:Client.php

示例5: __toString

 /**
  * Override __toString() to send HTTP Content-Type header
  * 
  * @return string
  */
 public function __toString()
 {
     if (!headers_sent()) {
         header('Content-Type: application/xml; charset=utf-8');
     }
     return parent::__toString();
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:12,代碼來源:Http.php

示例6: testLoadXmlThrowsExceptionWithMissingNodes3

 public function testLoadXmlThrowsExceptionWithMissingNodes3()
 {
     $sxl = new \SimpleXMLElement('<?xml version="1.0"?><methodResponse><bar>foo</bar></methodResponse>');
     $this->assertFalse($this->_response->loadXml($sxl->asXML()));
     $this->assertTrue($this->_response->isFault());
     $fault = $this->_response->getFault();
     $this->assertEquals(652, $fault->getCode());
 }
開發者ID:nevvermind,項目名稱:zf2,代碼行數:8,代碼來源:ResponseTest.php

示例7: _loadXml

 protected function _loadXml($xml)
 {
     try {
         $this->_response->loadXml($xml);
         $this->fail('Invalid XML-RPC response should raise an exception');
     } catch (Exception $e) {
     }
 }
開發者ID:omusico,項目名稱:logica,代碼行數:8,代碼來源:ResponseTest.php

示例8: call

 /**
  * 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
  * @throws Zend_Http_Client_FaultException
  */
 public function call($method, $params = array())
 {
     $request = new Zend_XmlRpc_Request($method, $params);
     $this->doRequest($request);
     if ($this->_lastResponse->isFault()) {
         $fault = $this->_lastResponse->getFault();
         throw new Zend_XmlRpc_Client_FaultException($fault->getMessage(), $fault->getCode());
     }
     return $this->_lastResponse->getReturnValue();
 }
開發者ID:josephholsten,項目名稱:swaplady,代碼行數:17,代碼來源:Client.php

示例9: testDoesNotAllowExternalEntities

 /**
  * @group ZF-12293
  */
 public function testDoesNotAllowExternalEntities()
 {
     $payload = file_get_contents(dirname(__FILE__) . '/_files/ZF12293-response.xml');
     $payload = sprintf($payload, 'file://' . realpath(dirname(__FILE__) . '/_files/ZF12293-payload.txt'));
     $this->_response->loadXml($payload);
     $value = $this->_response->getReturnValue();
     $this->assertTrue(empty($value));
     if (is_string($value)) {
         $this->assertNotContains('Local file inclusion', $value);
     }
 }
開發者ID:navassouza,項目名稱:zf2,代碼行數:14,代碼來源:ResponseTest.php

示例10: test__toString

 /**
  * __toString() test
  *
  * Call as method call 
  *
  * Returns: string 
  */
 public function test__toString()
 {
     $this->_response->setReturnValue('return value');
     $xml = $this->_response->__toString();
     try {
         $sx = new SimpleXMLElement($xml);
     } catch (Exception $e) {
         $this->fail('Invalid XML returned');
     }
     $this->assertTrue($sx->params ? true : false);
     $this->assertTrue($sx->params->param ? true : false);
     $this->assertTrue($sx->params->param->value ? true : false);
     $this->assertTrue($sx->params->param->value->string ? true : false);
     $this->assertEquals('return value', (string) $sx->params->param->value->string);
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:22,代碼來源:ResponseTest.php

示例11: call

 /**
  * 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
  * @param boolean $asResponseObject Return it as a response object instead of PHP native?
  * @throws Zend_Http_Client_FaultException
  */
 public function call($method, $params = array(), $asResponseObject = false)
 {
     $request = new Zend_XmlRpc_Request();
     $request->setMethod($method);
     $request->setParams($params);
     $this->doRequest($request);
     if ($asResponseObject) {
         return $this->_lastResponse;
     } else {
         if ($this->_lastResponse->isFault()) {
             $fault = $this->_lastResponse->getFault();
             throw new Zend_XmlRpc_Client_FaultException($fault->getMessage(), $fault->getCode());
         }
         return $this->_lastResponse->getReturnValue();
     }
 }
開發者ID:BackupTheBerlios,項目名稱:openpublisher-svn,代碼行數:24,代碼來源:Client.php

示例12: call

 /**
  * 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
  * @throws Zend_Http_Client_FaultException
  */
 public function call($method, $params = array())
 {
     if ('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 $e) {
             $success = false;
         }
         if ($success) {
             foreach ($params as $key => $param) {
                 if (is_array($param) && empty($param)) {
                     $type = 'array';
                     foreach ($signatures as $signature) {
                         if (!is_array($signature)) {
                             continue;
                         }
                         if (array_key_exists($key + 1, $signature)) {
                             $type = $signature[$key + 1];
                             $type = in_array($type, array('array', 'struct')) ? $type : 'array';
                             break;
                         }
                     }
                     $params[$key] = array('type' => $type, 'value' => $param);
                 }
             }
         }
     }
     $request = new Zend_XmlRpc_Request($method, $params);
     $this->doRequest($request);
     if ($this->_lastResponse->isFault()) {
         $fault = $this->_lastResponse->getFault();
         throw new Zend_XmlRpc_Client_FaultException($fault->getMessage(), $fault->getCode());
     }
     return $this->_lastResponse->getReturnValue();
 }
開發者ID:jon9872,項目名稱:zend-framework,代碼行數:45,代碼來源:Client.php

示例13: loadXML

 /**
  *
  */
 public function loadXML($response)
 {
     $valid = true;
     if (extension_loaded('WebServices')) {
         if (!is_string($response)) {
             $this->_fault = new Zend_XmlRpc_Fault(650);
             $this->_fault->setEncoding($this->getEncoding());
             return false;
         }
         try {
             $xml = @new SimpleXMLElement($response);
         } catch (Exception $e) {
             // Not valid XML
             $this->_fault = new Zend_XmlRpc_Fault(651);
             $this->_fault->setEncoding($this->getEncoding());
             return false;
         }
         if (!empty($xml->fault)) {
             // fault response
             $this->_fault = new Zend_XmlRpc_Fault();
             $this->_fault->setEncoding($this->getEncoding());
             $this->_fault->loadXml($response);
             return false;
         }
         if (empty($xml->params)) {
             // Invalid response
             $this->_fault = new Zend_XmlRpc_Fault(652);
             $this->_fault->setEncoding($this->getEncoding());
             return false;
         }
         $value = rpc_decode($response);
         $this->setReturnValue($value);
     } else {
         $valid = parent::loadXML($response);
     }
     return $valid;
 }
開發者ID:cwcw,項目名稱:cms,代碼行數:40,代碼來源:Response.php

示例14: testLoadXmlThrowsExceptionWithMissingNodes3

 public function testLoadXmlThrowsExceptionWithMissingNodes3()
 {
     $sxl = new \SimpleXMLElement('<?xml version="1.0"?><methodResponse><bar>foo</bar></methodResponse>');
     $this->setExpectedException('Zend\\XmlRpc\\Exception\\ValueException', 'Missing XML-RPC value in XML');
     $this->_response->loadXml($sxl->asXML());
 }
開發者ID:rmarshall-quibids,項目名稱:zf2,代碼行數:6,代碼來源:ResponseTest.php

示例15: testShouldDisallowsDoctypeInRequestXmlAndReturnFalseOnLoading

 public function testShouldDisallowsDoctypeInRequestXmlAndReturnFalseOnLoading()
 {
     $payload = file_get_contents(dirname(__FILE__) . '/_files/ZF12293-response.xml');
     $payload = sprintf($payload, 'file://' . realpath(dirname(__FILE__) . '/_files/ZF12293-payload.txt'));
     $this->assertFalse($this->_response->loadXml($payload));
 }
開發者ID:ThorstenSuckow,項目名稱:conjoon,代碼行數:6,代碼來源:ResponseTest.php


注:本文中的Zend_XmlRpc_Response類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。