Forum Discussion

lwakeman's avatar
lwakeman
New Contributor
12 years ago

Passing nullable datetimes

I'm working in SOAPUI 4.5 Beta 1. I have a web service created in c#.Net 4.0 WCF. My data contract datetime properties are defined as nullable - i.e. public datetime? property { get; set; } - note the ? after datetime. This works beautifully when I run the service from a front end I created. However, our requirement is to test it in SOAPUI. Unfortunately, when I pass a blank date field (or even one if mm/dd/yyyy format instead of yyyy-mm-dd) I get a completely unintelligible error message that ultimately tells me nothing. My SOAPUI request and response are below.

Is there some configuration setting or something that will allow me to pass blank dates? I can't believe nobody else has run into this (unless everyone uses strings instead of dates). But I haven't been able to find any help.

Request - note that the ClientReceivedDate is empty:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:imag="http://TmgServices/ImageWebService">
<soapenv:Header/>
<soapenv:Body>
<imag:GetDocumentList>
<!--Optional:-->
<imag:documentRequest>
<!--Optional:-->
<imag:imageType>
<!--Optional:-->
<imag:ClientCode>PRH</imag:ClientCode>
<!--Optional:-->
<imag:ClientReceivedDate></imag:ClientReceivedDate>
</imag:imageType>
</imag:documentRequest>
</imag:GetDocumentList>
</soapenv:Body>
</soapenv:Envelope>

Unintelligible response that tells me nothing:

<ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HelpLink i:nil="true"/>
<InnerException>
<HelpLink i:nil="true"/>
<InnerException>
<HelpLink i:nil="true"/>
<InnerException>
<HelpLink i:nil="true"/>
<InnerException i:nil="true"/>
<Message>The string '' is not a valid AllXsd value.</Message>
<StackTrace>at System.Xml.Schema.XsdDateTime..ctor(String text, XsdDateTimeFlags kinds)
at System.Xml.XmlConvert.ToDateTime(String s, XmlDateTimeSerializationMode dateTimeOption)
at System.Xml.XmlConverter.ToDateTime(String value)</StackTrace>
<Type>System.FormatException</Type>
</InnerException>
<Message>The value '' cannot be parsed as the type 'DateTime'.</Message>
<StackTrace>at System.Xml.XmlConverter.ToDateTime(String value)
at System.Xml.XmlBaseReader.ReadContentAsDateTime()
at System.Xml.XmlDictionaryReader.ReadElementContentAsDateTime()
at System.Runtime.Serialization.XmlReaderDelegator.ReadElementContentAsDateTime()
at ReadImageTypeFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Int32 id, RuntimeTypeHandle declaredTypeHandle, String name, String ns)
at ReadDocumentRequestFromXml(XmlReaderDelegator , XmlObjectSerializerReadContext , XmlDictionaryString[] , XmlDictionaryString[] )
at System.Runtime.Serialization.ClassDataContract.ReadXmlValue(XmlReaderDelegator xmlReader, XmlObjectSerializerReadContext context)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.ReadDataContractValue(DataContract dataContract, XmlReaderDelegator reader)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator reader, String name, String ns, Type declaredType, DataContract&amp; dataContract)
at System.Runtime.Serialization.XmlObjectSerializerReadContext.InternalDeserialize(XmlReaderDelegator xmlReader, Type declaredType, DataContract dataContract, String name, String ns)
at System.Runtime.Serialization.DataContractSerializer.InternalReadObject(XmlReaderDelegator xmlReader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)</StackTrace>
<Type>System.Xml.XmlException</Type>
</InnerException>
<Message>There was an error deserializing the object of type Model.Business.Imaging.DocumentRequest. The value '' cannot be parsed as the type 'DateTime'.</Message>
<StackTrace>at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName, DataContractResolver dataContractResolver)
at System.Runtime.Serialization.XmlObjectSerializer.ReadObjectHandleExceptions(XmlReaderDelegator reader, Boolean verifyObjectName)
at System.Runtime.Serialization.DataContractSerializer.ReadObject(XmlDictionaryReader reader, Boolean verifyObjectName)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo.ReadObject(XmlDictionaryReader reader, XmlObjectSerializer serializer)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.PartInfo.ReadObject(XmlDictionaryReader reader)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)</StackTrace>
<Type>System.Runtime.Serialization.SerializationException</Type>
</InnerException>
<Message>The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://TmgServices/ImageWebService:documentRequest. The InnerException message was 'There was an error deserializing the object of type Model.Business.Imaging.DocumentRequest. The value '' cannot be parsed as the type 'DateTime'.'. Please see InnerException for more details.</Message>
<StackTrace><![CDATA[at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameterPart(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameter(XmlDictionaryReader reader, PartInfo part, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeParameters(XmlDictionaryReader reader, PartInfo[] parts, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.DataContractSerializerOperationFormatter.DeserializeBody(XmlDictionaryReader reader, MessageVersion version, String action, MessageDescription messageDescription, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeBodyContents(Message message, Object[] parameters, Boolean isRequest)
at System.ServiceModel.Dispatcher.OperationFormatter.DeserializeRequest(Message message, Object[] parameters)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.DeserializeInputs(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)]]></StackTrace>
<Type>System.ServiceModel.Dispatcher.NetDispatcherFaultException</Type>
</ExceptionDetail>


THANKS!!!

2 Replies

  • lwakeman's avatar
    lwakeman
    New Contributor
    I know one way is to just manually remove the null fields from the SOAPUI request, but that is not an option with our requirements.
  • ProdipK's avatar
    ProdipK
    Occasional Contributor
    Have a look at this article. It's more work but you can leave behind the hard-to-debug serialization issue. This works at the .net server-side but you may have problem displaying the response in the SoapUI response window because SoapUi does not do custom serialization.

    Soap serialization in .Net Framework
    viewtopic.php?f=5&t=14720