class.soap_fault.php 2.3 KB

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