PHP Classes

Support for xsd:datetime?

Recommend this page to a friend!

      PHP WSDL Generator  >  All threads  >  Support for xsd:datetime?  >  (Un) Subscribe thread alerts  
Subject:Support for xsd:datetime?
Summary:DateTime object return causes empty WSDL file (no errors)
Messages:14
Author:Galmok
Date:2009-04-27 11:12:13
Update:2009-07-02 08:49:20
 
  1 - 10   11 - 14  

  11. Re: Support for xsd:datetime?   Reply   Report abuse  
Picture of Protung Dragos Protung Dragos - 2009-04-28 13:08:07 - In reply to message 10 from Protung Dragos
To ignore classes use the:

$WSDLCreator->ignoreClass ($class);
or
$WSDLCreator->ignoreClasses ($classes); // array of classes

methods

  12. Re: Support for xsd:datetime?   Reply   Report abuse  
Picture of Galmok Galmok - 2009-05-11 15:06:43 - In reply to message 11 from Protung Dragos
In case anyone is looking for datetime support, I got this to work:

/**
* getCurrentDate: returns dateTime
*
* @return DateTime $datetime
*/
function getCurrentDate() {
return new SoapVar(time(), XSD_DATETIME);
}

This will take the unix timestamp and return the date and time correctly.

Receiving datetime from a client is more difficult and I did it this way (php 5.2.9):

server:

/**
* Set date and time
*
* @param datetime $datetime
* @return DateTime $datetime
*/
function setDateTime($datetime) {
if ($datetime) {
try {
$dt = new SOAP_Type_dateTime($datetime);
$dt_u=$dt->toUnixtime();
// $dt_u is -1 if the string can't be converted
return new SoapVar($dt_u, XSD_DATETIME);
}
catch(Exception $ex) {
throw new SoapFault("Server", "Error: " . $ex);
}
} else {
throw new SoapFault("Server", "No time was given");
}
}

client:

$t=time();
$dt = new SoapVar($t, XSD_DATETIME);
$par = new SoapParam($dt, "datetime");
print($client->setDateTime($par));


Next adventure: Sending and receiving of nested arrays... (no idea so far)

  13. Re: Support for xsd:datetime?   Reply   Report abuse  
Picture of Galmok Galmok - 2009-05-11 15:10:20 - In reply to message 12 from Galmok
The line:

$dt = new SOAP_Type_dateTime($datetime);

requires dateTime.php from the SOAP PEAR package to included:

require_once 'SOAP/Type/dateTime.php';

which means PEAR has to be installed (although the file could be used as stand-alone).

  14. Problem with return type   Reply   Report abuse  
Picture of Petr Kučera Petr Kučera - 2009-07-02 08:49:20 - In reply to message 13 from Galmok
I have problem with return type - class/object

service.php
class service{

/**
* @param Integer $id
* @return TCategory $TCategory
*/
public function GetCategory( $id ) {
//some code

return $TCategory; //return instance of TCategory
}
}
----
and TCategory.php

class TCategory {

/**
* @var Integer
*/
public $id;

/**
* @var String
*/
public $name;

/**
* @var String
*/
public $value;
}
----

how i generate <types> into wsdl document?
like
<types>
<schema targetNamespace="urn:namespace">
<complexType name="TCategory">
<sequence>
<element name="id" type="unsignedInt"/>
<element name="name" type="string"/>
<element name="value" type="string"/>
</sequence>
</complexType>
</schema>
</types>



I have:

$wsdl = new WSDLCreator("name", "http://localhost/server/service.php");
$wsdl ->addURLToTypens("TCategory", "http://localhost/server/TCategory.php");

$wsdl ->addFile("service.php");
$wsdl ->addURLToClass("service", "http://localhost/server/service.php?server");

$wsdl ->createWSDL();
$wsdl ->printWSDL(true); // print with headers



and __GetFunctions return "UNKNOWN GetCategory(integer $id)"
instead of "TCategory GetCategory(integer $id)"


thanks

 
  1 - 10   11 - 14