2

Here is the scenario. There is an existing service contract with some methods which are getting consumed by a desktop app. Now need to expose some operation contracts via ReST. But it demands to expose all the methods as ReST. Else there is exception with below text which often comes if the params are wrapped.

Really confusing. Seems like a bug in framework.

Error message -

Operation 'SaveEntitiy' of contract 'IService' 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.

Operation contract.

[ServiceContract]
public interface IService
{
        [OperationContract] //No need to expose this as ReST
        string SaveEntity(int id,string name);

        [OperationContract]
        [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json)]
        string GetData(int value);
}

If we expose the SaveEntity as ReST everthing works. Means the configs are correct.

Joy George Kunjikkuru
  • 1,495
  • 13
  • 27
  • Change WebInvoke to WebGet and specify UriTemplate – Maximus Dec 10 '15 at 09:43
  • @Maximus,Are you telling that its the problem with WebInvoke not allowing to have non ReST methods? In my actual code I have POST methods(opreation contracts) in the same service contract. There I cannot avoid WebInvoke – Joy George Kunjikkuru Dec 10 '15 at 14:51

1 Answers1

0

As you are trying to use GET just go with WebGet method like below:

[WebGet(UriTemplate = “GetData/input/{value}”)]

Or

You may also try using [WebGet] alone.