本文整理汇总了PHP中Zend_XmlRpc_Fault类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_XmlRpc_Fault类的具体用法?PHP Zend_XmlRpc_Fault怎么用?PHP Zend_XmlRpc_Fault使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_XmlRpc_Fault类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: loadXml
/**
* Load a response from an XML response
*
* Attempts to load a response from an XMLRPC response, autodetecting if it
* is a fault response.
*
* @param string $response
* @return boolean True if a valid XMLRPC response, false if a fault
* response or invalid input
*/
public function loadXml($response)
{
if (!is_string($response)) {
$this->_fault = new Zend_XmlRpc_Fault(650);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
// @see ZF-12293 - disable external entities for security purposes
$loadEntities = libxml_disable_entity_loader(true);
$useInternalXmlErrors = libxml_use_internal_errors(true);
try {
$dom = new DOMDocument();
$dom->loadXML($response);
foreach ($dom->childNodes as $child) {
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
#require_once 'Zend/XmlRpc/Exception.php';
throw new Zend_XmlRpc_Exception('Invalid XML: Detected use of illegal DOCTYPE');
}
}
// TODO: Locate why this passes tests but a simplexml import doesn't
// $xml = simplexml_import_dom($dom);
$xml = new SimpleXMLElement($response);
libxml_disable_entity_loader($loadEntities);
libxml_use_internal_errors($useInternalXmlErrors);
} catch (Exception $e) {
libxml_disable_entity_loader($loadEntities);
libxml_use_internal_errors($useInternalXmlErrors);
// 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;
}
try {
if (!isset($xml->params) || !isset($xml->params->param) || !isset($xml->params->param->value)) {
#require_once 'Zend/XmlRpc/Value/Exception.php';
throw new Zend_XmlRpc_Value_Exception('Missing XML-RPC value in XML');
}
$valueXml = $xml->params->param->value->asXML();
$value = Zend_XmlRpc_Value::getXmlRpcValue($valueXml, Zend_XmlRpc_Value::XML_STRING);
} catch (Zend_XmlRpc_Value_Exception $e) {
$this->_fault = new Zend_XmlRpc_Fault(653);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->setReturnValue($value->getValue());
return true;
}
开发者ID:SalesOneGit,项目名称:s1_magento,代码行数:70,代码来源:Response.php
示例2: loadXml
/**
* Load XML and parse into request components
*
* @param string $request
* @return boolean True on success, false if an error occurred.
*/
public function loadXml($request)
{
if (!is_string($request)) {
$this->_fault = new Zend_XmlRpc_Fault(635);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
$xml = new SimpleXMLElement($request);
} catch (Exception $e) {
// Not valid XML
$this->_fault = new Zend_XmlRpc_Fault(631);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
// Check for method name
if (empty($xml->methodName)) {
// Missing method name
$this->_fault = new Zend_XmlRpc_Fault(632);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->_method = (string) $xml->methodName;
// Check for parameters
if (!empty($xml->params)) {
$types = array();
$argv = array();
foreach ($xml->params->children() as $param) {
if (!isset($param->value)) {
$this->_fault = new Zend_XmlRpc_Fault(633);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
$param = Zend_XmlRpc_Value::getXmlRpcValue($param->value, Zend_XmlRpc_Value::XML_STRING);
$types[] = $param->getType();
$argv[] = $param->getValue();
} catch (Exception $e) {
$this->_fault = new Zend_XmlRpc_Fault(636);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
}
$this->_types = $types;
$this->_params = $argv;
}
$this->_xml = $request;
return true;
}
开发者ID:nhp,项目名称:shopware-4,代码行数:63,代码来源:Request.php
示例3: loadXml
/**
* Load a response from an XML response
*
* Attempts to load a response from an XMLRPC response, autodetecting if it
* is a fault response.
*
* @param string $response
* @return boolean True if a valid XMLRPC response, false if a fault
* response or invalid input
*/
public function loadXml($response)
{
if (!is_string($response)) {
$this->_fault = new Zend_XmlRpc_Fault(650);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
// @see ZF-12293 - disable external entities for security purposes
$loadEntities = libxml_disable_entity_loader(true);
$useInternalXmlErrors = libxml_use_internal_errors(true);
try {
$xml = new SimpleXMLElement($response);
libxml_disable_entity_loader($loadEntities);
libxml_use_internal_errors($useInternalXmlErrors);
} catch (Exception $e) {
libxml_disable_entity_loader($loadEntities);
libxml_use_internal_errors($useInternalXmlErrors);
// 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;
}
try {
if (!isset($xml->params) || !isset($xml->params->param) || !isset($xml->params->param->value)) {
//require_once 'Zend/XmlRpc/Value/Exception.php';
throw new Zend_XmlRpc_Value_Exception('Missing XML-RPC value in XML');
}
$valueXml = $xml->params->param->value->asXML();
$value = Zend_XmlRpc_Value::getXmlRpcValue($valueXml, Zend_XmlRpc_Value::XML_STRING);
} catch (Zend_XmlRpc_Value_Exception $e) {
$this->_fault = new Zend_XmlRpc_Fault(653);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->setReturnValue($value->getValue());
return true;
}
开发者ID:schlypel,项目名称:YiiBackboneBoilerplate,代码行数:60,代码来源:Response.php
示例4: loadXml
/**
* Load a response from an XML response
*
* Attempts to load a response from an XMLRPC response, autodetecting if it
* is a fault response.
*
* @param string $response
* @return boolean True if a valid XMLRPC response, false if a fault
* response or invalid input
*/
public function loadXml($response)
{
if (!is_string($response)) {
$this->_fault = new Zend_XmlRpc_Fault(650);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
$useInternalXmlErrors = libxml_use_internal_errors(true);
$xml = new SimpleXMLElement($response);
libxml_use_internal_errors($useInternalXmlErrors);
} catch (Exception $e) {
libxml_use_internal_errors($useInternalXmlErrors);
// 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;
}
try {
if (!isset($xml->params) || !isset($xml->params->param) || !isset($xml->params->param->value)) {
throw new Zend_XmlRpc_Value_Exception('Missing XML-RPC value in XML');
}
$valueXml = $xml->params->param->value->asXML();
$value = Zend_XmlRpc_Value::getXmlRpcValue($valueXml, Zend_XmlRpc_Value::XML_STRING);
} catch (Zend_XmlRpc_Value_Exception $e) {
$this->_fault = new Zend_XmlRpc_Fault(653);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->setReturnValue($value->getValue());
return true;
}
开发者ID:nhp,项目名称:shopware-4,代码行数:60,代码来源:Response.php
示例5: loadXml
/**
* Load a response from an XML response
*
* Attempts to load a response from an XMLRPC response, autodetecting if it
* is a fault response.
*
* @param string $response
* @return boolean True if a valid XMLRPC response, false if a fault
* response or invalid input
*/
public function loadXml($response)
{
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;
}
try {
if (!isset($xml->params) || !isset($xml->params->param) || !isset($xml->params->param->value)) {
throw new Zend_XmlRpc_Value_Exception('Missing XML-RPC value in XML');
}
$valueXml = $xml->params->param->value->asXML();
$valueXml = preg_replace('/<\?xml version=.*?\?>/i', '', $valueXml);
$value = Zend_XmlRpc_Value::getXmlRpcValue(trim($valueXml), Zend_XmlRpc_Value::XML_STRING);
} catch (Zend_XmlRpc_Value_Exception $e) {
$this->_fault = new Zend_XmlRpc_Fault(653);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->setReturnValue($value->getValue());
return true;
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:58,代码来源:Response.php
示例6: loadXml
/**
* Load a response from an XML response
*
* Attempts to load a response from an XMLRPC response, autodetecting if it
* is a fault response.
*
* @param string $response
* @return boolean True if a valid XMLRPC response, false if a fault
* response or invalid input
*/
public function loadXml($response)
{
if (!is_string($response)) {
$this->_fault = new Zend_XmlRpc_Fault(650);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
$xml = Zend_Xml_Security::scan($response);
} catch (Zend_Xml_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;
}
try {
if (!isset($xml->params) || !isset($xml->params->param) || !isset($xml->params->param->value)) {
require_once 'Zend/XmlRpc/Value/Exception.php';
throw new Zend_XmlRpc_Value_Exception('Missing XML-RPC value in XML');
}
$valueXml = $xml->params->param->value->asXML();
$value = Zend_XmlRpc_Value::getXmlRpcValue($valueXml, Zend_XmlRpc_Value::XML_STRING);
} catch (Zend_XmlRpc_Value_Exception $e) {
$this->_fault = new Zend_XmlRpc_Fault(653);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->setReturnValue($value->getValue());
return true;
}
开发者ID:alanaipe2015,项目名称:moodle,代码行数:53,代码来源:Response.php
示例7: loadXml
/**
* Load a response from an XML response
*
* Attempts to load a response from an XMLRPC response, autodetecting if it
* is a fault response.
*
* @param string $response
* @return boolean True if a valid XMLRPC response, false if a fault
* response or invalid input
*/
public function loadXml($response)
{
if (!is_string($response)) {
$this->_fault = new Zend_XmlRpc_Fault(650);
return false;
}
// cast to UTF-8
$response = iconv('', 'UTF-8', $response);
try {
$xml = @new SimpleXMLElement($response);
} catch (Exception $e) {
// Not valid XML
$this->_fault = new Zend_XmlRpc_Fault(651);
return false;
}
if (!empty($xml->fault)) {
// fault response
$this->_fault = new Zend_XmlRpc_Fault();
$this->_fault->loadXml($response);
return false;
}
if (empty($xml->params)) {
// Invalid response
$this->_fault = new Zend_XmlRpc_Fault(652);
return false;
}
try {
$valueXml = $xml->params->param->value->asXML();
$valueXml = preg_replace('/<\\?xml version=.*?\\?>/i', '', $valueXml);
$value = Zend_XmlRpc_Value::getXmlRpcValue(trim($valueXml), Zend_XmlRpc_Value::XML_STRING);
} catch (Zend_XmlRpc_Value_Exception $e) {
$this->_fault = new Zend_XmlRpc_Fault(653);
return false;
}
$this->setReturnValue($value->getValue());
return true;
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:47,代码来源:Response.php
示例8: loadXml
/**
* Load XML and parse into request components
*
* @param string $request
* @return boolean True on success, false if an error occurred.
*/
public function loadXml($request)
{
if (!is_string($request)) {
$this->_fault = new Zend_XmlRpc_Fault(635);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
// @see ZF-12293 - disable external entities for security purposes
$loadEntities = libxml_disable_entity_loader(true);
try {
$dom = new DOMDocument();
$dom->loadXML($request);
foreach ($dom->childNodes as $child) {
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE) {
// require_once 'Zend/XmlRpc/Exception.php';
throw new Zend_XmlRpc_Exception('Invalid XML: Detected use of illegal DOCTYPE');
}
}
$xml = simplexml_import_dom($dom);
libxml_disable_entity_loader($loadEntities);
} catch (Exception $e) {
// Not valid XML
$this->_fault = new Zend_XmlRpc_Fault(631);
$this->_fault->setEncoding($this->getEncoding());
libxml_disable_entity_loader($loadEntities);
return false;
}
// Check for method name
if (empty($xml->methodName)) {
// Missing method name
$this->_fault = new Zend_XmlRpc_Fault(632);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
$this->_method = (string) $xml->methodName;
// Check for parameters
if (!empty($xml->params)) {
$types = array();
$argv = array();
foreach ($xml->params->children() as $param) {
if (!isset($param->value)) {
$this->_fault = new Zend_XmlRpc_Fault(633);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
try {
$param = Zend_XmlRpc_Value::getXmlRpcValue($param->value, Zend_XmlRpc_Value::XML_STRING);
$types[] = $param->getType();
$argv[] = $param->getValue();
} catch (Exception $e) {
$this->_fault = new Zend_XmlRpc_Fault(636);
$this->_fault->setEncoding($this->getEncoding());
return false;
}
}
$this->_types = $types;
$this->_params = $argv;
}
$this->_xml = $request;
return true;
}
开发者ID:jkimdon,项目名称:cohomeals,代码行数:67,代码来源:Request.php
示例9: testGettingAllMethodSignaturesDegradesToLooping
public function testGettingAllMethodSignaturesDegradesToLooping()
{
// system.listMethods() will return ['foo', 'bar']
$whatListMethodsReturns = array('foo', 'bar');
$response = $this->getServerResponseFor($whatListMethodsReturns);
$this->httpAdapter->setResponse($response);
// system.multicall() will return a fault
$fault = new Zend_XmlRpc_Fault(7, 'bad method');
$xml = $fault->saveXml();
$response = $this->makeHttpResponseFrom($xml);
$this->httpAdapter->addResponse($response);
// system.methodSignature('foo') will return [['int'], ['int', 'string']]
$fooSignatures = array(array('int'), array('int', 'string'));
$response = $this->getServerResponseFor($fooSignatures);
$this->httpAdapter->addResponse($response);
// system.methodSignature('bar') will return [['boolean']]
$barSignatures = array(array('boolean'));
$response = $this->getServerResponseFor($barSignatures);
$this->httpAdapter->addResponse($response);
$i = $this->xmlrpcClient->getIntrospector();
$expected = array('foo' => $fooSignatures, 'bar' => $barSignatures);
$this->assertEquals($expected, $i->getSignatureForEachMethod());
$request = $this->xmlrpcClient->getLastRequest();
$this->assertEquals('system.methodSignature', $request->getMethod());
}
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:25,代码来源:ClientTest.php
示例10: testFaultStringWithoutStringTypeDeclaration
public function testFaultStringWithoutStringTypeDeclaration()
{
$xml = $this->_createNonStandardXml();
$parsed = $this->_fault->loadXml($xml);
$this->assertTrue($parsed, $xml);
$this->assertEquals('Error string', $this->_fault->getMessage());
}
开发者ID:rafalwrzeszcz,项目名称:zf2,代码行数:7,代码来源:FaultTest.php
示例11: test__toString
/**
* __toString() test
*/
public function test__toString()
{
$this->_fault->setCode(1000);
$this->_fault->setMessage('Fault message');
$xml = $this->_fault->__toString();
try {
$sx = new SimpleXMLElement($xml);
} catch (Exception $e) {
$this->fail('Unable to parse generated XML');
}
$this->assertTrue($sx->fault ? true : false, $xml);
$this->assertTrue($sx->fault->value ? true : false, $xml);
$this->assertTrue($sx->fault->value->struct ? true : false, $xml);
$count = 0;
foreach ($sx->fault->value->struct->member as $member) {
$count++;
$this->assertTrue($member->name ? true : false, $xml);
$this->assertTrue($member->value ? true : false, $xml);
if ('faultCode' == (string) $member->name) {
$this->assertTrue($member->value->int ? true : false, $xml);
$this->assertEquals(1000, (int) $member->value->int, $xml);
}
if ('faultString' == (string) $member->name) {
$this->assertTrue($member->value->string ? true : false, $xml);
$this->assertEquals('Fault message', (string) $member->value->string, $xml);
}
}
$this->assertEquals(2, $count, $xml);
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:32,代码来源:FaultTest.php
示例12: testFaultStringWithoutStringTypeDeclaration
public function testFaultStringWithoutStringTypeDeclaration()
{
$xml = $this->_createNonStandardXml();
try {
$parsed = $this->_fault->loadXml($xml);
} catch (Exception $e) {
$this->fail('Failed to parse XML: ' . $e->getMessage());
}
$this->assertTrue($parsed, $xml);
$this->assertEquals('Error string', $this->_fault->getMessage());
}
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:11,代码来源:FaultTest.php
示例13: __construct
/**
* Constructor
*
* @param Exception $e
* @return Zend_XmlRpc_Server_Fault
*/
public function __construct(Exception $e)
{
$this->_exception = $e;
$code = 404;
$message = 'Unknown error';
$exceptionClass = get_class($e);
if (isset(self::$_faultExceptionClasses[$exceptionClass])) {
$code = $e->getCode();
$message = $e->getMessage();
}
parent::__construct($code, $message);
// Notify exception observers, if present
if (!empty(self::$_observers)) {
foreach (array_keys(self::$_observers) as $observer) {
call_user_func(array($observer, 'observe'), $this);
}
}
}
开发者ID:vojtajina,项目名称:sitellite,代码行数:24,代码来源:Fault.php
示例14: testSetGetEncoding
/**
* Test encoding settings
*/
public function testSetGetEncoding()
{
$this->assertEquals('UTF-8', $this->_fault->getEncoding());
$this->_fault->setEncoding('ISO-8859-1');
$this->assertEquals('ISO-8859-1', $this->_fault->getEncoding());
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:FaultTest.php
注:本文中的Zend_XmlRpc_Fault类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论