Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 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
 
26
/** PEAR_Error */
27
require_once 'PEAR.php';
28
 
29
/**
30
 * PEAR::Error wrapper used to match SOAP Faults to PEAR Errors
31
 *
32
 * SOAP_Fault can provide a complete backtrace of the error.  Revealing these
33
 * details in a public web services is a bad idea because it can be used by
34
 * attackers.  Thus you have to enable backtrace information in SOAP_Fault
35
 * responses by putting the following code in your script after your
36
 * "require_once 'SOAP/Server.php';" line:
37
 *
38
 * <code>
39
 * $backtrace =& PEAR::getStaticProperty('SOAP_Fault', 'backtrace');
40
 * $backtrace = true;
41
 * </code>
42
 *
43
 * @package  SOAP
44
 * @access   public
45
 * @author   Shane Caraveo <Shane@Caraveo.com>   Port to PEAR and more
46
 * @author   Dietrich Ayala <dietrich@ganx4.com> Original Author
47
 */
48
class SOAP_Fault extends PEAR_Error
49
{
50
    /**
51
     * Constructor.
52
     *
53
     * @param string $faultstring  Message string for fault.
54
     * @param mixed $faultcode     The faultcode.
55
     * @param mixed $faultactor
56
     * @param mixed $detail        @see PEAR_Error
57
     * @param array $mode          @see PEAR_Error
58
     * @param array $options       @see PEAR_Error
59
     */
60
    function SOAP_Fault($faultstring = 'unknown error', $faultcode = 'Client',
61
                        $faultactor = null, $detail = null, $mode = null,
62
                        $options = null)
63
    {
64
        parent::PEAR_Error($faultstring, $faultcode, $mode, $options, $detail);
65
        if ($faultactor) {
66
            $this->error_message_prefix = $faultactor;
67
        }
68
    }
69
 
70
    /**
71
     * Returns a SOAP XML message that can be sent as a server response.
72
     *
73
     * @return string
74
     */
75
    function message($encoding = SOAP_DEFAULT_ENCODING)
76
    {
77
        $msg = new SOAP_Base();
78
        $params = array();
79
        $params[] = new SOAP_Value('faultcode', 'QName', SOAP_BASE::SOAPENVPrefix().':' . $this->code);
80
        $params[] = new SOAP_Value('faultstring', 'string', $this->message);
81
        $params[] = new SOAP_Value('faultactor', 'anyURI', $this->error_message_prefix);
82
        if (PEAR::getStaticProperty('SOAP_Fault', 'backtrace') &&
83
            isset($this->backtrace)) {
84
            $params[] = new SOAP_Value('detail', 'string', $this->backtrace);
85
        } else {
86
            $params[] = new SOAP_Value('detail', 'string', $this->userinfo);
87
        }
88
 
89
        $methodValue = new SOAP_Value('{' . SOAP_ENVELOP . '}Fault', 'Struct', $params);
90
        $headers = null;
91
        return $msg->makeEnvelope($methodValue, $headers, $encoding);
92
    }
93
 
94
    /**
95
     * Returns a simple native PHP array containing the fault data.
96
     *
97
     * @return array
98
     */
99
    function getFault()
100
    {
101
        $fault = new stdClass();
102
        $fault->faultcode = $this->code;
103
        $fault->faultstring = $this->message;
104
        $fault->faultactor = $this->error_message_prefix;
105
        $fault->detail = $this->userinfo;
106
        return $fault;
107
    }
108
 
109
    /**
110
     * Returns the SOAP actor for the fault.
111
     *
112
     * @return string
113
     */
114
    function getActor()
115
    {
116
        return $this->error_message_prefix;
117
    }
118
 
119
    /**
120
     * Returns the fault detail.
121
     *
122
     * @return string
123
     */
124
    function getDetail()
125
    {
126
        return $this->userinfo;
127
    }
128
 
129
}