Search code examples
wcfwcf-rest

SOAP headers in WCF REST error


I have that error :

Operation 'GetFields' in contract 'IService' uses a MessageContract that has SOAP headers. SOAP headers are not supported by the None MessageVersion.

The problem is that my operation was used by two endpoints : CustomEndpoint with messageVersion="Soap12WSAddressing10" and second webHttpBehavior.

And I think that this error fire problem that Rest have MessageVersion.None

Any way to fix it ?


Solution

  • Unfortunately, in WCF RESTfulness tends to be a contract-level feature. That means that you often can't use a RESTful contract in a non-RESTful context and vice-versa.

    You have two options here, and each have their tradeoffs. First, you can have two separate contracts (one marked up for RESTful features and a "plain", non-RESTful one) that are both implemented by your WCF service. This requires that both contracts have identical method signatures, which may not always be possible.

    The second option is to have two separate WCF services, each with their own contract and processing code, but to have them both offload operation calls to a third class they both know about that does the actual work. This is the most flexible solution, but tends to require special translation code in either (or both) WCF service in order to call the third class.