2016-02-05 63 views
1

我使用nusoap & php作爲服務器進行簡單的Web服務。在那個服務器頁面上,我想實例化Date對象並將其返回給客戶端。它將成爲complextype(結構)的一部分。我閱讀了關於soapval()函數的一些解決方案,但我無法使其工作。 那麼我該如何返回日期?如何在Nusoap服務器端創建日期格式?

//ComplexLoginType 
$server->wsdl->addComplexType('UserInfo','complexType','struct','all','', 
    array( 
    'Id' => array('name' => 'Id','type' => 'xsd:int'), 
    'LastName' => array('name' => 'LastName','type' => 'xsd:string'), 
    'FirstName' => array('name' => 'FirstName','type' => 'xsd:string'), 
    'Address' => array('name' => 'Address','type' => 'xsd:string'), 
    'Position' => array('name' => 'Position','type' => 'xsd:string'), 
    'Manager' => array('name' => 'Manager','type' => 'xsd:int'), 
    'Password' => array('name' => 'Password','type' => 'xsd:string'), 
    'Date' => array('name' => 'Date','type' => 'xsd:string')) 
); 

我的用法soapval();

$Date = new soapval('Token', 'dateTime', '2006-12-19T19:51:12.174Z'); 
+0

請檢查它,可能對你有幫助http://stackoverflow.com/questions/10172403/datetime-datatype-not-working-in-soap-php – Evgeniy

+0

這是關於發送日期格式到服務器。我想在服務器端創建日期格式而不是在客戶端。 –

回答

1

在我與的NuSOAP服務這個代碼工作

$server->wsdl->addComplexType( 
    'order_type', 
    'complexType', 
    'array', 
    'sequence', 
    '', 
    array(
     ... 
     'date_trips' => array('name' => 'date_trips', 'type' => 'xsd:date'), 
     ... 
    ) 
); 

和服務而日期YYYY-mm-dd格式。