Wednesday, March 24, 2010

WCF: Error in deserializing body of reply message

Problem

You got an error "Error in deserializing body of reply message" when calling WCF service.

Solution

If your response message size is huge then check the reader quota settings in client app/web.config-file at bindings section and change them. For example:

<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/>

Note that you must have same binding, which settings you are changing, in server side also!

More about reader quota: http://msdn.microsoft.com/en-us/library/ms731325.aspx

Tuesday, March 16, 2010

WCF Oracle adapter: Field xxx has a value with time zone information set. Specify a value without time zone

Problem

I tried to call a Oracle stored procedure from orchestration with WCF Oracle Adapter.

My source message contains a date element like this <deliveryDate>2010-03-17T16:20:34.252125+02:00</deliveryDate> and when I put that value to destination message which is sent to Oracle: <DELIVERYDATE>2010-03-15T16:20:34.2365000Z</DELIVERYDATE>

I got an error "Microsoft.ServiceModel.Channels.Common.XmlReaderParsingException: Field DELIVERYDATE has a value with time zone information set. Specify a value without time zone.


Solution
Destination messsage date value should be modified to XML date format without timezone:

DateTime date = XmlConvert.ToDateTime(xmldate, XmlDateTimeSerializationMode.Unspecified);
DestinationElementValue = date.ToString("yyyy-MM-ddThh:mm:ss"));