class.soap_val.php 2.2 KB

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