Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple parameters passed in WCF client don't work (even when WebMessageBodyStyle is Wrapped)
    primarykey
    data
    text
    <p>Hi fellow StackOverflowers,</p> <p>I've got a WCF service wrtten C# that i can succesfully consume from things like jquery.</p> <p>I want to be able to consume it by adding a web service reference in C# and making calls in the code. Everything was rosy, until I added multiple parameters. When I try to call <strong>any</strong> Service method, I get this error:</p> <blockquote> <p>Operation 'GetStopNames' of contract 'IPublic' 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.</p> </blockquote> <p>I googled and searched StackOverflow for ages, but everybody seemed to have their problem fixed by setting <code>BodyStyle=WebMessageBodyStyle.Wrapped</code> in the WebGet / WebInvoke attributes.</p> <p>An example of one of my service methods in the interface:</p> <pre><code> [OperationContract] [WebGet( BodyStyle=WebMessageBodyStyle.WrappedRequest , UriTemplate = "GetOperators?appKey={apk}" , RequestFormat = WebMessageFormat.Json , ResponseFormat = WebMessageFormat.Json)] ResultList GetOperators(string apk); </code></pre> <p>Is there something wrong with this?</p> <p>I'm simply calling</p> <pre><code>ServiceReference1.PublicClient c = new ServiceReference1.PublicClient(); c.GetOperators("XXX"); </code></pre> <p>inside the client, and it's breaking on the second line.</p> <p>Any ideas? If there is any more data you need to help answer me, just add a comment :)</p> <p>EDIT: here are the excerpts of relevant bits from my Web.config files <a href="http://pastebin.com/CyQNG6wk" rel="nofollow">http://pastebin.com/CyQNG6wk</a></p> <p>EDIT: shortcut to serviceContract that I linked in comments <a href="http://pastebin.com/bvGmGtfd" rel="nofollow">http://pastebin.com/bvGmGtfd</a></p> <p>I ended up switching to using WebApi but I'm keeping this question open since I'm still not sure why it was failing.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload