+ Start a Discussion
Doug ADoug A 

Outbound Message pain: System.FormatException: String was not recognized as a valid DateTime.

I'm finding this error occurs when I include fields of type DateTime (for example, LastModifiedDate) on an outbound message.  I've posted a snippet of the output from YATT stack trace below.  BTW, I'm running Win2k3, IIS 6.0, .NET 2.0.


HTTP/1.1 500 Internal Server Error
Date: Fri, 02 Feb 2007 08:32:49 GMT
Server: Microsoft-IIS/6.0
MicrosoftOfficeWebServer: 5.0_Pub
X-AspNet-Version: 2.0.50727
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Content-Length: 2584


System.Web.Services.Protocols.SoapException: Server was unable to read request.
---> System.InvalidOperationException: There is an error in XML document (21, 73).
---> System.FormatException: String was not recognized as a valid DateTime.
   at System.DateTimeParse.ParseExactMultiple(String s, String[] formats, DateTimeFormatInfo dtfi, DateTimeStyles style)
   at System.DateTime.ParseExact(String s, String[] formats, IFormatProvider provider, DateTimeStyles style)
   at System.Xml.XmlConvert.ToDateTime(String s, String[] formats)
   at System.Xml.Serialization.XmlCustomFormatter.ToDateTime(String value, String[] formats)
   at System.Xml.Serialization.XmlCustomFormatter.ToDate(String value)
   at System.Xml.Serialization.XmlSerializationReader.ToDate(String value)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read2_NullableOfDateTime(Boolean checkType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read5_MY_CUSTOM_SOBJECT__c(Boolean isNullable, Boolean checkType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read7_MY_CUSTOM_SOBJECT__cNotification(Boolean isNullable, Boolean checkType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read8_notifications(Boolean isNullable, Boolean checkType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read10_notifications()
   at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Deserialize(XmlSerializationReader reader)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   --- End of inner exception stack trace ---
   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()



Now, I was able to work around this by 1) removing the DateTime field(s) from the outbound message--which enables the serialization to work and let the web service code proceed to execute--and then 2) using "retrieve" to get the field when its needed in runtime.  Alas, this results in an extra round-trip, which is unfortunate.  At least it works for now. 

Any other suggestions?  I'm sure others will encounter this at some point. 


Doug ADoug A
Sorry about the very wide message.  Here's what I was trying to say, without the
stack trace:

I'm finding this error occurs when I include fields of type DateTime (for
example, LastModifiedDate) on an outbound message.  I've posted a snippet of the
output from YATT stack trace below.  BTW, I'm running Win2k3, IIS 6.0, .NET 2.0.


(wide stack trace removed)

Now, I was able to work around this by 1) removing the DateTime field(s) from the
outbound message--which enables the serialization to work and let the web service
code proceed to execute--and then 2) using "retrieve" to get the field when its
needed in runtime.  Alas, this results in an extra round-trip, which is
unfortunate.  At least it works for now.

Any other suggestions?  I'm sure others will encounter this at some point.


SuperfellSuperfell
See the thread at the top of this board that says, resolution for dateTime parsing issues with .NET 2.0
sfunstonsfunston
Hi.  I seem to be having this same problem, but I can not find the post that you refered to.  I would appreciate it if you could reply with some more information. 

Thanks
SuperfellSuperfell
http://community.salesforce.com/sforce/board/message?board.id=NET_development&message.id=4069
sfunstonsfunston
Thanks a lot Simon.  Your help in this matter is greatly appreciated.