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


PHP Zend_XmlRpc_Response::loadXml方法代碼示例

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


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

示例1: testLoadXml

 /**
  * loadXml() test
  *
  * Call as method call 
  *
  * Expects:
  * - response: 
  * 
  * Returns: boolean 
  */
 public function testLoadXml()
 {
     $dom = new DOMDocument('1.0', 'UTF-8');
     $response = $dom->appendChild($dom->createElement('methodResponse'));
     $params = $response->appendChild($dom->createElement('params'));
     $param = $params->appendChild($dom->createElement('param'));
     $value = $param->appendChild($dom->createElement('value'));
     $value->appendChild($dom->createElement('string', 'Return value'));
     $xml = $dom->saveXML();
     $parsed = $this->_response->loadXml($xml);
     $this->assertTrue($parsed, $xml);
     $this->assertEquals('Return value', $this->_response->getReturnValue());
 }
開發者ID:jorgenils,項目名稱:zend-framework,代碼行數:23,代碼來源:ResponseTest.php

示例2: 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

示例3: 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

示例4: _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

示例5: 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

示例6: doRequest

 /**
  * Perform an XML-RPC request and return a response.
  *
  * @param Zend_XmlRpc_Request $request
  * @param null|Zend_XmlRpc_Response $response
  * @return void
  */
 public function doRequest($request, $response = null)
 {
     $this->_lastRequest = $request;
     iconv_set_encoding('input_encoding', 'UTF-8');
     iconv_set_encoding('output_encoding', 'UTF-8');
     iconv_set_encoding('internal_encoding', 'UTF-8');
     $http = $this->getHttpClient();
     $http->setUri($this->_serverAddress);
     $http->setHeaders(array('Content-Type: text/xml; charset=utf-8', 'User-Agent: Zend_XmlRpc_Client'));
     $xml = $this->_lastRequest->__toString();
     $http->setRawData($xml);
     $httpResponse = $http->request(Zend_Http_Client::POST);
     if (!$httpResponse->isSuccessful()) {
         throw new Zend_XmlRpc_Client_HttpException($httpResponse->getMessage(), $httpResponse->getStatus());
     }
     if ($response === null) {
         $response = new Zend_XmlRpc_Response();
     }
     $this->_lastResponse = $response;
     $this->_lastResponse->loadXml($httpResponse->getBody());
 }
開發者ID:villos,項目名稱:tree_admin,代碼行數:28,代碼來源:Client.php

示例7: doRequest

 /**
  * Perform an XML-RPC request and return a response.
  *
  * @param Zend_XmlRpc_Request $request
  * @param null|Zend_XmlRpc_Response $response
  * @return void
  * @throws Zend_XmlRpc_Client_HttpException
  */
 public function doRequest($request, $response = null)
 {
     $this->_lastRequest = $request;
     iconv_set_encoding('input_encoding', 'UTF-8');
     iconv_set_encoding('output_encoding', 'UTF-8');
     iconv_set_encoding('internal_encoding', 'UTF-8');
     $http = $this->getHttpClient();
     if ($http->getUri() === null) {
         $http->setUri($this->_serverAddress);
     }
     $http->setHeaders(array('Content-Type: text/xml; charset=utf-8', 'Accept: text/xml'));
     if ($http->getHeader('user-agent') === null) {
         $http->setHeaders(array('User-Agent: Zend_XmlRpc_Client'));
     }
     $xml = $this->_lastRequest->__toString();
     $http->setRawData($xml);
     $httpResponse = $http->request(Zend_Http_Client::POST);
     if (!$httpResponse->isSuccessful()) {
         /**
          * Exception thrown when an HTTP error occurs
          * @see Zend_XmlRpc_Client_HttpException
          */
         #require_once 'Zend/XmlRpc/Client/HttpException.php';
         throw new Zend_XmlRpc_Client_HttpException($httpResponse->getMessage(), $httpResponse->getStatus());
     }
     if ($response === null) {
         $response = new Zend_XmlRpc_Response();
     }
     $this->_lastResponse = $response;
     $this->_lastResponse->loadXml($httpResponse->getBody());
 }
開發者ID:blazeriaz,項目名稱:youguess,代碼行數:39,代碼來源:Client.php

示例8: 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

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