class.soap_val.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. * The XML element name
  16. *
  17. * @var string
  18. * @access private
  19. */
  20. var $name;
  21. /**
  22. * The XML type name (string or false)
  23. *
  24. * @var mixed
  25. * @access private
  26. */
  27. var $type;
  28. /**
  29. * The PHP value
  30. *
  31. * @var mixed
  32. * @access private
  33. */
  34. var $value;
  35. /**
  36. * The XML element namespace (string or false)
  37. *
  38. * @var mixed
  39. * @access private
  40. */
  41. var $element_ns;
  42. /**
  43. * The XML type namespace (string or false)
  44. *
  45. * @var mixed
  46. * @access private
  47. */
  48. var $type_ns;
  49. /**
  50. * The XML element attributes (array or false)
  51. *
  52. * @var mixed
  53. * @access private
  54. */
  55. var $attributes;
  56. /**
  57. * constructor
  58. *
  59. * @param string $name optional name
  60. * @param mixed $type optional type name
  61. * @param mixed $value optional value
  62. * @param mixed $element_ns optional namespace of value
  63. * @param mixed $type_ns optional namespace of type
  64. * @param mixed $attributes associative array of attributes to add to element serialization
  65. * @access public
  66. */
  67. function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
  68. parent::nusoap_base();
  69. $this->name = $name;
  70. $this->type = $type;
  71. $this->value = $value;
  72. $this->element_ns = $element_ns;
  73. $this->type_ns = $type_ns;
  74. $this->attributes = $attributes;
  75. }
  76. /**
  77. * return serialized value
  78. *
  79. * @param string $use The WSDL use value (encoded|literal)
  80. * @return string XML data
  81. * @access public
  82. */
  83. function serialize($use='encoded') {
  84. return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true);
  85. }
  86. /**
  87. * decodes a soapval object into a PHP native type
  88. *
  89. * @return mixed
  90. * @access public
  91. */
  92. function decode(){
  93. return $this->value;
  94. }
  95. }
  96. ?>