class.soap_fault.php 2.3 KB

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