From:             kevin dot craft at gmail dot com
Operating system: Windows XP
PHP version:      5.2.5
PHP Bug Type:     SOAP related
Bug description:  PHP DateTime not converted to xsd:datetime

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 bug report at http://bugs.php.net/?id=44383&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=44383&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=44383&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=44383&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=44383&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=44383&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=44383&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=44383&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=44383&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=44383&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=44383&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=44383&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=44383&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=44383&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=44383&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=44383&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=44383&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=44383&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=44383&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=44383&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=44383&r=mysqlcfg

Reply via email to