root/trunk/lib/class.soap_fault.php

Revision 61, 2.2 kB (checked in by yann, 5 years ago)

use nusoap library for SOAP access (can be included in plugin package)

Line 
1 <?php
2
3
4
5
6 /**
7 * Contains information for a SOAP fault.
8 * Mainly used for returning faults from deployed functions
9 * in a server instance.
10 * @author   Dietrich Ayala <dietrich@ganx4.com>
11 * @version  $Id: class.soap_fault.php,v 1.12 2005/07/27 19:24:42 snichol Exp $
12 * @access public
13 */
14 class soap_fault extends nusoap_base {
15     /**
16      * The fault code (client|server)
17      * @var string
18      * @access private
19      */
20     var $faultcode;
21     /**
22      * The fault actor
23      * @var string
24      * @access private
25      */
26     var $faultactor;
27     /**
28      * The fault string, a description of the fault
29      * @var string
30      * @access private
31      */
32     var $faultstring;
33     /**
34      * The fault detail, typically a string or array of string
35      * @var mixed
36      * @access private
37      */
38     var $faultdetail;
39
40     /**
41     * constructor
42     *
43     * @param string $faultcode (client | server)
44     * @param string $faultactor only used when msg routed between multiple actors
45     * @param string $faultstring human readable error message
46     * @param mixed $faultdetail detail, typically a string or array of string
47     */
48     function soap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
49         parent::nusoap_base();
50         $this->faultcode = $faultcode;
51         $this->faultactor = $faultactor;
52         $this->faultstring = $faultstring;
53         $this->faultdetail = $faultdetail;
54     }
55
56     /**
57     * serialize a fault
58     *
59     * @return    string    The serialization of the fault instance.
60     * @access   public
61     */
62     function serialize(){
63         $ns_string = '';
64         foreach($this->namespaces as $k => $v){
65             $ns_string .= "\n  xmlns:$k=\"$v\"";
66         }
67         $return_msg =
68             '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'.
69             '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n".
70                 '<SOAP-ENV:Body>'.
71                 '<SOAP-ENV:Fault>'.
72                     $this->serialize_val($this->faultcode, 'faultcode').
73                     $this->serialize_val($this->faultactor, 'faultactor').
74                     $this->serialize_val($this->faultstring, 'faultstring').
75                     $this->serialize_val($this->faultdetail, 'detail').
76                 '</SOAP-ENV:Fault>'.
77                 '</SOAP-ENV:Body>'.
78             '</SOAP-ENV:Envelope>';
79         return $return_msg;
80     }
81 }
82
83
84
85
86 ?>
Note: See TracBrowser for help on using the browser.