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


PHP Zend_XmlRpc_Server::fault方法代码示例

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


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

示例1: fault

 /**
  * Raise an xmlrpc server fault
  *
  * Moodle note: the difference with the Zend server is that we throw a plain PHP Exception
  * with the debuginfo integrated to the exception message when DEBUG >= NORMAL
  *
  * @param string|Exception $fault
  * @param int $code
  * @return Zend_XmlRpc_Server_Fault
  */
 public function fault($fault = null, $code = 404)
 {
     //intercept any exceptions with debug info and transform it in Moodle exception
     if ($fault instanceof Exception) {
         //add the debuginfo to the exception message if debuginfo must be returned
         if (debugging() and isset($fault->debuginfo)) {
             $fault = new Exception($fault->getMessage() . ' | DEBUG INFO: ' . $fault->debuginfo, 0);
         }
     }
     return parent::fault($fault, $code);
 }
开发者ID:LMSeXT,项目名称:SAWEE-WS_server-engine,代码行数:21,代码来源:locallib.php

示例2: testFault

 /**
  * fault() test
  */
 public function testFault()
 {
     $fault = $this->_server->fault('This is a fault', 411);
     $this->assertTrue($fault instanceof Zend_XmlRpc_Server_Fault);
     $this->assertEquals(411, $fault->getCode());
     $this->assertEquals('This is a fault', $fault->getMessage());
     $fault = $this->_server->fault(new Zend_XmlRpc_Server_Exception('Exception fault', 511));
     $this->assertTrue($fault instanceof Zend_XmlRpc_Server_Fault);
     $this->assertEquals(511, $fault->getCode());
     $this->assertEquals('Exception fault', $fault->getMessage());
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:14,代码来源:ServerTest.php

示例3: multicall

    /**
     * Multicall - boxcar feature of XML-RPC for calling multiple methods
     * in a single request.
     *
     * Expects a an array of structs representing method calls, each element
     * having the keys:
     * - methodName
     * - params
     *
     * Returns an array of responses, one for each method called, with the value
     * returned by the method. If an error occurs for a given method, returns a
     * struct with a fault response.
     *
     * @see http://www.xmlrpc.com/discuss/msgReader$1208
     * @param  array $methods
     * @return array
     */
    public function multicall($methods)
    {
        $responses = array();
        foreach ($methods as $method) {
            $fault = false;
            if (!is_array($method)) {
                $fault = $this->_server->fault('system.multicall expects each method to be a struct', 601);
            } elseif (!isset($method['methodName'])) {
                $fault = $this->_server->fault('Missing methodName: ' . var_export($methods, 1), 602);
            } elseif (!isset($method['params'])) {
                $fault = $this->_server->fault('Missing params', 603);
            } elseif (!is_array($method['params'])) {
                $fault = $this->_server->fault('Params must be an array', 604);
            } else {
                if ('system.multicall' == $method['methodName']) {
                    // don't allow recursive calls to multicall
                    $fault = $this->_server->fault('Recursive system.multicall forbidden', 605);
                }
            }

            if (!$fault) {
                try {
                    $request = new Zend_XmlRpc_Request();
                    $request->setMethod($method['methodName']);
                    $request->setParams($method['params']);
                    $response = $this->_server->handle($request);
                    if ($response instanceof Zend_XmlRpc_Fault
                        || $response->isFault()
                    ) {
                        $fault = $response;
                    } else {
                        $responses[] = $response->getReturnValue();
                    }
                } catch (Exception $e) {
                    $fault = $this->_server->fault($e);
                }
            }

            if ($fault) {
                $responses[] = array(
                    'faultCode'   => $fault->getCode(),
                    'faultString' => $fault->getMessage()
                );
            }
        }

        return $responses;
    }
开发者ID:nhp,项目名称:shopware-4,代码行数:65,代码来源:System.php

示例4: fault

 /**
  * Generate a server fault
  *
  * Note that the arguments are reverse to those of Zend_XmlRpc_Server_Fault.
  *
  * note: the difference with the Zend server is that we throw a Zend_XmlRpc_Server_Fault exception
  * with the debuginfo integrated to the exception message when DEBUG >= NORMAL
  *
  * If an exception is passed as the first argument, its message and code
  * will be used to create the fault object if it has been registered via
  * {@Link registerFaultException()}.
  *
  * @param  string|Exception $fault
  * @param  string $code XMLRPC Fault Codes
  * @return Zend_XmlRpc_Server_Fault
  */
 public function fault($fault = null, $code = 404)
 {
     //run the zend code that clean/create a xmlrpcfault
     $xmlrpcfault = parent::fault($fault, $code);
     //intercept any exceptions and add the errorcode and debuginfo (optional)
     $actor = null;
     $details = null;
     if ($fault instanceof Exception) {
         //add the debuginfo to the exception message if debuginfo must be returned
         if (ws_debugging() and isset($fault->debuginfo)) {
             $details = $fault->debuginfo;
         }
     }
     $fault = new Zend_XmlRpc_Server_Fault($xmlrpcfault);
     $fault->setCode($xmlrpcfault->getCode());
     $fault->setMessage($xmlrpcfault->getMessage() . ' | ERRORCODE: ' . $xmlrpcfault->getCode() . ' | DETAILS: ' . $details);
     return $fault;
 }
开发者ID:rboyatt,项目名称:mahara,代码行数:34,代码来源:locallib.php

示例5: fault

 /**
  * Raise an xmlrpc server fault
  *
  * Moodle note: the difference with the Zend server is that we throw a plain PHP Exception
  * with the debuginfo integrated to the exception message when DEBUG >= NORMAL
  *
  * @param string|Exception $fault
  * @param int $code
  * @return Zend_XmlRpc_Server_Fault
  */
 public function fault($fault = null, $code = 404)
 {
     // Intercept any exceptions with debug info and transform it in Moodle exception.
     if ($fault instanceof Exception) {
         // Code php exception must be a long
         // we obtain a hash of the errorcode, and then to get an integer hash.
         $code = base_convert(md5($fault->errorcode), 16, 10);
         // Code php exception being a long, it has a maximum number of digits.
         // we strip the $code to 8 digits, and hope for no error code collisions.
         // Collisions should be pretty rare, and if needed the client can retrieve
         // the accurate errorcode from the last | in the exception message.
         $code = substr($code, 0, 8);
         // Add the debuginfo to the exception message if debuginfo must be returned.
         if (debugging() and isset($fault->debuginfo)) {
             $fault = new Exception($fault->getMessage() . ' | DEBUG INFO: ' . $fault->debuginfo . ' | ERRORCODE: ' . $fault->errorcode, $code);
         } else {
             $fault = new Exception($fault->getMessage() . ' | ERRORCODE: ' . $fault->errorcode, $code);
         }
     }
     return parent::fault($fault, $code);
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:31,代码来源:locallib.php

示例6: testCreatingFaultWithEmptyMessageResultsInUnknownError

 public function testCreatingFaultWithEmptyMessageResultsInUnknownError()
 {
     $fault = $this->_server->fault('', 123);
     $this->assertSame('Unknown Error', $fault->getMessage());
     $this->assertSame(123, $fault->getCode());
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:6,代码来源:ServerTest.php


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