ID: 44383 Comment by: barth at pbx-network dot de Reported By: kevin dot craft at gmail dot com Status: Open Bug Type: SOAP related Operating System: Windows XP PHP Version: 5.2.5 New Comment:
Anyone has a soluiton or workaround for this issue? How can a date/time been passed over to a webservice endpoint? Previous Comments: ------------------------------------------------------------------------ [2008-03-17 01:17:47] kevin dot craft at gmail dot com Exactly. The SOAP extension should know what format to output the DateTime as because it should be specified as a W3C standard somewhere in the SOAP or XML Schema definition. When the SOAP extension encounters an xsd:datetime (or related type), it should output the DateTime object according to the standard for that type. ------------------------------------------------------------------------ [2008-03-16 07:09:07] [EMAIL PROTECTED] We can't add __toString() to the date class, as it would have no idea on which format to use to render it. So it should be done in the SOAP ext. ------------------------------------------------------------------------ [2008-03-15 13:06:28] [EMAIL PROTECTED] Your idea then is add __toString in DateTime? This is not a bug, but a "feature request". :) ------------------------------------------------------------------------ [2008-03-09 18:22:29] kevin dot craft at gmail dot com In case it wasn't obvious, "Expected Result" should have read: "Assuming the current date is 2008-03-06 00:00:00:" rather than "2008-03-08 23:00:00". ------------------------------------------------------------------------ [2008-03-09 18:19:15] kevin dot craft at gmail dot com Description: ------------ When using a SoapServer object in WSDL mode, PHP DateTime objects are converted to an empty xsd:datetime element. To produce the correct results, DateTime objects have to be formatted as strings, which defeats the purpose of using the SoapServer to map data types. Environment: ------------ O/S: Windows XP Web Server: Apache 2.2 PHP: 5.2.5 w/ GD, MySQL, and SOAP Reproduce code: --------------- bug.wsdl: <?xml version ="1.0" encoding ="UTF-8" ?> <wsdl:definitions name="GetCurrentDate" targetNamespace="http://localhost" xmlns:tns="http://localhost" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"> <wsdl:message name="GetCurrentDateRequest" /> <wsdl:message name="GetCurrentDateResponse"> <wsdl:part name="currentDate" type="xsd:datetime" /> </wsdl:message> <wsdl:portType name="GetCurrentDatePortType"> <wsdl:operation name="getCurrentDate"> <wsdl:input message="tns:GetCurrentDateRequest" /> <wsdl:output message="tns:GetCurrentDateResponse" /> </wsdl:operation> </wsdl:portType> <wsdl:binding name="GetCurrentDateBinding" type="tns:GetCurrentDatePortType"> <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="getCurrentDate"> <soap:operation soapAction="http://localhost#getCurrentDate" /> <wsdl:input> <soap:body use="encoded" namespace="urn:xmethods-delayed-quotes" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> </wsdl:input> <wsdl:output> <soap:body use="encoded" namespace="urn:xmethods-delayed-quotes" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" /> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="GetCurrentDateService"> <wsdl:port name="GetCurrentDatePortType" binding="GetCurrentDateBinding"> <soap:address location="http://localhost" /> </wsdl:port> </wsdl:service> </wsdl:definitions> server.php: <?php function getCurrentDate() { return new DateTime(); } $server = new SoapServer('bug.wsdl'); $server->addFunction('getCurrentDate'); $server->handle(); ?> client.php <?php $client = new SoapClient('bug.wsdl', array('trace' => 1)); echo 'current date: '.$client->getCurrentDate().'<br /><br />'; echo 'last response: '.htmlentities($client->__getLastResponse()); ?> Expected result: ---------------- Assuming the current date is 2008-03-08 23:00:00: current date: 2008-03-06 00:00:00 (or any other format accepted by xsd:datetime) last response: <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getCurrentDateResponse><currentDate xsi:type="xsd:datetime">2008-03-06 00:00:00</currentDate></ns1:getCurrentDateResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> Actual result: -------------- current date: last response: <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:xmethods-delayed-quotes" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:getCurrentDateResponse><currentDate xsi:type="xsd:datetime" /></ns1:getCurrentDateResponse></SOAP-ENV:Body></SOAP-ENV:Envelope> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=44383&edit=1