开发者

2 WCF services, 1 common interface, multiple headaches

I have 2 WCF services that implement an interface from a separate library. The interface's methods are not marked with either the WebGet or the WebInvoke attribute. BUT, one service is going to be handling POST request, while the other is handling the GET request. So its kinda like this:

Service 1: Handles all POST request. Request is in JSON, response is in JSON. All methods inherited and implemented from the interface are marked with WebInvoke

Service 2: Handles all GET request. Request is in JSON, response is in JSONP. All methods inherited and implimented from the interface are marked with WebGet

So far so good. Now fire these gu开发者_运维技巧ys up 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 would make sense if the actual interface already was marked with one or both of the attributes, but it isnt.

double hmmmmmm: This setup works perfectly fine if you create a default WCF service through VS add a second service and markup all the method implementations.

triple hmmmmmmm: If I only remove the WebGet attribute from my JSONP service (leaving the WebInvoke on the JSON service), it works. The same goes if i remove the WebInvoke attribute from my JSON service.

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


Have you tried removing the reference to the project that contains the contract (Interface) and re-adding it. Or even just try running "Clean Solution" in case something has gotten out of date.

I'm assuming it is a project reference you are using?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜