| 1 |
lars |
1 |
<?php
|
|
|
2 |
//
|
|
|
3 |
// +----------------------------------------------------------------------+
|
|
|
4 |
// | PHP Version 4 |
|
|
|
5 |
// +----------------------------------------------------------------------+
|
|
|
6 |
// | Copyright (c) 1997-2003 The PHP Group |
|
|
|
7 |
// +----------------------------------------------------------------------+
|
|
|
8 |
// | 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 |
|
|
|
10 |
// | available at through the world-wide-web at |
|
|
|
11 |
// | http://www.php.net/license/2_02.txt. |
|
|
|
12 |
// | If you did not receive a copy of the PHP license and are unable to |
|
|
|
13 |
// | obtain it through the world-wide-web, please send a note to |
|
|
|
14 |
// | license@php.net so we can mail you a copy immediately. |
|
|
|
15 |
// +----------------------------------------------------------------------+
|
|
|
16 |
// | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more |
|
|
|
17 |
// | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author |
|
|
|
18 |
// +----------------------------------------------------------------------+
|
|
|
19 |
//
|
|
|
20 |
// $Id: Fault.php 696 2011-09-08 09:08:23Z tiefland $
|
|
|
21 |
//
|
|
|
22 |
require_once('PEAR.php');
|
|
|
23 |
|
|
|
24 |
/**
|
|
|
25 |
* SOAP_Fault
|
|
|
26 |
* PEAR::Error wrapper used to match SOAP Faults to PEAR Errors
|
|
|
27 |
*
|
|
|
28 |
* @package SOAP
|
|
|
29 |
* @access public
|
|
|
30 |
* @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more
|
|
|
31 |
* @author Dietrich Ayala <dietrich@ganx4.com> Original Author
|
|
|
32 |
*/
|
|
|
33 |
class SOAP_Fault extends PEAR_Error
|
|
|
34 |
{
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* Constructor
|
|
|
38 |
*
|
|
|
39 |
* @param string message string for fault
|
|
|
40 |
* @param mixed the faultcode
|
|
|
41 |
* @param mixed see PEAR::ERROR
|
|
|
42 |
* @param mixed see PEAR::ERROR
|
|
|
43 |
* @param array the userinfo array is used to pass in the
|
|
|
44 |
* SOAP actor and detail for the fault
|
|
|
45 |
*/
|
|
|
46 |
function SOAP_Fault($faultstring = 'unknown error', $faultcode = 'Client', $faultactor=NULL, $detail=NULL, $mode = null, $options = null)
|
|
|
47 |
{
|
|
|
48 |
parent::PEAR_Error($faultstring, $faultcode, $mode, $options, $detail);
|
|
|
49 |
if ($faultactor) $this->error_message_prefix = $faultactor;
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
/**
|
|
|
53 |
* message
|
|
|
54 |
*
|
|
|
55 |
* returns a SOAP_Message class that can be sent as a server response
|
|
|
56 |
*
|
|
|
57 |
* @return SOAP_Message
|
|
|
58 |
* @access public
|
|
|
59 |
*/
|
|
|
60 |
function message()
|
|
|
61 |
{
|
|
|
62 |
$msg =& new SOAP_Base();
|
|
|
63 |
$params = array();
|
|
|
64 |
$params[] =& new SOAP_Value('faultcode', 'QName', 'SOAP-ENV:'.$this->code);
|
|
|
65 |
$params[] =& new SOAP_Value('faultstring', 'string', $this->message);
|
|
|
66 |
$params[] =& new SOAP_Value('faultactor', 'anyURI', $this->error_message_prefix);
|
|
|
67 |
if (isset($this->backtrace)) {
|
|
|
68 |
$params[] =& new SOAP_Value('detail', 'string', $this->backtrace);
|
|
|
69 |
} else {
|
|
|
70 |
$params[] =& new SOAP_Value('detail', 'string', $this->userinfo);
|
|
|
71 |
}
|
|
|
72 |
|
|
|
73 |
$methodValue =& new SOAP_Value('{'.SOAP_ENVELOP.'}Fault', 'Struct', $params);
|
|
|
74 |
$headers = NULL;
|
|
|
75 |
return $msg->_makeEnvelope($methodValue, $headers);
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
/**
|
|
|
79 |
* getFault
|
|
|
80 |
*
|
|
|
81 |
* returns a simple native php array containing the fault data
|
|
|
82 |
*
|
|
|
83 |
* @return array
|
|
|
84 |
* @access public
|
|
|
85 |
*/
|
|
|
86 |
function getFault()
|
|
|
87 |
{
|
|
|
88 |
global $SOAP_OBJECT_STRUCT;
|
|
|
89 |
if ($SOAP_OBJECT_STRUCT) {
|
|
|
90 |
$fault =& new stdClass();
|
|
|
91 |
$fault->faultcode = $this->code;
|
|
|
92 |
$fault->faultstring = $this->message;
|
|
|
93 |
$fault->faultactor = $this->error_message_prefix;
|
|
|
94 |
$fault->detail = $this->userinfo;
|
|
|
95 |
return $fault;
|
|
|
96 |
}
|
|
|
97 |
return array(
|
|
|
98 |
'faultcode' => $this->code,
|
|
|
99 |
'faultstring' => $this->message,
|
|
|
100 |
'faultactor' => $this->error_message_prefix,
|
|
|
101 |
'detail' => $this->userinfo
|
|
|
102 |
);
|
|
|
103 |
}
|
|
|
104 |
|
|
|
105 |
/**
|
|
|
106 |
* getActor
|
|
|
107 |
*
|
|
|
108 |
* returns the SOAP actor for the fault
|
|
|
109 |
*
|
|
|
110 |
* @return string
|
|
|
111 |
* @access public
|
|
|
112 |
*/
|
|
|
113 |
function getActor()
|
|
|
114 |
{
|
|
|
115 |
return $this->error_message_prefix;
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
/**
|
|
|
119 |
* getDetail
|
|
|
120 |
*
|
|
|
121 |
* returns the fault detail
|
|
|
122 |
*
|
|
|
123 |
* @return string
|
|
|
124 |
* @access public
|
|
|
125 |
*/
|
|
|
126 |
function getDetail()
|
|
|
127 |
{
|
|
|
128 |
return $this->userinfo;
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
}
|
|
|
132 |
?>
|