onsdag den 12. januar 2011

Missing [WebGet] on WCF auto generated client

I have been working on a WCF web service for a client for some time now. Today I added a new method to the existing service interface and left everything else untouched. After updating the service reference in VS2010 the proxy presented me with the exception


The service methods are decorated with [WebGet] and it is exposed using the webHttpBinding. Without being true REST it is intended for easy consumation across platform and hence not only WCF clients. 

System.InvalidOperationException : Operation 'active' of contract 'ISubscriptionService' specifies multiple request body parameters to be serialized without any wrapper elements. At most one body parameter can be serialized without wrapper elements. Either remove the extra body parameters or set the BodyStyle property on the WebGetAttribute/WebInvokeAttribute to Wrapped.

The strange thing is that the proxy simply needed to get the [WebGet] attribute assigned which caused the abovementioned error to dissapear. But why is this attribute not generated automatically?

Apparantly decoration with  [WebGet] does not happen automatically in the service proxy. But luckily it can be put there manually. Just need to remember this when the service reference is updated.