1

Hi I am writing a PHP function to communicate with an external WSDL service and am currently experiencing an issue. There are dateTime elements that either need a valid date/time or need to have a NULL variable passed through to them. For example:

<s:element minOccurs="1" maxOccurs="1" name="dAppointment" type="s:dateTime"/>

A simplified version of the PHP function is like so:

$client = new SoapClient($this->SOAPURL, array("connection_timeout" => 20));

$params = new stdClass();
$params->dAppointment = NULL;
settype($params->dAppointment, "null");  // Trying to confirm

$client->AddJob($params)->AddJobResult;

The function works fine when a valid date is submitted but when trying to pass a NULL variable through the following error is returned:

The string '' is not a valid AllXsd value

Suggesting that the value is being converted to an empty string along the way. Does the variable need to be set to NULL a different way like using SoapVar or could this be a problem at the WSDL end?

Thanks for any help.

Thomas
  • 53
  • 5

1 Answers1

0

So, everybody who got this issue, solution:

  • Open your local.wsdl file
  • Find your field:

<s:element minOccurs="1" maxOccurs="1" name="dAppointment" type="s:dateTime"/>

  • Change it to:

<s:element minOccurs="1" maxOccurs="1" name="dAppointment" type="s:dateTime" nillable="true" />

  • And now when you set variable as NULL it'll be NULL.
J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94