2 WCF services, 1 common interface, multiple headaches

I have 2 WCF services that implement an interface from a separate library. Interface methods are not marked with either the WebGet attribute or the WebInvoke attribute. BUT, one service will process the POST request, and the other will process the GET request. So it’s kind of like:

Service 1: processes the entire POST request. The request is in JSON, the response is in JSON. All methods inherited and implemented from the interface are marked with WebInvoke

Service 2: processes all GET requests. The request is in JSON, the response is in JSONP . All methods inherited and implemented from the interface are marked with WebGet

So far so good. Now shoot these guys at aaaaaand splat. This is the error I get:

Operation 'SomeMethod' in contract 'IServiceContract' has both WebGetAttribute and WebInvokeAttribute; only one can be present. 

hmmmm, this makes sense if the actual interface has already been marked with one or both of the attributes, but this is not the case.

double hmmmmmm: this setting works fine, if you create the default WCF service via VS, add a second service and label all implementations of the method.

triple hmmmmmmm: If I remove only the WebGet attribute from my JSONP service (leaving WebInvoke in the JSON service), it will work. The same thing happens if I remove the WebInvoke attribute from my JSON service.

edit : another weird thing, only one of the services is causing this error (my JSONP / GET service) while the regular JSON / POST service is running.

+4
source share
1 answer

You tried to remove the link to the project containing the contract (Interface) and re-add it. Or even try running the Clean Solution if something is out of date.

I assume this is a link to the project you are using?

+1
source

All Articles