ID: 44383
User updated by: kevin dot craft at gmail dot com
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:
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".
Previous Comments:
------------------------------------------------------------------------
[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