WHY doesn't WCF 'properly' consume/expose abstract types when hosted as a web service

前端 未结 5 1833
臣服心动
臣服心动 2021-01-02 08:23

I\'ve been designing web services for quite a while now but never had to expose a \'complicated\' WCF service until recently. I was baffled at the apparent lack of \"proper

5条回答
  •  暖寄归人
    2021-01-02 08:47

    "abstract" is an implementation detail. It has no place in a service contract. Naturally, as soon as you insist that your caller must be aware you are returning an abstract type, WCF must fall back on a serializer that can expose this fact: and you're back to being stuck with the XmlSerializer.

    I suspect you're using abstract because that's the OO way to do things. But you're not doing OO, you're doing web services - SOA. There's a difference.

提交回复
热议问题