class.soap_fault.php 2.1 KB

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