Search code examples
phpsoapnusoap

How do I send an empty dateTime with NUSOAP?


I'm using NUSOAP on the server-side of a web service. I want to return a null dateTime element, but I'm not sure how.

If I return the values false or '' , the result is

<due_date xsi:type="xsd:dateTime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

whereas I would like it to be

<due_date xsi:type="xsd:dateTime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:null="true"/>

If I return null, the due_date tag is not present anymore, which causes problems on the client side.


Solution

  • Instead of null or '', explicitly return new soapval( 'element','xsd:dateTime', null ).

    (Some) courtesy of the NuSOAP Sourceforge forums.