Hacker News new | ask | show | jobs
by ilitirit 4050 days ago
> Have enumerations somewhere? WCF will encode them as integers.

Can you give an example of this? I have never had this problem.

> Have or need a date/time value in a format that isn't what WCF generates or expects

In my experience this is a data-interchange problem that will always exist. It is not unique to WCF.

I do agree that if you are using REST/Json then you should avoid WCF.

1 comments

On phone, can't copy/paste.

But e.g. Enum Direction { East, West, North, South };

Put that as a field in a structure that's sent/received through WCF; on JSON it will encode as numbers, regardless on any annotation you put. On XML iirc too - though I don't remember for sure. Want them as strings? You have to encode/decode yourself. But if you use .NET on both sides , you wouldn't notice unless you sniff the connection - until you change the enumeration order, for example, and all help breaks loose. Which is to be expected of a binary protocol, but completely unexpected for verbose text formats like JSON or XML.

> On XML iirc too

It serializes correctly.

For JSON you need an appropriate converter but as I said I would not use WCF with JSON.