值“2016-09-17”根据其数据类型无效 - 如何修复?

时间:2016-09-17 15:15:51

标签: php soap

我正在使用SOAP与E-conomic进行API集成。这里列出了SOAP调用的文档:

https://api.e-conomic.com/secure/api1/EconomicWebService.asmx?op=CashBookEntry_CreateFromData

一切正常,除了使用Date参数时,我收到此错误:

  

object(SoapFault)#3(10){[“message”:protected] => string(304)“Economic.Api.Exceptions.SchemaException(E00500):'e-conomic.com:Date'元素无效 - 根据数据类型'w3.org/,值'2016-09-17'无效2001 / XMLSchema:dateTime' - 字符串'2016-09-17'不是有效的DateTime值。(id = 2bd3961a-1c13-46c9-8b4c-5dacd58ac4d4)“[”string“:”Exception“:private] =&gt ; string(0)“”[“code”:protected] => int(0)[“file”:protected] => string(34)“/ Applications //index.php”[“line”:protected] => int(89)[“trace”:“Exception”:private] => array(1){[0] => array(6){[“file”] => string(34)“/ Applications //index.php”[“line”] => int(89)[“function”] => string(6)“__ call”[“class”] => string(10)“SoapClient”[“type”] => string(2)“ - >” [ “ARGS”] => array(2){[0] => string(28)“CashBookEntry_CreateFromData”[1] => array(1){[0] => array(1){[“data”] => array(10){[“Type”] => string(15)“CreditorPayment”[“CashBookHandle”] => array(1){[“Number”] => int(1767)} [“CreditorHandle”] => array(1){[“Number”] => int(6750)} [“ContraAccountHandle”] => array(1){[“Number”] => int(6750)} [“Date”] => string(10)“2016-09-17”[“VoucherNumber”] => int(1767)[“Text”] => string(3)“API”[“AmountDefaultCurrency”] => int(298)[“Amount”] => int(298)[“CurrencyHandle”] => array(1){[“Code”] => string(3)“DKK”}}}}}}} [“previous”:“Exception”:private] => NULL [“faultstring”] => string(304)“Economic.Api.Exceptions.SchemaException(E00500):'e-conomic.com:Date'元素无效 - 根据数据类型'.w3.org,值'2016-09-17'无效/ 2001 / XMLSchema:dateTime' - 字符串'2016-09-17'不是有效的DateTime值。(id = 2bd3961a-1c13-46c9-8b4c-5dacd58ac4d4)“[”faultcode“] => string(11)“soap:Client”[“detail”] => string(0)“”}

我在SOAP调用上传递了这个日期格式:

date("Y-m-d");

但它一直给我同样的错误。任何人都可以看到我传递给电话的日期有什么问题吗?

1 个答案:

答案 0 :(得分:0)

问题已通过日期时间类修复:

$ d = new \ DateTime();

$ D->格式(' C&#39)

这为我们提供了标准的W3日期时间格式。