function echoDate($timeInstant) { require_once 'SOAP/Type/dateTime.php'; $dt = new SOAP_Type_dateTime($timeInstant); if ($dt->toUnixtime() != -1) { $value = $dt->toSOAP(); return new SOAP_Value('return', 'dateTime', $value); } else { return new SOAP_Fault("Value $timeInstant is not a dateTime value"); } }
/** * SOAP::Value::_getSoapType * * convert php type to soap type * @param string value * @param string type - presumed php type * * @return string type - soap type * @access private */ function _getSoapType(&$value, &$type) { $doconvert = FALSE; if (0 && $this->wsdl) { # see if it's a complex type so we can deal properly with SOAPENC:arrayType if (!$type && $this->name) { # XXX TODO: # look up the name in the wsdl and validate the type $this->debug("SOAP_VALUE no type for {$this->name}!"); } else { if ($type) { # XXX TODO: # this code currently handles only one way of encoding array types in wsdl # need to do a generalized function to figure out complex types if (array_key_exists($type, $this->wsdl->complexTypes)) { if ($this->arrayType = $this->wsdl->complexTypes[$type]['arrayType']) { $type = 'Array'; } else { if ($this->wsdl->complexTypes[$type]['order'] == 'sequence' && array_key_exists('elements', $this->wsdl->complexTypes[$type])) { reset($this->wsdl->complexTypes[$type]['elements']); # assume an array if (count($this->wsdl->complexTypes[$type]['elements']) == 1) { $arg = current($this->wsdl->complexTypes[$type]['elements']); $this->arrayType = $arg['type']; $type = 'Array'; } else { foreach ($this->wsdl->complexTypes[$type]['elements'] as $element) { if ($element['name'] == $type) { $this->arrayType = $element['type']; $type = $element['type']; } } } } } } } } } if (!$type || !$this->verifyType($type)) { if ($type && $this->wsdl && array_key_exists($type, $this->wsdl->complexTypes)) { # do nothing, this preserves our complex types } else { if (is_object($value)) { # allows for creating special classes to handle soap types $type = get_class($value); # this may return a different type that we process below $value = $value->toSOAP(); } elseif (isArray($value)) { $type = isHash($value) ? 'Struct' : 'Array'; } elseif (isInt($value)) { $type = 'int'; } elseif (isFloat($value)) { $type = 'float'; } elseif (SOAP_Type_hexBinary::is_hexbin($value)) { $type = 'hexBinary'; } elseif (isBase64($value)) { $type = 'base64Binary'; } elseif (isBoolean($value)) { $type = 'boolean'; } else { $type = gettype($value); # php defaults a lot of stuff to string, if we have no # idea what the type realy is, we have to try to figure it out # this is the best we can do if the user did not use the SOAP_Value class if ($type == 'string') { $doconvert = TRUE; } } } } # we have the type, handle any value munging we need if ($doconvert) { $dt = new SOAP_Type_dateTime($value); if ($dt->toUnixtime() != -1) { $type = 'dateTime'; $value = $dt->toSOAP(); } } else { if ($type == 'dateTime') { # encode a dateTime to ISOE $dt = new SOAP_Type_dateTime($value); $value = $dt->toSOAP(); } else { // php type name mangle if ($type == 'integer') { $type = 'int'; } else { if ($type == 'boolean') { if ($value != 0 && $value != '0' || strcasecmp($value, 'true') == 0) { $value = 'true'; } else { $value = 'false'; } } } } } return $type; }