source: branches/version-2_5-dev/data/module/SOAP/Fault.php @ 20119

Revision 20119, 4.0 KB checked in by nanasess, 13 years ago (diff)

module 以下は svn:keywords を除外

  • Property svn:eol-style set to LF
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2/**
3 * This file contains the SOAP_Fault class, used for all error objects in this
4 * package.
5 *
6 * PHP versions 4 and 5
7 *
8 * LICENSE: This source file is subject to version 2.02 of the PHP license,
9 * that is bundled with this package in the file LICENSE, and is available at
10 * through the world-wide-web at http://www.php.net/license/2_02.txt.  If you
11 * did not receive a copy of the PHP license and are unable to obtain it
12 * through the world-wide-web, please send a note to license@php.net so we can
13 * mail you a copy immediately.
14 *
15 * @category   Web Services
16 * @package    SOAP
17 * @author     Dietrich Ayala <dietrich@ganx4.com> Original Author
18 * @author     Shane Caraveo <Shane@Caraveo.com>   Port to PEAR and more
19 * @author     Chuck Hagenbuch <chuck@horde.org>   Maintenance
20 * @author     Jan Schneider <jan@horde.org>       Maintenance
21 * @copyright  2003-2006 The PHP Group
22 * @license    http://www.php.net/license/2_02.txt  PHP License 2.02
23 * @link       http://pear.php.net/package/SOAP
24 */
25
26require_once 'PEAR.php';
27
28/**
29 * PEAR::Error wrapper used to match SOAP Faults to PEAR Errors
30 *
31 * SOAP_Fault transmissions normally contain a complete backtrace of the
32 * error.  Revealing these details in a public web services is a bad idea
33 * because it can be used by attackers.  Backtrace information can be kept out
34 * of SOAP_Fault responses by putting the following code in your script after
35 * your "require_once 'SOAP/Server.php';" line:
36 *
37 * <code>
38 * $skiptrace =& PEAR::getStaticProperty('PEAR_Error', 'skiptrace');
39 * $skiptrace = true;
40 * </code>
41 *
42 * @package  SOAP
43 * @access   public
44 * @author   Shane Caraveo <Shane@Caraveo.com>   Port to PEAR and more
45 * @author   Dietrich Ayala <dietrich@ganx4.com> Original Author
46 */
47class SOAP_Fault extends PEAR_Error
48{
49    /**
50     * Constructor.
51     *
52     * @param string $faultstring  Message string for fault.
53     * @param mixed $faultcode     The faultcode.
54     * @param mixed $faultactor
55     * @param mixed $detail        @see PEAR_Error
56     * @param array $mode          @see PEAR_Error
57     * @param array $options       @see PEAR_Error
58     */
59    function SOAP_Fault($faultstring = 'unknown error', $faultcode = 'Client',
60                        $faultactor = null, $detail = null, $mode = null,
61                        $options = null)
62    {
63        parent::PEAR_Error($faultstring, $faultcode, $mode, $options, $detail);
64        if ($faultactor) {
65            $this->error_message_prefix = $faultactor;
66        }
67    }
68
69    /**
70     * Returns a SOAP XML message that can be sent as a server response.
71     *
72     * @return string
73     */
74    function message($encoding = SOAP_DEFAULT_ENCODING)
75    {
76        $msg = new SOAP_Base();
77        $params = array();
78        $params[] = new SOAP_Value('faultcode', 'QName', 'SOAP-ENV:' . $this->code);
79        $params[] = new SOAP_Value('faultstring', 'string', $this->message);
80        $params[] = new SOAP_Value('faultactor', 'anyURI', $this->error_message_prefix);
81        if (isset($this->backtrace)) {
82            $params[] = new SOAP_Value('detail', 'string', $this->backtrace);
83        } else {
84            $params[] = new SOAP_Value('detail', 'string', $this->userinfo);
85        }
86
87        $methodValue = new SOAP_Value('{' . SOAP_ENVELOP . '}Fault', 'Struct', $params);
88        $headers = null;
89        return $msg->makeEnvelope($methodValue, $headers, $encoding);
90    }
91
92    /**
93     * Returns a simple native PHP array containing the fault data.
94     *
95     * @return array
96     */
97    function getFault()
98    {
99        $fault = new stdClass();
100        $fault->faultcode = $this->code;
101        $fault->faultstring = $this->message;
102        $fault->faultactor = $this->error_message_prefix;
103        $fault->detail = $this->userinfo;
104        return $fault;
105    }
106
107    /**
108     * Returns the SOAP actor for the fault.
109     *
110     * @return string
111     */
112    function getActor()
113    {
114        return $this->error_message_prefix;
115    }
116
117    /**
118     * Returns the fault detail.
119     *
120     * @return string
121     */
122    function getDetail()
123    {
124        return $this->userinfo;
125    }
126
127}
Note: See TracBrowser for help on using the repository browser.