I have a WCF web service that is being consumed by ABAP, which expects the 'Z' character at the end for UTC time. The WCF service is serializing it just fine, with the exception of the 'Z'.

That is, it is sending 2014-01-12T19:43:13, where I want it to send 2014-01-12T19:43:13Z.

I have read several posts relating to this, but I am hoping there's a really elegant solution available. Adding another element/member that returns a string is not ideal.

As an alternative, is there a way to specify the format used, so that the client can parse the date time using said format?

有帮助吗?

解决方案

You're right, 500 - Internal Server Error, it does, if the DateTime has it's DateTimeKind set to Utc, which it didn't (even though it was in UTC time). I created an extension method, using DateTimeOffset, to return a DateTime with the DateTimeKind set to Utc and all is well.

Scratch that, I opted to use the DateTime.SpecifyKind() method instead, which seems neater.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top