class.soap_val.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. /**
  3. * For creating serializable abstractions of native PHP types. This class
  4. * allows element name/namespace, XSD type, and XML attributes to be
  5. * associated with a value. This is extremely useful when WSDL is not
  6. * used, but is also useful when WSDL is used with polymorphic types, including
  7. * xsd:anyType and user-defined types.
  8. *
  9. * @author Dietrich Ayala <dietrich@ganx4.com>
  10. * @version $Id: class.soap_val.php,v 1.11 2007/04/06 13:56:32 snichol Exp $
  11. * @access public
  12. */
  13. class soapval extends nusoap_base
  14. {
  15. /**
  16. * The XML element name
  17. *
  18. * @var string
  19. * @access private
  20. */
  21. var $name;
  22. /**
  23. * The XML type name (string or false)
  24. *
  25. * @var mixed
  26. * @access private
  27. */
  28. var $type;
  29. /**
  30. * The PHP value
  31. *
  32. * @var mixed
  33. * @access private
  34. */
  35. var $value;
  36. /**
  37. * The XML element namespace (string or false)
  38. *
  39. * @var mixed
  40. * @access private
  41. */
  42. var $element_ns;
  43. /**
  44. * The XML type namespace (string or false)
  45. *
  46. * @var mixed
  47. * @access private
  48. */
  49. var $type_ns;
  50. /**
  51. * The XML element attributes (array or false)
  52. *
  53. * @var mixed
  54. * @access private
  55. */
  56. var $attributes;
  57. /**
  58. * constructor
  59. *
  60. * @param string $name optional name
  61. * @param mixed $type optional type name
  62. * @param mixed $value optional value
  63. * @param mixed $element_ns optional namespace of value
  64. * @param mixed $type_ns optional namespace of type
  65. * @param mixed $attributes associative array of attributes to add to element serialization
  66. * @access public
  67. */
  68. function __construct($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
  69. parent::__construct();
  70. $this->name = $name;
  71. $this->type = $type;
  72. $this->value = $value;
  73. $this->element_ns = $element_ns;
  74. $this->type_ns = $type_ns;
  75. $this->attributes = $attributes;
  76. }
  77. /**
  78. * return serialized value
  79. *
  80. * @param string $use The WSDL use value (encoded|literal)
  81. * @return string XML data
  82. * @access public
  83. */
  84. function serialize($use='encoded') {
  85. return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true);
  86. }
  87. /**
  88. * decodes a soapval object into a PHP native type
  89. *
  90. * @return mixed
  91. * @access public
  92. */
  93. function decode(){
  94. return $this->value;
  95. }
  96. }
  97. ?>