5

Deployed wcf service (.net 4.0). Service side config looks like:

<endpoint address="" binding="webHttpBinding" bindingNamespace="https://mydomain/myservice/services" behaviorConfiguration="WebBehavior" contract="MyService" /> <endpointBehaviors> <behavior name="WebBehavior"> <webHttp /> </behavior> </endpointBehaviors> 

Trying consume service in web app, web.config looks like:

<system.serviceModel> <client> <endpoint name="MyServiceEndpointBasicHttp" address="http://myDomain/myService" binding="webHttpBinding" behaviorConfiguration="webBehavior" contract="MyNamespace.IMyService" /> </client> <behaviors> <endpointBehaviors> <behavior name="webBehavior"> <webHttp /> </behavior> </endpointBehaviors> </behaviors> </system.serviceModel> 

I'm getting exception when calling service:

Operation 'Method1' of contract 'IMyService' 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.

After some googling, we've set [WebGet(BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Xml)] on methods, but no success...

One interesting thing: There is always the same method name in exception, even I'm calling other methods...

Service works fine in REST mode while testing with browser by entering method name and necessary paramaters...

1
  • 2
    Can you show us the service contract with the definition of your service methods? Commented Dec 27, 2010 at 16:25

1 Answer 1

3

It seems you're facing similar issue as in this thread: WCF Service Proxy throws exception when more than one parameter is used in [OperationContract] method

"It seems you have created Proxy code using Add Service Reference dialog in VS. VS ASR dialog doesn't support WCF REST fully, so, the proxy code is missing [WebInvoke] attribute. Can you try adding [WebInvoke(BodyStyle = WebMessageBodyStyle.Wrapped)] attribute on operations in client proxy?"

Sign up to request clarification or add additional context in comments.

1 Comment

What do you mean by "adding attribute on operations in client proxy" ? In which file it has to be added?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.