WCF MessageContract Inheritance

前端 未结 5 769
生来不讨喜
生来不讨喜 2020-12-11 19:36

I am fairly new to WCF and just have a question on how to correctly get MessageContract inheritance working. A simplified version of my setup is as follows - a \"base\" mess

5条回答
  •  隐瞒了意图╮
    2020-12-11 19:58

    OK, first question is: why are you really using Message contracts? Do you really have a need for that??

    Typically, message contracts are only ever used when you need to tightly control the layout of your SOAP message, e.g. to satisfy a legacy system you need to call which requires specific headers and such.

    A "normal" WCF call should hardly ever need to use a message contract.

    You define your service calls (the methods on your service) using [ServiceContract], and the data structures being passed around as [DataContract]. If you have a DataContract, you have more options as to how to deal with inheritance / polymorphism in your service (more than with the message contract construct).

    Marc

提交回复
热议问题